# Expected number of uniform draws to exceed a first uniform draw

I came across the following problem (Problem number 27 from here): Aaron samples from the Uniform(0,1) distribution. Then Brooke repeatedly samples from the same distribution until she obtains a number higher than Aaron’s. How many samples is she expected to make?

Here's my attempt: Let the number of draws Brooke makes be $$N$$. Let Aaron draw $$A$$. Then given $$A=a$$, $$N$$ is a Geometric($$1-a$$) random variable, with expectation $$1/(1-a)$$. Hence,

$$E[N] = E[E[N|A]] = E\left[\frac{1}{1-A}\right]$$

Here's where I got stuck, because I don't think for $$A\sim U(0,1)$$, $$E[(1-A)^{-1}]$$ is finite.

You can check the link for a solution provided by the person who wrote the article (their answer is $$\pi^2/6)$$, but I don't see the flaw in my logic. Is the answer really $$\infty$$?

Related, but not exactly same problem: Ms. A selects a number $X$ randomly from the uniform distribution on $[0, 1]$. Then Mr. B repeatedly, and independently, draws numbers

• Your reference goes off the rails after finding $E[N\mid A]=1/(1-A).$ (The calculations following that are so nonsensical as to seem to pertain to some other problem.) Your calculation is the correct one. It is intuitively obvious that the answer cannot be as small as $\pi^2/6.$
– whuber
Sep 12, 2020 at 18:34

You are correct, and the reference wrong, as whuber just pointed out in comments. I will show another analysis leading to the correct answer.

As probabilities can be expressed as expectations, we can use the iterated expectation theorem also for probabilities to find directly the unconditional distribution of $$N$$. That gives $$\DeclareMathOperator{\E}{\mathbb{E}} \DeclareMathOperator{\P}{\mathbb{P}} \P(N=n)=\E \P(N=n \mid A=a)=\E A^{n-1} (1-A) = \E A^{n-1}-\E A^n =\\ \int_0^1 a^{n-1}\; da -\int_0^1 a^n\; da=\frac1{n(n+1)},\quad n=1,2,\dotsc$$ Then the expectation is the sum $$\sum_{n=1}^\infty n\cdot \frac1{n(n+1)} =\infty$$

• Would you mind to double check your result of the 3rd-line expression ? I think the right-hand side of the expression should be 1/n(n+1), not 1/n(n-1). Sep 13, 2020 at 3:58
• @user295357: Thanks, will correct! Sep 13, 2020 at 17:05

$$E[N|A] = \frac{1}{1-A}$$
is correct. Actually this is a general expression for the probability that an event does not occur in the first $$(N-1)$$ tests followed by a test with the event occurs, regardless of what distribution it is, where $$A$$ represents the probability that an event does not occur in a single test while $$(1-A)$$ represents the probability that the event occur in a single test. This expression is easy to understand and remember, since it simply says that if the probability that an event occurs in a single test is 0.1, then on average it needs 10 tests to see the event occurs.
Your result for $$E[(1−A)^{−1}]$$ goes to infinity is also correct. The reason is that "Aaron samples from the Uniform(0,1) distribution". As two extreme cases, if Aaron's number is 0, obviously Brooke only needs to sample once $$(N=1)$$; However, if Aaron's number is 1 (or infinitely approaches 1), then even Brooke samples infinite times she still can not get a number greater than 1. Anyway, since the sampled number is from the Uniform(0,1), indeed, $$E[N]$$ is infinite.