Aaron offers Berenice to play a game of dice with him. Aaron explains the game to Berenice as follows:
"We each get one die, the highest one wins. If we tie, I win, but since you always lose when you roll a one, if you roll a one you can roll it again. If you get a one the second time you have to keep it."
What is each person's probability of winning? What are the probabilities of winning if Berenice can keep rolling until she gets something besides a one?
(In reply to
solution by Charlie)
Part 1:
bwin=0; awin=0;
for trial=1:100000000
a=randi(6);
b=randi(6);
if b==1
b=randi(6);
end
if b>a
bwin=bwin+1;
else
awin=awin+1;
end
end
fprintf('%8s %7.5f ','a prob =',awin/trial,'b prob =',bwin/trial);
fprintf('\n');
Five runs with 1 million trials each, plus one with 100 million trials:
>> gameOfDice
a prob = 0.51150 b prob = 0.48850
>> gameOfDice
a prob = 0.51318 b prob = 0.48682
>> gameOfDice
a prob = 0.51269 b prob = 0.48731
>> gameOfDice
a prob = 0.51461 b prob = 0.48539
>> gameOfDice
a prob = 0.51358 b prob = 0.48642
>> gameOfDice
a prob = 0.51393 b prob = 0.48607
Part 2:
Repeating the above (5 with one million, 1 with 100 million trials), but with
while b==1
instead of
if b==1
we get:
>> gameOfDice
a prob = 0.50023 b prob = 0.49978
>> gameOfDice
a prob = 0.49895 b prob = 0.50106
>> gameOfDice
a prob = 0.50075 b prob = 0.49925
>> gameOfDice
a prob = 0.50071 b prob = 0.49929
>> gameOfDice
a prob = 0.49988 b prob = 0.50012
>> gameOfDice
a prob = 0.50002 b prob = 0.49998
|
Posted by Charlie
on 2022-11-14 14:00:50 |