an express riddle
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
A quick puzzle on The Riddler this week that enjoys a quick solution once one writes it out. The core of the puzzle is about finding the average number of draws one need to empty a population of size T if each draw is uniform over the remaining number of individuals between one and the number that remain. It is indeed easy to see that this average satisfies
since all draws but one require an extra draw. A recursion then leads by elimination to deduce that
which is the beginning of the (divergent) harmonic series. In the case T=30, the solution is (almost) equal to 4.
> sum(1/(1:30))*1e10
[1] 39949871309
A second riddle the same week reminded me of a result in Devroye’s Non-Uniform Random Variate Generation, namely to find the average number of draws from a Uniform until the sequence goes down. Actually, the real riddle operates with a finite support Uniform, but I find the solution with the continuous Uniform more elegant. And it only took a few metro stops to solve. The solution goes as follows: the probability to stop after two Uniform draws is 1/2, after n uniform draws, it is (n-1)/n!, which does sum up to 1:
and the expectation of this distribution is e-1 by a very similar argument, as can be checked by a rudimentary Monte Carlo experiment
> over(1e7) #my implementation of the puzzle
[1] 1.7185152
Filed under: Books, Kids, R Tagged: FiveThirtyEight, harmonic series, The Riddler
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.