/Monty-Hall-Problem

Simulation for Monty Hall problem with the ability to run millions of tests in seconds.

Primary LanguagePythonMIT LicenseMIT

Monty Hall Problem

Simulation for Monty Hall problem with the ability to run millions of tests in seconds.


Environment

MontyHall The environment is very simple, done entirely in python and numpy. It is possible to configure the number of tests by changing the global variable LOOP_SIZE or change the initial 'seed' of the doors by changing the global variable SEED. This project only took into consideration the use of 3 doors, to use more doors the code should be remade.

Setup

All of requirements is show in the badgets above, but if you want to install all of them, enter the repository and execute the following line of code:

pip3 install -r requirements.txt

To execute the code just use:

python3 monty_hall.py

Objectives

This problem consists in a game where we have 3 doors, two of these doors are empty and one has a prize. The player must choose a door to his liking and then one of the doors that was not chosen by the player and that does not have the prize will be opened leaving the player with two options: continue with his door or change to the other door. It's common sense to believe that only because you have two doors the chance of hitting is 50%.

This project aims to demonstrate that the best choice for the second stage is to switch to the other door. And this can be demonstrated by this simulation, bringing a very big gain by making this choice, where the chance of hit goes from 33% to 66%.

MontyHall

If you liked this repository, please don't forget to starred it!