As the title says, I'm trying to find the formula that calculates the average cost for a game of chance.

Here are the rules of the game -

  • There is a 25% chance to win a game
  • The player wants to win exactly 3 games in one day. After that he stops playing.
  • There is a maximum of 10 games per day
  • The player pays for each game. The cost is 5 coins per game

What is the average total amount of money the player would have to spend until he reaches a day in which he has won exactly 3 games?

At first, I thought I could use the binomial distribution formula to solve the chance of getting exactly 3 wins in a day and use the result to calculate the average cost.

$$E(X) = \binom{10}{3}0.25^{3}(0.75)^{7}$$

The result is ~ 0.2502, which means meeting our goal of exactly 3 wins approximately once every 4 games. That didn't seem right. Because the binomial distribution doesn't take into account the fact that the player stops playing after 3 wins. It assumes the player always plays 10 games every day.

Since this didn't seem like the correct answer I wrote a little python program to approximate the true answer.

The program simulates 10 million iterations with the rules above (the player has a maximum of 10 games per day, or 3 wins, whichever comes first. A game cost 5 coins and there's a 25% chance to win a game).

These were the results -

  • The player will have to play an average of 18.329 games until the goal of a day with exactly 3 wins is met
  • Times that by the cost of 5 coins per game gives us an average cost of 91.64 coins

The full output of the program can be seen here.

So, is there a way to get to this answer without iterating through 10 million cases? Is there a formula to calculate this?


2 Answers 2


Let's consider a single day. The probability that the third win occurs on game $n$ is $$p_n=\binom {n-1}2\times .25^3\times .75^{n-3}$$

Thus the probability that you achieve success on a single day is $$\alpha=\sum_{n=3}^{10} p_n=.4744$$

and the expected number of games it will take you conditioned on knowing that this is a winning day is $$\sum_{n=3}^{10}n\times p_n \times \frac 1{.4744}= 7.25188$$

It follows that the answer to your question is $$7.25188+10\times \sum_{k=1}^{\infty} (k-1)\times (1-.4744)^{k-1}\times .4744=\boxed {18.3308}$$

Which I think confirms your simulation nicely.

Variant (for the last step): Letting $E$ be the desired expectation, we consider the first day. Either you succeed on that day, in which case you expect to play $7.25188$ games, or you fail and the game restarts (only now you have played $10$ games). Thus $$E=(1-\alpha)(E+10)+\alpha\times 7.25188$$

which is easily solved to yield the same result as before.

  • $\begingroup$ Thank you for your answer! I've been on this problem for days. However, I'm kind of lost following the fourth line, can you explain it a little bit more? $\endgroup$ Aug 20, 2022 at 7:14
  • $\begingroup$ @austere1993 IMOP you can check the last line is equivalent to $\sum_{n=3}^{10} np_n\frac{1}{.4744} + 10(\frac{1}{.4744}-1)$ , note that the first $\frac{1}{.4744}$ is for normalization and the second is the mean of geometric r.v $\endgroup$
    – C.C.
    Aug 20, 2022 at 8:45
  • 1
    $\begingroup$ Do you understand the logic of the computation? First we compute the probability that you will win on a given day, that's $\alpha=.4744$ Once we know that, then we know that that the probability we end on day $k$ is $(1-\alpha)^{k-1}\times \alpha$ since we need $k-1$ fails followed by a success. But if we end on day $k$ then we know we played $10\times(k-1)$ games over the fail days and we expect to have played $7.25188$ on the day we finally win. $\endgroup$
    – lulu
    Aug 20, 2022 at 9:07
  • 1
    $\begingroup$ I have added an alternative calculation which avoids the geometric sum at the last stage (note that the alternate assumes that an expectation exists but that's not such a big stretch here). $\endgroup$
    – lulu
    Aug 20, 2022 at 11:19
  • $\begingroup$ (+1) I used $\frac1p-1$ to get the expected number of days before a day with $3$ wins. Most of the proofs of that that I've seen use geometric series. $\endgroup$
    – robjohn
    Aug 21, 2022 at 17:23

The probability of getting $3$ or more wins in a day (run of $10$ games): $$ \sum_{k=3}^{10}\overbrace{\ \ \binom{10}{k}{\vphantom{\left(\frac14\right)^k}}\ \ }^{\substack{\text{ways to}\\\text{arrange}\\\text{$k$ wins}\\\text{and $10-k$}\\\text{losses}}}\overbrace{\left(\frac14\right)^k\left(\frac34\right)^{10-k}}^{\substack{\text{probability of $k$ wins}\\\text{and $10-k$ losses}}}=\frac{124363}{262144}\tag1 $$ Probability of getting $3$ wins in exactly $k$ games: $$ \overbrace{\binom{k-1}{2}\vphantom{\left(\frac14\right)^3}}^{\substack{\text{ways to arrange}\\\text{$2$ wins and}\\\text{$k-3$ losses}\\\text{and a final win}}}\overbrace{\left(\frac14\right)^3\left(\frac34\right)^{k-3}}^{\substack{\text{probability of $3$ wins}\\\text{and $k-3$ losses}}}\tag2 $$ Summing $(2)$ from $k=3$ to $k=10$, we get the same probability as $(1)$: $$ \sum_{k=3}^{10}\binom{k-1}{2}\left(\frac14\right)^3\left(\frac34\right)^{k-3}=\frac{124363}{262144}\tag3 $$ Both $(1)$ and $(3)$ say that the expected number of days to get a day with $3$ wins is $\frac{262144}{124363}$; thus, the expected number of days before we get a day with $3$ wins is $$ \frac{262144}{124363}-1=\frac{137781}{124363}\tag4 $$ Using $(2)$, we can compute the expected number of games needed to get the three wins, given that we have three wins (the conditional expectation): $$ \frac{\sum\limits_{k=3}^{10}k\binom{k-1}{2}\left(\frac14\right)^3\left(\frac34\right)^{k-3}}{\sum\limits_{k=3}^{10}\binom{k-1}{2}\left(\frac14\right)^3\left(\frac34\right)^{k-3}}=\frac{901866}{124363}\tag5 $$ Since there are $10$ games in a day without $3$ wins, using $(4)$ and $(5)$, we get the expected number of games played until getting $3$ wins in a day to be $$ 10\overbrace{\left(\frac{262144}{124363}-1\right)}^{\substack{\text{expected number of}\\\text{days $\textit{before}$ a day}\\\text{with $3$ wins}}}+\overbrace{\frac{901866}{124363}}^{\substack{\text{given $3$ wins,}\\\text{number of games}\\\text{until $3$ wins}}}=\frac{2279676}{124363}\approx18.33082186824\tag6 $$

Explanation of $\bf{(4)}$

If an independent event has probability $p$ then the probability that it will first occur on trial $k$ is $$ \overbrace{(1-p)^{k-1}}^{\substack{\text{probability the}\\\text{event does not}\\\text{occur in the}\\\text{first $k-1$ trials}}}\overbrace{\quad\ \ p\ \ \quad\vphantom{1^{k-1}}}^{\substack{\text{probability the}\\\text{event occurs on}\\\text{trial $k$}}}\tag7 $$ Summing the geometric series, $$ \begin{align} \sum_{k=1}^\infty(1-p)^{k-1}p &=\frac{p}{1-(1-p)}\tag{8a}\\ &=1\tag{8b} \end{align} $$ Thus, the probability that the event will occur on some trial is $1$.

To compute the expected trial on which the event will occur, we compute $$ \begin{align} \sum_{k=1}^\infty k(1-p)^{k-1}p &=\frac{p}{(1-(1-p))^2}\tag{9a}\\ &=\frac1p\tag{9b} \end{align} $$ Thus, the expected number of failed trials before a successful trial is $$ \frac1p-1\tag{10} $$

  • $\begingroup$ Thank you for the answer. I understand 1,2,3,4,6 completely. The one part that hasn't clicked for me yet is 5. Your answer is very similar to the way I approached the problem when I first tried to solve it, let's calculate the chance of getting a winning day - k. We then can easily calculate the number of days to get there - 1/k. And with that, it's easy enough to calculate the number of games before the winning day - 10 * (1/k - 1). So far it's the same as your answer but then the last part is adding the average number of games ON a winning day, which I still don't fully understand. $\endgroup$ Aug 24, 2022 at 12:58
  • $\begingroup$ I understand the numerator part of 5). The numerator is taking the number of games it could take to win 3..10 and multiplying it by the chance of getting 3 victories in that specific number of games, which is what you did in your answer. I understand that needs to be done. And I also understand we need to normalize it somehow... But the denominator we use to normalize it with is the part I don't understand. You divided it by the chance of getting a winning day, k. But why k? Why in the normalization process you decided to divide in k? I still haven't fully figured that part out. $\endgroup$ Aug 24, 2022 at 13:05
  • $\begingroup$ Intuitively the denominator that comes to mind is n-3+1=8. As we're trying to find the average number of games we played ON a winning day. We have 8 different 'options' (3*Chance of winning in 3, 4*Chance of winning in 4, 5*Chance of winning in 5 .. 10*Chance of winning in 10) of games, even though it's not true summing them up and dividing by 8 makes a bit more sense to me. $\endgroup$ Aug 24, 2022 at 15:59
  • $\begingroup$ This is a Conditional Expectation. The probability of winning $3$ games in exactly $k$ games is computed in $(2)$ as $p(k)=\binom{k-1}{2}\left(\frac14\right)^3\left(\frac34\right)^{k-3}$. The conditional expectation of how many games it takes to win $3$ games, given that we win $3$ within $10$ games is $$\frac{\sum\limits_{k=3}^{10}k\,p(k)}{\sum\limits_{k=3}^{10}p(k)}$$ $\endgroup$
    – robjohn
    Aug 24, 2022 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .