Code Monkey home page Code Monkey logo

doors's Introduction

Doors

Doors is intended to be a super simple test of the Monty Hall Problem, specifially to Marilyn vos Savant's suggested solution of switching'every time. Please note, this is by no means commentary. The intent is purely for fun of testing.

Dependencies

Go

Build

$ go get -v ./...
$ go build

Usage

$ ./doors -g 3000 -i 10

# sample output
total wins:     20017
avg wins:       2001
avg percentage: 0.667

When run, a defined number of games are generated, each with 3 doors. Of the 3 doors, 2 have a goat and 1 has a car behind them. In the original spirit of the problem, a contestant picks a door. In this case, we rely on a (psuedo-)randomly generated number between 0 and 2. The host then opens a door, of the 2 not selected, showing a goat. For this… we loop through the doors ignoring the the one previusly selected, looking for the first one with a goat. Per the suggested solution, we should then select the remaining door. This is achieved by looping through the doors and selecting the door that was neither selected nor the "opened door". If this final door is a "car" door, then we have a win.

For the outputs:

  • total wins is the aggregate sum of game wins for all iterations.
  • avg wins is the average of the aggregate wins… i.e. total wins / iterations
  • avg percentage is the average percent of game wins (in decimals)… i.e. avg wins / games

It's worth noting, there may be no reason to include iterations. The intent here was to try and run more games of the same count to see variations in the results.

doors's People

Contributors

elliottpolk avatar

Watchers

James Cloos avatar  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.