function Analyzer;

global Demands muA muS;
global Num devicenum
global Devices refusednum capacity
global curtime queuetime worktime TimeCount muA muS systemtime
global queueamount workamount sysamount queuenum time
global sysusage avgwaittime avglivetime avgqueueamount avgsysamount
global rand1 rand2

sysusage = worktime/(devicenum*curtime);

sum = 0;
for i=2:length(Demands)
    sum = sum + Demands(2,i);
end;

muA = sum/(length(Demands)-1);

%Дисперсия
%disp = 0;
%for i=1:1:(length(Demands)-1)
 %   disp = disp + (Demands(2,i)-0.50088)^2 / ((length(Demands)-1) - 1);
%end;
%fprintf('\nДисперсия: %10.7f\n',disp);

sum = 0;
for i=1:length(Demands)
    sum = sum + Demands(3,i);
end;

muS = sum/length(Demands);

%Дисперсия
%disp1 = 0;
%for i=1:1:(length(Demands)-1)
 %   disp1 = disp1 + (Demands(3,i)-muS)^2 / ((length(Demands)-1) - 1);
%end;
%fprintf('\nДисперсия1: %10.7f\n',disp1);

avgqueueamount = queuetime/curtime;

avgwaittime = avgqueueamount*muA;

sysamount = queueamount + workamount;

avglivetime = avgwaittime+muS;

avgsysamount = avglivetime/muA;



%fprintf('\n/r1/r2/p/d/w/q/l/\n Values: %4.6f  %4.6f  %4.6f  %4.6f  %4.6f  %4.6f  %4.6f \n\n',rand1, rand2, sysamount,avgwaittime,avglivetime, avgqueueamount,avgsysamount);

%fprintf(f,'<td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td></tr>\r\n',rand1, rand2, sysamount,avgwaittime,avglivetime, avgqueueamount,avgsysamount);%fprintf('rejected = %d\n', rejected);  

