Sunday, February 28, 2021

Penney's Game

 Just finished the book Humble Pi. Interesting read, especially if you are interested in math trivia and read about how little math mistakes can cause serious disasters.

In the chapter about probability, it mentioned the Penney's Game and how people's misconception about independent event makes the game interesting.

I ended up writing a program that simulate coin flipping to verify the claims. The result checked out but I did make a mistake when first implementing the logic.

When looping the coin flipping result, I used counter to keep track of the number of matches for each player. When a mismatch happens, I incorrectly reset the counter to zero. Instead, I should have checked if the last one / two coin flipping results match player's pattern.