import random
n = 100000 # number of times to run the estimation
woncar = 0
for i in range(n):
doors = [1,2,3]
car = random.randint(1,3)
choice = random.randint(1,3)
doors.remove(car) # remove for now to choose which one reveal
if(choice in doors):
doors.remove(choice) # dont reveal the choice
reveal = random.sample(doors,1)[0]
'''
Here is where you find the proof...
In the following we check if our other option which is != choice is the same as car.
Since the other non car options has been removed we only need to check if choice!=car
You can notice that we dont need lines 12-15
This is too obvious that the chance is 66% not 50%.
'''
if(choice != car):
woncar += 1
print("Chance that you win a car if you switch:", woncar/(i+1))
monty-hall-proof's Introduction
monty-hall-proof's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.