Giter Site home page Giter Site logo

montyhall's Introduction

Monty Hall Synopsis

This code simulates the monty hall problem. Monty Hall is a game show where contestants have the ability to win the car. Contestants can choose from three closed doors, two with goats and one with a cars. After one's choice, Monty Hall will reveal a door that you did not choose and has a goat. Now that you know where one of the goats are, Monty Hall allows you choose: Do you want to stick with your choice or do you want to change to the other door.

The problem

On our first trial, we have a 33% chance of selecting the car. After, Monty Hall reveals one of the doors, intuitively, one can say that there is a 50% chance from choosing a goat from a car. This is not the case as picking the other choice actually gives us double the chance: 66%.

Why?

We have a 1/3 chance of selecting the car on our first pick and 2/3 chance of selecting a goat.

Let's say that you have choices A, B and C and choice A has the car.
1) You choose A and Monty can choose either B or C to show you. If you switch, you lose.
2) You choose B and Monty can only show you C. If you switch, you win.
3) You choose C and Monty can only show you B. If you switch, you win.

Thus, you have a 2/3 chance of winning.

The chance increases because Monty provides you with more information. It would be 50-50 if they were equally likely to occur but now that you have more information, switching would give you 66% chance of winning.

Simulation

n = 1000000
Game Won (No Choice Change) Win Rate: 0.333289
Game Won (Choice Change) Win Rate: 0.666972

montyhall's People

Contributors

imwillx avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.