Urn problem with random halting Consider an urn with $r$ red and $b$ black balls in it. We start drawing balls (without replacement) from it with following rules:

*

*If the drawn ball is red, we stop the draw with probability $p$. Conversely, we continue the draw with probability $1-p$.


*If the drawn ball is black, we stop the draw.
What is the expected number of drawn balls?
For $p=0$ the question was already solved here. It doesn't seem clear to me how to incorporate the random stop into the solution of $p=0$ case.
 A: You will draw the first ball with probability $1.$
The probability that you stop after drawing the first ball is
$$ \frac{b + pr}{b + r}. $$
The probability that you draw the second ball is
$$ 1 - \frac{b + pr}{b + r} = \frac{qr}{b + r}.$$
The probability that you draw the $n$th ball,
given that you drew the $(n-1)$st ball, is
$$
1 - \frac{b + p(r + 2 - n)}{b + r + 2 - n} = \frac{q(r + 2 - n)}{b + r + 2 - n}.
$$
So if $N$ is the total number of balls drawn,
\begin{align}
\mathbb P(N\geq1) &= 1, \\
\mathbb P(N\geq2) &= \frac{qr}{b + r}, \\
\mathbb P(N\geq3) &= \frac{qr}{b + r} \cdot \frac{q(r - 1)}{b + r - 1}, \\
\mathbb P(N\geq4) &= \frac{qr}{b + r} \cdot \frac{q(r - 1)}{b + r - 1}
               \cdot \frac{q(r - 2)}{b + r - 2}, \\
\mathbb P(N\geq k) &= \frac{qr}{b + r} \cdot \frac{q(r - 1)}{b + r - 1}
               \cdots \frac{q(r + 2 - k)}{b + r + 2 - k}, \\
\mathbb P(N\geq k + 1) &= \frac{qr}{b + r} \cdot \frac{q(r - 1)}{b + r - 1}
                  \cdots \frac{q(r + 1 - k)}{b + r + 1 - k}, \\
\mathbb P(N\geq r + 1) &= \frac{qr}{b + r} \cdot \frac{q(r - 1)}{b + r - 1}
                  \cdots \frac{q}{b + 1}, \\
\mathbb P(N\geq m) &= 0 \quad\text{if}\quad m \geq r + 2.
\end{align}
The expectation of $N$ is
$$
\mathbb E(N) = \sum_{k=1}^{r+1} \mathbb P(N \geq k).
$$
We can write the probabilities a little more compactly in one of the following forms:
$$
P(N \geq k + 1)
 = \frac{r!\, (b+r-k)!\, q^k}{(r-k)!\,(b + r)!}
 = \frac{\displaystyle \binom rk q^k}{\displaystyle \binom{b + r}k}
 = \frac{r^{(k)} q^k}{(b + r)^{(k)}}
$$
where $a^{(k)} = a(a-1)(a-2)\cdot(a-k+1)$ is the falling factorial.
So for example, substituting $k = j + 1$ in the formula for $\mathbb E(N)$
above, we can write
$$
\mathbb E(N) = \sum_{j=0}^r \mathbb P(N \geq j + 1)
= \sum_{j=0}^r \frac{r!\, (b+r-j)!\, q^j}{(r-j)!\,(b + r)!},
$$
but I have not been able to simplify this or any of the other forms further.
A: We can imagine that before any draws happen, all of the $r+b$ balls are randomly lined up, and then drawn in that order. Let $X$ be the number of red balls that occur before the earliest black ball in random that order. Then for each $x\in \{0,1,\dots,r\}$,
$$
P(X = x)=\frac{r}{r+b}\cdot \frac{r-1}{r+b-1}\cdots \frac{r-x+1}{r+b-x+1}\cdot \frac{b}{r+b-x}=\frac{r!/(r-x)!\cdot b}{(r+b)!/(r+b-x-1)!}
$$
Now, let $N$ be the total number of draws. First, we find the conditional expectation of $N$ given each possible value of $X$. For this part, I will use the conditional version of $E[X]=\sum_{k=0}^\infty P(X>k)$.
$$
P[N>n\mid X=x]=
\begin{cases}(1-p)^n  & n\le x  \\ 0 & n> x \end{cases}
$$
Letting $q:=1-p$ to make things look neater,
$$
E[N\mid X=x]
=\sum_{n=0}^{x} P[N>n\mid X=x]
=\sum_{n=0}^{x} q^n=\frac{1-q^{x+1}}{1-q}
=\frac{1-q^{x+1}}{p}
$$
Finally, we conclude
$$
\begin{align}
E[N]
  &=\sum_{x=0}^{r}E[N\mid X=x]P(X=x)
\\&=\sum_{x=0}^r\frac{1-q^{x+1}}{p}\cdot \frac{r!/(r-x)!\cdot b}{(r+b)!/(r+b-x-1)!}
\\&=\boxed{\frac1p-\frac {1-p}p\sum_{x=0}^r(1-p)^x\cdot \frac{r!/(r-x)!\cdot b}{(r+b)!/(r+b-x-1)!}}
\end{align}
$$
I do not know if this can be simplified any further.
