Giter Site home page Giter Site logo

box-paradox's Introduction

Bertrand's Box Paradox

A model and game

These are two Python programs that replicate Bertrand's Box Paradox.

The "paradox" can be summarized like this...

Suppose you have three boxes in front of you, each with exactly two coins inside them. One box contains two silver coins, one box contains two gold coins, and the remaining box contains one silver and one gold coin. You don't know which of the boxes is which. Now suppose that without looking you reach into one of the boxes and draw a gold coin.

So after having drawn a gold coin, what is your chance of drawing another gold coin from that same box?

Solution and explanation can be found on Wiki.

box paradox model.py

This program runs the simulation any numbers of times you select under the following rule: it will always guess the same color coin it just drew. At the end it outputs a percent accuracy. This accuracy converges on the correct answer found on the Wiki page above.

Note: Running more than a few hundred thousand simulations may take quite some time.

box paradox game.py

Here you can actually play the game yourself. You select a box and draw a coin from the box. You can then input your guess of what you think the other coin in the box will be. It reports your success (or failure), and keeps track of your accuracy.

Super secret tip: there's a way to cheat in this game and know the box that's been selected before making your guess.

Model Changelog

v0.3

  • Added intro text
  • Cleaned up and simplified code
  • Cleaned up and improved text
  • Added more specific end stats

v0.2

  • Asks user for number of simulations to run
  • Deleted some unnecessary code
  • TODO: Keep track of individual gold & silver accuracy, not just total accuracy
    • NOTE: Done in v0.3

v0.1

  • Initial build

Game Changelog

v0.2.1

  • Tightened input validation throughout

v0.2

  • Changed text and other text throughout
  • Added super basic ASCII art
  • Rejiggered quit method
  • Possibly added a special secret way to cheat

v0.1

  • Initial build

box-paradox's People

Contributors

yourfriendaaron avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

jennyhwan

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.