I'm asked to find the probability of this problem :(
Afficher commentaires plus anciens
hello all, we had this problem in the class and we asked to verify the answer using MATLAB (answer=0.13867), so I write the following code:
if true
>> a= rand;
b=rand;
c=rand;
e=rand;
d=rand;
x=0.251;
n=0;
p=0;
for i=1: 10000
if (a<x)
a=1;
else
a=0;
end
if (b<x)
b=1;
else
b=0;
end
if (c<x)
c=1;
else
c=0;
end
if (d<x)
d=1;
else
d=0;
end
if (e<x)
e=1;
else
e=0;
end
p = (a*b)+ (a*e*d)+(c*d)+(c*e*b);
if (p>=1)
n=n+1;
end
end;
n/10000 end
and the answer appears is either 1 or 0.5, what is wrong? thanks ahead, I've to submitting it tomorrow, pls help
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Parallel Computing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!