Hi all. I have been working my way through the Probability course, specifically the section on Conditional Probability, when I fell upon this linked problem.
By solving the linked problem recursively, you find that you have a \(\frac{1}{3}\) probability of winning the game.
I thought this would be a fun problem to program, so I wrote a program in Python 3 to solve this using Monte Carlo methods. The program and output of the program can be seen below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 

Output:
0.5001471644515492
Assuming the program is correct, the probability of winning the game is approximately \(\frac{1}{2}\), as opposed to the original solution that states you have a \(\frac{1}{3}\) chance of winning the game.
Can anyone explain what is going on here (it is very possible that my code has something wrong with it, or I am misunderstanding some fundamental concept. If you catch anything please point it out :)?
Comments
Sort by:
Top NewestExcellent simulation. Your code is mostly correct, except for a small typo in line 21. Can you figure it out? – Agnishom Chattopadhyay · 3 weeks, 6 days ago
Log in to reply