This implementation solves the famous Monty Hall problem, presenting an interactive dashboard where you can simulate numerous iterations of the game and visibly note the win percentages in both scenarios, i.e., switching and not switching the chosen door.
.
├─ README.md
├─ requirements.txt
└─ src
├─ monty_hall.py
└─ app.py
README.md: This descriptive filerequirements.txt: Contains all the required modules and libraries needed to run the projectsrc/monty_hall.py: Contains the Python program to simulate the Monty Hall gamesrc/app.py: The Streamlit application file to display an interactive dashboard
- Python 3.7 or higher
- Streamlit
- pandas
To install necessary packages, run pip install -r requirements.txt.
You can play the Monty Hall game simulation by adding the src directory to the PYTHONPATH and running:
python3 src/monty_hall.py
To start the Streamlit dashboard, run:
streamlit run src/app.py
On running the Streamlit application, you will see an input field where you can specify the number of games to simulate. The app will then perform a simulation for each game, both where the contestant switches doors and where they don't. Lastly, the dashboard will display the win percentages dynamically as two separate line charts - showing how the likelihood of winning changes based on your decision to switch or not to switch doors.