Follow @ProbabilityPuz |
Q: You are about to play a game wherein you flip a biased coin. The coin falls heads with probability \(p\) and tails with \(1 - p\) where \(p \le \frac{1}{2}\). You are forced to play by selecting heads so the game is biased against you. For every toss you make, your opponent gets to toss too. The winner of this game is the one who wins the toss the most. You, however get to choose the number of rounds that get played. Can you ever hope to win?
Machine Learning: The Art and Science of Algorithms that Make Sense of Data
A: At a first look, it might appear that the odds are stacked against you as you are forced to play by choosing heads. You would think that your chances or winning decrease as you play more and more. But, surprisingly there is a way to choose the optimal number of tosses (remember, you get to choose the number of times this game is played). To see how, lets crank out some numbers. If you get to toss the coin \(n\) times, then the total number of coin tosses you and your opponent flips is \(2n\). Out of the \(2n\) tosses if \(y\) turns out heads, the probability that you would win is
$$
P(\text{y Wins}) = {2n \choose y} p^{y}(1 - p)^{2n - y}
$$
In order to win, the value of \(y\) should run from \(n + 1\) to \(2n\) and the overall probability works out to
$$
P(\text{Win}) = \sum_{y = n + 1}^{2n}{2n \choose y} p^{y}(1 - p)^{2n - y}
$$
We can work out the probability of winning by choosing various values of \(p\) and \(n\) and chart them out. Here is the R code that does it.
The code runs pretty quickly and uses the data.table package. All the processed data is contained in variables z and z1. They are plotted using the ggplot package to generate the following charts for the strategy.
The first chart shows the variation of the probability of winning by the number of games played for various probability bias values.
The next chart shows the optimal number of games to play for a given bias probability value.
Some good books to own for learning probability is listed here
Yet another fascinating area of probability are Monte Carlo methods. Here are a list of good books to own to learn Monte Carlo methods.
Comments
Post a Comment