Program
Program
p = 0.10;
Nc = 20;
Fix = 5;
N = 100000;
Time_to_clear = zeros(N,1);
All_infected = zeros(N,1);
Num_infected= zeros(N,1);
for k=1:N;
T = 0 ;
Infected_comps = [1
zeros(Nc-i , 1)];
Infected_at_least_once = Infected_comps;
Ninfected = sum(Infected_comps);
Compfix = 1; Ncompfix = 0;
while (Campfix <= Nc) Kc (Ncompfix < Fix);
if Infected_comps(Compfix)==1;
Infected_comps (Compfix) =0;
Ncompfix = Ncompfix+1;
end;
Compfix = Campfix + 1;
end;
Ninfected = sum(lnfected_comps);
end;
Time_to_clear(k) = T;
All_infected(k) ( sum(Infected_at_least_once)==Nc );
Num_infected(k) ( sum(Infected_at_least_once) );
end;
-----------------------------------------------------------------------------------
--------------------------------------------------
output
-----------------------------------------------------------------------------------
--------------------------------------------------
The expected time until all computers are fixed is approximately 73 days
The probability that each computer gets infected at least once is approximately
0.0012
The expected number of computers that get infected is approximately 2.98