San Francisco
October 6, 2015

Monte Carlo Simulations & Probability in Ruby

For people with passing familiarity in Ruby or modest experience in another language, who are interested in computational simulation and/or statistics

Here are two fun probability puzzles we will solve with little Ruby scripts:

  • Monty Hall problem - the solution is notoriously counterintuitive, yet it's pretty easy to prove with a quick Ruby program. Solving this empirically is a useful exercise that reminds us to distrust our intuitions and instead use computer programs to demonstrate the correct answer.

  • Birthday problem - the solution to this one is also surprising to the layman. Familiarity with this problem is useful for understanding hash tables and some areas of cryptography and number theory.

Both problems, no matter how difficult they may be to solve theoretically, are easy to solve in a few lines of code! The use of computer programs to solve problems using repeated trials against random inputs is known as the Monte Carlo method.

Please skim the Wikipedia articles linked above before class.

Be sure to complete the following Codewars challenge before class! (If your RailsSchool profile includes your Codewars username, you'll get a nifty star if you complete the challenge.)

7pm Pacific - 9pm Pacific on October 6, 2015 at Noisebridge
7 students were there


Please, sign in to see the Whiteboard

Watch Lesson