# Binomial Distribution where number of trials is dependent on number of successes.

With a binomial distribution we can calculate the probability of winning x times in k trials. But, what if the number of trials is increased by each time you "win".

Say for example, you have 100.00 dollars, each scratch off costs 5 dollars. Each scratch off you win 20% of the time and you win 10 dollars.

What is the probability that you will get to play at least 30 times?

Well we can calculate the number of times we'd need to win in order to be able to play 30 times. We'd need 10 more tickets at 5 dollar per ticket so we'd need to therefore win 50 dollar --> we need to win 5 times.

But, i don't think the answer is as simple as calculating the binomial distribution for: 5 wins in 30 trials...

Background: This isn't homework... i'm trying to calculate the odds of winning a prize in an online game.

• It's worth mentioning that even if you can't come to an analytic result, something like this is very easy to simulate via a computer.
– Mark
Dec 17 '16 at 5:11
• I've written a quick python script here that simulates it with a result of 0.67831 for your given parameters (in $10^5$ trials).
– Mark
Dec 17 '16 at 5:36

Say for example, you have 100.00 dollars, each scratch off costs 5 dollars. Each scratch off you win 20% of the time and you win 10 dollars.

So you began with $n=20$ trials, and if you won $k$ times, you have played $n+k$ times in total; and lost $n$ times.   (I'm assuming you intended that you buy one more ticket and bank the other five dollars on each win).   We'll also assume the probability of winning, $p=0.20$, is independent for each try.

At first blush this appears a similar setup to a Binomial Distribution, but on closer examination a minor complication arises.   No win can happen after the $n$-th loss.   To rephrase that: the last win must occur before the $n+k$ try.

So, you have won $k$ times among the first $n+k-1$ trials, then lost on the last trial.   The probability of this occurring is:

$$\mathsf P(X=k) ~=~ \binom {n+k-1}k p^k(1-p)^n$$

Now calculate $\mathsf P(X\geq 10)$ when $n=20, p=0.20$ ... as $0.0492635$.

• It's also worth noting that this is the probability mass function of the Negative Binomial distribution.
– jjet
Dec 17 '16 at 18:35
• Can you elaborate on how you got 0.0492635? Do you need to evaluate that function for multiple values of X? Does X=k? I guess i'm not following how to iterate both n and k. Dec 20 '16 at 3:05
• You don't iterate $n$. It is fixed. $\mathsf P(X\geq k) = \sum_{j=k}^\infty \mathsf P(X=j)\\\qquad = 1-\sum_{j=0}^{k-1}\mathsf P(X=j)$ Dec 20 '16 at 9:00

You'd need to have at least one win in the first 20 scratch offs to be able to go beyond 20 scratch offs, and at least 2 wins in the first 22 scratch offs to be able to go beyond 22 scratch offs, and at least 3 wins in the first 24 scratch offs, and at least 4 wins in the first 26 scratch offs, and at least 5 wins in the first 28 scratch offs.

As you noticed at least 5 wins in the first 28 scratch offs isn't enough, but its probability would be $1-\sum_{k=0}^4 \binom{28}{k}0.2^k0.8^{28-k}$ which is the probability to have at least five wins among the first 28 scratch offs. Now, given that you have at least 5 wins in the first 28 scratch offs the probability to have less than 4 wins in 26 scratch offs are only if you have 3 wins in 26 scratch offs and then 2 wins. I.e. $1-\sum_{k=0}^4 \binom{28}{k}0.2^k0.8^{28-k} - \binom{26}{3}0.2^5 0.8^{23}$.

Similarly given that you have at least 5 wins in the first 28 scratch offs and at least 4 wins in the first 26 scratch offs the probability that you have less than 3 wins in 24 scratch offs are only if you have 2 wins in 24 scratch offs and then 2 wins. I.e. $1-\sum_{k=0}^4 \binom{28}{k}0.2^k0.8^{28-k} - \binom{26}{3}0.2^5 0.8^{23} - \binom{24}{2} 0.2^4 0.8^{22}$.

Going on like this the probabilty is $1-\sum_{k=0}^4 \binom{28}{k}0.2^k0.8^{28-k} - \binom{26}{3}0.2^5 0.8^{23} - \binom{24}{2} 0.2^4 0.8^{22} - \binom{22}{1} 0.2^3 0.8^{21} - 0.2^2 0.8^{20} \approx 0.674878$

• Not sure if this is consistent with Marks simulation results since he didn't give any confidence intervals, but at fist appearance it seems reasonable. Dec 17 '16 at 18:23