This is an interesting problem that has long been a favorite of mine for its surprising solution.
Problem: Let be a positive real. Let
be i.i.d random variables uniformly distributed between
and
. Define the random variable
as
. In plain English,
is the minimum number of uniform random variables one needs to add for the sum to exceed
. Find the expected value of
.
The more famous version of this problem merely asks you to find the expectation of . However, a slight extension of the approach can give the answer for a general
. We shall tackle this problem using recursive expectation which is a fairly natural line of attack for these kinds of problems. Before proceeding further, let me note that it is also possible to find this expectation by actually computing the pmf of
(at least when
. I don’t know it if the pmf is easy to compute for
).
Lets start by defining to be the expected value of
. For reasons that will become obvious shortly, lets for now restrict x to lie between
and
. A recursion can be derived for
by conditioning on the value of the first random variable
.
This integral naturally splits into two as
If the value of is greater than
(as is the case in the second integral), the sum has already exceeded
which implies that
in this case. If
, we get
. This is the crucial step where recursion steps in. Substituting these back into the expression for
above, we get
which is the same as
This integral equation can be solved by converting it into a differential equation. Differentiating yields,
The solution in the familiar exponential function . It is easy to see that as
,
which implies that the constant of integration must be
. Therefore, we get that
for
. Therefore, the expected number of uniform random variables one needs to add to cross a threshold of unity is simply
!!!
Take a moment to reflect how cool this result is. Uniform random variables are everywhere around us and by simply adding them up till they cross a threshold, we can estimate one of the fundamental constants of all mathematics. This is similar to the Buffon’s needle problem which one can use to estimate by simply throwing a needle onto a ruled sheet. It comes with a caveat though: The variance of
is quite high (
) which means that, just as in the Buffon’s needle problem, this is a highly inefficient way of estimating the underlying constant.
Let us forge on and try to compute for
. A similar recursive equation can be derived by conditioning on
as
However, the difference is that when , the integral doesn’t split into two parts like it did in the case when
. Instead the only possible simplification is by replacing
by
as before and changing the variable of integration. This gives
Differentiating with respect to gives the differential equation
I don’t know if there is a easy way to solve this equation but I tackled it in the following manner. We already know the form of when
. So, when
, the above equation can be converted to a familiar linear first order differential equation by substituting
. This results in the differential equation
when
whose solution is (with the boundary condition that f(1) = e)
for
.
Armed with this, we can solve the differential equation for and so on. For example, we have
when
whose solution is
for
.
The form of the solution for a general can be easily guessed by working out the first couple of terms in the above manner. Once the form is guessed, it is easy to show that it indeed satisfies the above differential equation and that the solution is unique. Cutting to the chase, the final expression is
where
is the integer part of
.
A couple of questions that I am currently trying to figure out:
- What is the variance of
? Computer simulations suggest that it isn’t quite monotone increasing in
. Is there a deeper reason for this?
- As
, we expect
to be approximately
. Computer simulations suggest that
does indeed grow linearly. However, as
,
. Is this fact apriori obvious? In other words, is it possible to guess the above form of
for very large
without going through this derivation? Also, how can this asymptotic form be derived from the exact expression for
given above?
- What is the distribution of
. As
, clearly,
is uniformly distributed in
. When
,
is definitely not uniformly distributed in
. It seems to me that for very large
, the distribution should again be uniform in
. Is this true? How does the procession from uniform to non-uniform to uniform again take place?
- What kind of results can we expect if we replace the uniform distribution of
with some other distribution (which only takes positive values) like the exponential distribution?
- One (potentially useless) side benefit of the above asymptotic is that we can use it to derive polynomial identities involving
that are almost integers. For example,
which gives the approximation
.
- The difference is only about