jeudi 26 mai 2016

Modify this code to estimate the probability of three heads in three flips assuming the coin has a 55% probability of heads

I am attempting to modify the code below which is a random number generator designed to estimate the percentage of times 3 coins are flipped and they are all heads. Now I must assume the coin has a 55% chance of heads, and modify the code so that it estimates the probability of three heads in three flips. I am honestly lost on how to incorporate the 55% chance of heads, and then estimating three heads in three flips. ANY help is most greatly appreciated!!

trials = 10000;

flip = rand(trials,3,1);

heads = (flip >= 0.5);

freq = sum(all(heads,2));

percent = freq/trials

percent =

0.1281

Thank you in advance!!




Aucun commentaire:

Enregistrer un commentaire