One post on Science of Board Games contains Python code for the famous Monty Hall problem:
To demonstrate how I use rejection sampling, we can use it to confirm the Monty Hall riddle. Basically, you are a contestant on a game show, and are asked to pick on of three doors, behind one of which is a new car that you win if you pick it. After picking a door, the host then reveals one of the other doors without a car in it, and offers to let you switch your choice. So, should you switch? The answer is always yes, though I won't go into details: suffice it to say that it's a non-intuitive probability calculation. If you switch, you have a 2/3 chance of winning the car, and if you stay the course, you have a 1/3 chance of winning.I wrote code for it, too, once, and if you're interested I suggest you try to modify it so that the host opens a door at random, and then see if switching still gives probability 2/3.
No comments:
Post a Comment
Markup Key:
- <b>bold</b> = bold
- <i>italic</i> = italic
- <a href="http://www.fieldofscience.com/">FoS</a> = FoS