- Notifications
You must be signed in to change notification settings - Fork10
Simulating monty hall problem with python
Kalebu/Monty-Hall-Problem-Simulation-in-Python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The repository acts as the source code for theMonty hall problem simulation
I'm a great fan of movies & thus where most of biggest motivation in STEM and coding came from, The first time I came across the Monty hall problem was when I was watching movie titled21.
_Assume There are three doors, and behind one of them is a car, while behind the other two are goats. If you choose the door with the car behind it, you win the car. Now, say you choose Door 1. The host Monty Hall then opens either Door 2 or Door 3, behind which is a goat. (He knows what is behind each door, and never opens the door with the car behind it.) Monty now gives you the choice: do you want to stick with Door 1, or switch to the other door. What should you do? Or does it matter?
Now the battle liesEmotion vs Math, mathematically switching would give you a 2/3 probability of winning rather than sticking to the same door as the probabilty of winning a car among those two door would concentrate into one.
In this source code I have simulated this problem using random module to simulate the process, and supringly with enough trials the probability winning when you switch converge to 0.6666.. which is equivalent to 2/3.
To get started running the simulation for this code, you might wanna clone or download the repository first just as shown below;
$-> git clone https://github.com/Kalebu/Monty-Hall-Problem-Simulation-in-Python
Open in a terminal in a project directory or you can just change a directory into the project directory and then run th app just as shown below;
$->cd Monty-Hall-Problem-Simulation-in-Python$ Monty-Hall-Problem-Simulation-in-Python-> python app.py
Once you run the application, a very simple gui similar to what shown below will pop up with an entry box, write in it no of sample to be simulated and then press enter and then program will evaluate total wins for case of same choice or switching
Did you find this information useful, then give it a star
1.https://www.mathwarehouse.com/monty-hall-simulation-online/
All the credits tokalebu
About
Simulating monty hall problem with python
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.