Earlier quoted context omitted.
It's very easy to verify experimentally that e is likely the correct answer.
Doubly confirmed. 2.71832 over 100M trials. import random totalsteps = 0 for i in range(100000000): sum = 0.0 steps = 0 while sum
How many draws of a random number [0,1] are needed to sum to 1
11–20 of 42 posts
Re: How many draws of a random number [0,1] are needed to sum to 1
#12Isn't the pdf of a uniform distribution just f(x) = 1. What he gave was an exponential distribution with rate parameter lambda. The rest of the math seems correct. But the dependence on e is not surprising as it is relevant to the initial pdf. Am I missing something?
It's very easy to verify experimentally that e is likely the correct answer.
perl -e 'my $testcount = 10_000_000; my $total = 0; foreach my $i (0 .. $testcount) { my $sum = 0; while($sum Re: How many draws of a random number [0,1] are needed to sum to 1
#13 function sumToOne() {
var acum = 0,
count = 0;
do {
count++;
acum += Math.random();
} while (acum Re: How many draws of a random number [0,1] are needed to sum to 1
#14Heh wrote about this (on my blog) a long, long ago. Was a fun numerical experiment to break the boringness of my own numerical experiments with fractals
Re: How many draws of a random number [0,1] are needed to sum to 1
#15Using simple methods from martingale theory we can show that the expected value we're looking for must be no smaller than 2 and no larger than 4, but I'm in no mood to delve into more detailed calculations.
Re: How many draws of a random number [0,1] are needed to sum to 1
#16Isn't the pdf of a uniform distribution just f(x) = 1. What he gave was an exponential distribution with rate parameter lambda. The rest of the math seems correct. But the dependence on e is not surprising as it is relevant to the initial pdf. Am I missing something?
One way to arrive at the answer correctly is to write the number of samples needed before they first sum to 1 as N and observe that the probability that P[N > k] = 1/k!. You can get this from a k-dimensional integral. A general formula for E[N] is Sum_k=0^infty P[N > k] thus E[N] = e.
Re: How many draws of a random number [0,1] are needed to sum to 1
#17Heh wrote about this (on my blog) a long, long ago. Was a fun numerical experiment to break the boringness of my own numerical experiments with fractals
I found your explanation to be much clearer than this one, as I'm still having trouble seeing why the uniform density is that of a poisson RV.
Re: How many draws of a random number [0,1] are needed to sum to 1
#18If someone could explain, that would be very helpful.
There is a much clearer derivation that does not make use of the Poisson distribution here: http://mathworld.wolfram.com/UniformSumDistribution.html (Starts at "Interestingly, ...".)
Re: How many draws of a random number [0,1] are needed to sum to 1
#19Isn't the pdf of a uniform distribution just f(x) = 1. What he gave was an exponential distribution with rate parameter lambda. The rest of the math seems correct. But the dependence on e is not surprising as it is relevant to the initial pdf. Am I missing something?
No, I was confused too. The maths doesn't make sense to me and the whole blog seems to exist just to push amazon affiliate links.
If you are actually interested in probability theory, I highly recommend this (non-affiliate-link) book:
http://www.amazon.co.uk/Probability-Computing-Randomized-Alg...
It does a good job of motivating the subject by applying the new theory in each chapter to the study of useful randomized algorithms.
Re: How many draws of a random number [0,1] are needed to sum to 1
#20The author is not solving the same problem he states in the title. I'm not even sure what problem he is solving. For one thing, the pdf of uniform distribution on a [0, 1] with regard to Lebesgue measure on R is a function that's 1 on [0, 1] and 0 elsewhere. The pdf he gave is actually a pdf of Poisson distribution with regard to counting measure. Using simple methods from martingale theory we can show that the expec…