Answer to Question #31375 in MatLAB | Mathematica | MathCAD | Maple for Fatih
If 2% of the bolts produced by a machine are defective, write a Matlab m-file to determine and output the probability that out of 400 bolts chosen at random greater than 10 bolts will be defective. Compare your results with the analytical solution. Use a billon random events.
pls help us...pls pls pls:(:(:(
function& y& = probability(& ) %UNTITLED Summary of this function goes here % Detailed explanation goes here A= zeros(50); A(1)=1; C=zeros(400); counter=0; Value=0; for i=1:2500000 for i=1:1:400 x2 = randi(50,1); C(i)=A(x2); if C(i)==1 & counter=counter+1; end end if counter>10 Value =Value + 1; end
end for i=1:10 AnalitSolution=1-((1/50)^i)*(49/50)^(400-i); end y=[Value/2500000,AnalitSolution];