Skip to content

Mithcodes007/Monty-Hall-Problem-Simulation-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Monty Hall Problem Simulation in Python

This repository contains a Python simulation of the Monty Hall Problem, a famous probability puzzle that challenges intuition versus mathematics.

What is the Monty Hall Problem?

The Monty Hall Problem is a classic probability puzzle inspired by the game show Let’s Make a Deal. Here’s the scenario:

There are three doors. Behind one door is a car (the prize), and behind the other two are goats.

You pick one door (e.g., Door 1).

The host, Monty Hall, who knows what’s behind each door, opens one of the remaining doors to reveal a goat.

Monty then asks: Do you want to stick with your original choice or switch to the other unopened door?

Mathematically, switching doors gives a 2/3 chance of winning, whereas staying with the initial choice only gives a 1/3 chance. Emotion vs Math—this is where intuition often fails!

Project Motivation

I’ve always been fascinated by movies, and my interest in STEM and coding was sparked by them. The first time I encountered the Monty Hall Problem was while watching the movie 21, and I was intrigued by the underlying math. This project simulates the problem to demonstrate the probability in action.

How the Simulation Works

This simulation uses Python’s random module to mimic the Monty Hall process. By running enough trials, the probability of winning when switching converges to approximately 2/3, while staying with the initial choice yields about 1/3.

Getting Started Clone the Repository git clone https://github.com/Mithcodes007/Monty-Hall-Problem-Simulation-in-Python.git

Run the Application cd Monty-Hall-Problem-Simulation-in-Python python app.py

A simple GUI will appear. Enter the number of simulations you want to run and press Enter. The program will calculate total wins for both staying and switching strategies.

Features

Simulates the Monty Hall Problem with any number of trials.

Calculates and displays the probability of winning for staying vs switching.

Simple and interactive GUI for easy experimentation.

References

https://www.mathwarehouse.com/monty-hall-simulation-online/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages