An implementation of the Monty Hall problem. See https://en.wikipedia.org/wiki/Monty_Hall_problem for more info about the problem.
The function montyhall
can be called with no parameters, so you can play the game, or with params to simulate a game. Below the function I wrote code to simulate a given amount of games according to the settings variables. By default it calls the function 10,000 times starting with a random door, and always switching, then 10,000 times starting with a random door, and staying with the original choice all the time. Then it calculates the percentage, and prints them out. It shows that if you switch there is an average 66% chance of winning, and if you stay a 33% chance of winning. Keep the switchtimes
, and staytimes
high to make sure you get accurate results.
-
Notifications
You must be signed in to change notification settings - Fork 0
A monty hall simulator with a playable mode
License
NoahCristino/montyhall
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A monty hall simulator with a playable mode
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published