In a game of heads and tails with a fair coin - you win $\$1$ if heads; lose $\$1$ if tails - what is the probability of being $\$5$ up after $25$ tosses?

  • $\begingroup$ Isn't this a duplicate of the many binomial distribution self-study problems that have appeared?. Indeed, since the average after 25 tosses is obviously $5/25$, I believe the duplicate provides a great answer--and your answer would work just fine for the duplicate, too. $\endgroup$ – whuber Dec 7 '15 at 17:24
  • $\begingroup$ I don't see any in the link provided with the same set-up. An argument can be easily made that you don't need more than familiarity with the binomial distribution (or combinations) to work out the question. But, respectfully, I would suggest that these types of game-based questions are great to find linked to (can I say, "our") site when Google-ing. After all, it was gambling that got statistic started. OK. I rest my case. $\endgroup$ – Antoni Parellada Dec 7 '15 at 17:29
  • $\begingroup$ Incidentally, there was no petulance in the "our" comment - I still consider myself a guest / student. $\endgroup$ – Antoni Parellada Dec 7 '15 at 17:32
  • $\begingroup$ @whuber My appeal was denied :-) And I thought I had made such a compelling case... I'll never learn... I should know better... When you are ready to close or mark as duplicate the question is rhetoric. Hey, best wishes for a nice holiday... $\endgroup$ – Antoni Parellada Dec 7 '15 at 17:35
  • 1
    $\begingroup$ @whuber Kindly, I believe that the "level of entry" to comprehend the question linked in its degree of abstraction, and in the lexicon it requires makes it mathematically identically, but it excludes a larger segment of potential people interested. $\endgroup$ – Antoni Parellada Dec 7 '15 at 17:38

Antoni's answer is better than mine since it has a deeper mathematical underpinning but mine is quicker. Using R the answer comes immediately from looking at the the number of "wins" needed to be "5 up" and using the dbinom function:

> dbinom(15, 25, .5)
[1] 0.09741664

The first argument is the number of wins and the second argument the number of throws. The third argument forces it to be a fair coin although it's not really needed because that is the default value. You can check to see if this makes sense by adding all possible outcomes which should equal unity.

> sum( dbinom(0:25, 25, .5)) # the first argument to dbinom accepts and returns a vector

[1] 1
| cite | improve this answer | |
  • $\begingroup$ +1 Thanks for making it better by giving it a different (and much faster) perspective! It ties in great with the binomial plot. $\endgroup$ – Antoni Parellada Dec 7 '15 at 0:06

We want to know the probability of getting to $5$ with $25$ plays. The probability of a win is $\text p(W) = 0.5$. Each win adds $+1$ and each loss $-1$. Therefore we have a random walk: each play is independent from the prior, but because we are considering the position in the play $n-1$, and add or subtract the result of play $n$, we build up across plays in the fashion of a random walk, in a way that can be expressed as $\displaystyle \sum_{i=1}^n X_i$, where $X_i$ is a random variable that can take with equal probability the outcomes $\{1,-1\}$, in essence a Bernoulli process. In R we could express it as rw <- cumsum(replicate(25, sample(c(1,-1), 1))); rw[25]:

enter image description here

Among all the possible such random walks we want to know how many are going to land us in the number $5$.

To do so we just need to realize that we need a difference of $5$ between the losses ($L$) and wins ($W$), regardless of the order. If we label the total number of plays as $n$ (in our case $n=25$) and this difference between $W$ and $L$ as $d$ (in our case $d=5$), this relationship will take place provided $n = L + W = \frac{n - d}{2} + \frac{n + d}{2}$. So we need for $L$ to be equal to $\frac{n - d}{2}$ in number. But we can choose these $L$'s among the $n$ total plays - the combinations will be ${n}\choose{(n - d)/2}$, corresponding to all the possible ways we can arrange in time the $\frac{n-d}{2}$ losses among the $n$ zigzags in the random walk (the mathematical combinations) - logically, once these are determined the wins are just the complementary.

Since for every play we can either get $1$ or $-1$, the total number of possible random walks will be $2^n$.

Therefore the probability of getting a result of $d=5$ at the end of the $n=20$ plays is,

$\large \frac{{n}\choose{(n - d)/2}}{2^n} = \frac{{25}\choose{10}}{2^{25}}$$ =0.097 \sim 10\%$.

Instead we can just simulate the game with a Monte Carlo simulation. Plotting the results of $100,000$ simulations (code in R below):

enter image description here

We get a lot of $0$'s, and values around $0$. In fact, we get a "binomial distribution". The horizontal line at the $10\%$ mark happily coincides with our math calculations for the $\$5$ in the question.

If we calculate the proportion of $5$'s that we get in this computer simulation, we actually get $0.09763 \sim 10\%$, closing the loop - we get to the same spot analytically as now through computer simulation.

Here is the code if you want to try it out in R:

mc <- 0
for (i in 1:1e5){
rw <- cumsum(replicate(25, sample(c(1,-1), 1)))
mc[i] <- rw[25]
hist(mc,breaks = 40, prob = T, ylim=c(0,0.20), xlim=c(-20,20),
     border = F,
     col = "gray50",
     xlab = "frequency distribution",
     main = "Random Walk Heads Tails Monte Carlo")
abline(h = 0.10)
| cite | improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.