The formula to calculate the average cost of winning a game of chance

191 Views Asked by At

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

There are 2 best solutions below

5
On

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.

4
On

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} $$