Expected number of Bernoulli trials before at least s successes and f failures

binomial distributionexpected valuenegative binomialpower seriesprobability distributions

Let a random variable $X$ be the number of independant Bernoulli trials needed to reach $s$ successes and $f$ failures when the probability of success is $p$. We therefore stop trials when we have $s$ successes and at least $f$ failures OR $f$ failures and at least $s$ successes.

I do not know if a probablity distribution modeling such $X$ is described in the probability literature, but I figured it could be written as follows
\begin{equation}
P(X=x) =
\begin{cases}
\binom{s+f}{s}p^{s}(1-p)^{f} & \text{if $x=s+f$}\\
\binom{x-1}{s-1}p^{s}(1-p)^{x-s}+\binom{x-1}{f-1}(1-p)^{f}p^{x-f} & \text{if $x>s+f$}\\
0 & \text{otherwise}
\end{cases}
\end{equation}

where the first part is therefore the probability to get exactly $s$ successes (and therefore $f$ failures) in $s+f$ trials. And the second part is a weighted sum of two negative binomials.

I would like to find the expected value of $X$, function of $s$ and $f$.

Thanks a lot for your help!

Best Answer

If you knew specific values for $s,f$ and $p$, you could set up a recursion
$$E(s,f)=1+pE(s-1,f)+(1-p)E(s,f-1)\\ E(s,0)=1+pE(s-1,0)+(1-p)E(s,0)\\ E(0,f)=1+pE(0,f)+(1-p)E(0,f-1)$$ So, for example $E(s,0)=s/p$ and $E(0,f)=f/(1-p)$, and build up from there.
For any possible path from $(s,f)$ to $(0,0)$, you might consider the last point on the grid before one of the entries is zero, because each step becomes more expensive from then on.
$$E(s,f)=\sum_{e=1}^f{s-1+f-e\choose s-1}p^{s}(1-p)^{f-e}(s+f-e+e/(1-p))+\\ \sum_{r=1}^s{s-r+f-1\choose f-1}p^{s-r}(1-p)^f(f+s-r+r/p)$$