Skip to Content
author's profile photo Morten Wittrock

The Monty Hall problem in Ruby

Hi all

I just stumbled on this small piece of Ruby code I wrote a couple of years back. It's a Monty Hall problem experiment. Specifically, it determines the relative frequency of winning the car, if the contestant chooses to switch doors.

The probability of winning when switching doors is 2/3, and the program outputs a relative frequency very close to this probability. To get progressively closer, you can increase the number of experiments.

Oh, and by the way, who says that all players want to win the car? XKCD has a different take on it.

Have a great weekend, everybody.

* Please Login or Register to Comment on or Follow discussions.


    Add a comment
    10|10000 characters needed characters exceeded