Giter VIP home page Giter VIP logo

montyhallstats's Introduction

Monty Hall Stats

Calculate the stats of the Monty Hall problem.

What is the Monty Hall problem?

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

Your intuition might say there would be no reason to switch the doors since the odds should be 1/2 of recieving the car since there would only be 2 doors left, but that assumption would be wrong as the chance is actually locked in at the begining of the game, so keeping the door would result in a 1/3 chance of recieving the car, while switching the door results in a 2/3 chance of winning the car.

Config

Parameters to change

In the begining of the main function 2 variables are present, defining the outcome of the game

Those are switchDoor and gamesToPlay

Change switchDoor to false, if you don't want to switch doors and change gamesToPlay to if you want to play it a diffrent amount of games each time.

Running

To run the program you need to have go installed, and then simply run go run . in your prefered command line inside the project directory.

Output

To save you the time of actually running this i will present the outputs of 2 runs of the program with 1000000 games played in each run below

If I chose to keep the original door

In 100000 games
Games won: 22263
Games lost: 77737
This gave you an average of 22.26% percent chance of winning if you kept the original door

If i chose to switch doors

In 100000 games
Games won: 66624
Games lost: 33376
This gave you an average of 66.62% percent chance of winning if you switched the door

montyhallstats's People

Contributors

jesperbakhandskemager avatar

Watchers

 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.