Mathematics Puzzle: Adding Random Numbers
Posted on February 28, 2008
Filed Under Math Puzzles |
I have no intention of turning this blog into a math blog, but every now and then I run into interesting mathematical puzzles. My two favorite fields are combinatorics and probability, and this puzzle belongs to one of them:
Suppose you start adding up random numbers chosen from the interval [0,1]. How many numbers, on the average, would you have to add before their sum becomes equal to or exceeds one?
(Hint: the answer is NOT 2 … )
Comments
6 Responses to “Mathematics Puzzle: Adding Random Numbers”
Leave a Reply
Ok, here is a hint (stop reading if you want to think about it for yourself!).
A naive answer would be two numbers. The expectation value of X, a random variable uniformly distributed between [0,1], is 1/2. So doesn’t it make sense that the expectation value of X+X be 1/2+1/2 = 1, meaning we’ll need to numbers on the average?
The answer is no. The above reasoning is a sort of “backwards”-reasoning, and it omits a very important piece of information: no matter what, a SINGLE random variable X would NEVER give us 1.
When you compute the average of X+X+X+X+…+X you’re actually looking at a large number of trials, and you’re not excluding any sort of trial - even the ones in which you have a single random variable.
Try and looking at the cumulative probability distribution of X+X+X+…+X and see where that gets you.
I believe the average number of random numbers picked before their sum exceeds unity, is Euler’s number e = 2.71828…
Yep!
Care to share your solution with the readers?
{
class Program
{
static void Main(string[] args)
{
int Numbers = 0;
int one = 1;
double sume = 0.0;
int I ;
double RR;
int j;
double Eo = 0.0;
for (j = 0; j < 10; j++)
{
for (I = 0; I 1.0)
{
Numbers++;
sume = 0.0;
}
RR = new Random().NextDouble();
sume += RR;
}
Eo = Eo + 2000.0/Numbers;
Numbers = 0;
}
Console.WriteLine(Eo/10);
Console.ReadLine();
}
}
}
Hey, that’s cheating :).
I meant a mathematical argument.
Ok, final hint: prove that the expectation for the time for something to happen equals the sum of all probabilities of it not happening (in the 1st time, 2nd time, 3rd time, etc … ). In other words, prove:
E(X) = F1 + F2 + F3 + …
where Fi is the probability of the experiment failing to produce the event in i steps. Now use this to compute the expectation in this riddle. Good luck!