In this weeks installment of Matt solves a riddle with a simulation, we have the ridder express question from fivethirtyeight. In a chess match, 12 games are played and the first player to 6.5 points wins. You get 1 point for a win, 0.5 points for a draw, and 0 for a loss. It’s very possible that the best player loses a chess match with this scoring system and only twelve games. It’s more than football, baseball, or basketball, but is 12 games enough to decide? Furthermore, how many games would be required to determine the winner 90% or 99% of the time.
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.
Nate Silver (of 538 fame) tweeted an interesting problem today. Somebody on Reddit had averaged the birthdays of all the presidents and found it to be July 4th (link). Nate responded that it was wrong and said the real average is sometime in late November. I thought it was an interesting problem and figured I’d work on my python skills so I decided to see for myself and threw in a couple of alterations as well.
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.
I’m working to bone up on my python skills so I decided to spend my Sunday doing problems 1-10 from Project Euler. I’ve done them before with C or Java but this was my first time with Python. Here are the problems and my commented code for each one in case it interests anybody.
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.