/Monty-Hall-Problem-Simulator

Simulated the Monty Hall Problem and verified winning probabilities

Primary LanguagePythonMIT LicenseMIT

Monty-Hall-Problem-Simulator

Python code to simulate the Monty Hall Problem (MHP) and verify winning probabilities

Running The Code

Command: python3 MHP.py NUMBER OF SIMULATIONS
Recommended NUMBER OF SIMULATIONS: 2500-3000 (although the more the merrier)
Approximate run-time for 2500-3000 simulations: 1 minute

Verification of the Following Facts (using a generated plot)

  • Probability of winning if you switch = 2/3
  • Probability of winning if you stick = 1/3

Mathematical Insight

Assume (#winning ratio after switching) as a Bernoulli random variable with p = 2/3 (Expectation = 2/3)
or,(#winning ratio after sticking) as a Bernoulli random variable with p = 1/3 (Expectation = 1/3)
The results we get are in accordance with the Law of Large Numbers
i.e with very high number of simulations, the winning ratio does converge to its expected value

Useful Links

About the problem: https://en.wikipedia.org/wiki/Monty_Hall_problem
MIT Maths for CS: https://www.youtube.com/watch?v=SmFwFdESMHI