CodePlexProject Hosting for Open Source Software

A university project explaining a phenomenon of a coin tossing game called Penney Ante.

So what is so interesting about Penney Ante? There are eight different patterns to consider (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT). Each pattern is built of outcomes of three tosses. Each of the three outcomes is equally likely to happen and independent of the others. Hence if we throw a coin three times each pattern has the same probability of winning (1/8). At this stage it´s intuitive to think about the patterns as independent and the game to be fair. This logic would be perfectly fine if after each three throws we could follow with another three and continue in that manner until one of the players wins. However, Penney-ante is not played that way. If after first three flips there is no winner, we do a fourth toss and we examine the last three throws. If there is still no winner, we do a fifth throw, and we continue until a winning pattern is matched. Therefore patterns depend on previous flips which makes them depend on each other. Thus at least some of them when played against each other appear first with different probabilities.

Although initially the game appears to be fair, it is not in general. Results appear to be quite surprising. There is no best pattern that beats all others. The best we can do is let our opponent go first and then choose the best possible option that beats his particular pattern. To do so we need to be able to define relations between each two patterns. Thus we would like to invent a function which calculates the probability of one pattern happening before another. Moreover, we obviously want to come up with a function that can cope with any pattern length. And this is where the fun begins. As we will see it is a lot easier to solve the problem using a pencil and a piece of paper than writing a programming code.

The project not only explains how to find probabilities of some patterns to appear before others but also includes:

- computations of the average waiting time for each of the 8 considered patterns to happen.

- game simulations that test the correctness of the computations by running the game a various number of times.

- a simple frame application that lets you play the game and convince yourself that you have no chance playing against a machine while going first and how easy it is to win having a second choice.

- complete project including all the source code in .nb file.

- complete project including all the source code written as PDF file.

To run the project use PenneyAnte.nb.

Open .nb files using Mathematica. You can also open .nb files using CDF Player but in this case .nb files will not function interactively. Both Mathematica and CDF Player can be downloaded from http://www.wolfram.com/

programming language: Mathematica

Last edited Jan 19, 2013 at 1:00 PM by panryba, version 10