# Expected number of draws until the first good element is chosen

A population has $G$ good and $B$ bad elements, $G+B=N$. Elements are drawn one by one at random without replacement. Suppose the first good element appears on draw number $X$. Find a simple formula, not involving any summation from $1$ to $N$, for $E(X)$. Hint: Write $X-1$ as sum of $B$ indicators.

Ok, so we know in the first $X-1$ draws we only get bad elements. Let $I_j$ be $1$ if $j$th draw gives bad ball and $0$ otherwise. $X-1=I_1+I_2+ \cdots +I_{x-1}$, all of which have value $1$. $E(I_1)= \cdots=E(I_n)=B/N=(N-G)/N$. Now we can write $E(X)=E((X-1)+1)$ $=E(X-1)+E(1)=E(X-1)+1.$ I'm not exactly sure on the formula for $E(X-1)$. Hopefully, I'm on the right track. Thanks!

-
@MikeSpivey +1 Of course! Serves me right for thinking through the problem too quickly! I'll remove it to avoid confusion. – Mike Wierzbicki Oct 20 '11 at 5:12

Your current attempt doesn't express $X-1$ as the sum of $B$ indicators. Instead, number the bad balls $1$ through $B$. Try $I_j = 1$ if bad ball $j$ is chosen before any of the good balls and $0$ otherwise. Then you have $X-1 = \sum_{j=1}^B I_j$. Now, can you finish off the problem by finding $E[I_j]$?

(Added, for completeness): We have $E[I_j] = \frac{1}{G+1}$, the probability that bad ball $j$ is chosen before any of the good balls. Thus $$E[X] = \frac{B}{G+1} + 1 = \frac{B + G + 1}{G+1} = \frac{N+1}{G+1}.$$

-
@caligirl11: No, $E(I_j)$ is the probability that bad ball $j$ is chosen before any of the good balls. This is not $B/N$. Instead, you have bad ball $j$ vs $G$ good balls; what's the probability that, out of those $G+1$ balls, the bad one is chosen first? – Mike Spivey Oct 20 '11 at 5:30
Ok thank you! I got it now E($I_j$)=1/(G+1). – caligirl11 Oct 20 '11 at 5:35
@caligirl11: Yep, nice job! – Mike Spivey Oct 20 '11 at 5:37

Since I was trying to solve this using summation techniques for curiosity, let me add my solution for documenting (even though it does not answer the question).

Let $P(n)$ be the probability that our first $n$ picks are bad candidates.

$$P(n) = {{(N-G)(N-G-1)(N-G-n+1)} \over {N(N-1)..(N-n+1)} }$$

We can re-arrange this equation in the following way.

$$P(n) = {{(N-G)(N-G-1)(N-G-n+1)(N-G-n)(N-G-n-1)..1(N-n)(N-n-1)..1} \over {N(N-1)..(N-n+1)(N-n)(N-n-1)..1}(N-G-n)(N-G-n-1)..1 }$$

$$P(n) = {{N-n \choose G} \over {N \choose G}}$$

TO calculate the expectation, let us define a function $F(n)$ which is the probability of failing $n-1$ times and succeeding $n^{th}$ time.

$$F(n) = P(n-1){G \over {N-n+1}}$$

$$E(x) = \sum_{i=1}^{N-G+1}iF(i)$$

Re-indexing this sum and applying the binomial identities leads to the result as expected.

-