The 538 Riddler question this week isn’t especially interesting. What are the chances that somebody’s phone number has the exact same seven digits as your phone number, just in a different order? But as I was driving home thinking about it, I realized that there were several different ways to go about this and I wondered which was faster.
I recently came across an interesting math problem on youtube (why youtube keeps showing me these when I’m watching cooking shows, I’ll never understand, but I digress). What is the average distance between two random points on a circle? This can also be expanded to ask what is the average distance between two random points inside a circle? Now of course I’m not going to sit down and do lots of math to figure this out, but it is a kinda interesting problem for a monte carlo simulation. So I dusted the python off and went to work.
Many of you are familiar with the Birthday Paradox. If you want to read more about it you can find a good article here. Basically, it says that in a room of 23 people, there is a 50% chance that at least two people share a birthday. And if you increase that number to 75 people, the chances go up to 99.9%. I wanted to explore this a little more and rather than doing the math (boring!), I decided to do a Monte Carlo simulation, run it a bunch of times, and plot the results.
Last week a podcast I listen to, the 404, discussed a math problem where you roll six 20-sided die and count how often you get a situation where at least one dice matches another dice. They discussed the math a little and came to the conclusion that it happens far more than you’d think. I thought it’d make a good monte carlo programming exercise so I’ve done just that. Below, you’ll find my C code (though it’s not great) and results for 2-20 dice.
Over at One Mile At A Time, they did an analysis of the recent IHG Priceless Surprises Promotion where you could mail in 94 entrees and get back 94 plays in an online game. Most entrees only won 500 points but some won 1000, 2000, 5000, and a few won free nights or gift cards. I liked his analysis and it got me thinking about possible wins and the distribution. Instead of doing a bunch of math, it was easier to create a Monte Carlo Simulation and the results were a little surprising.