128 points · by weinzierl · 7y ago · 33 comments
The Wikipedia section on the history of the term[1] is quite amusing. Basically, the guy who invented the idea picked the name that was most likely to get his research grant applications approved.
[1]: https://en.wikipedia.org/wiki/Dynamic_programming#History
c_{n,m}=n/(n+m) c_{n-1,m+1} + m/(n+m) c_{n,m-1}
Boundary condition: c_{0,m} = m
After some experimenting I got the following closed form solution: c_{n,m}=H_n+m/(n+1) where H_n=sum_{i=1}^n 1/i (nth harmonic number). This can be shown by induction. We want to know what happens if we start from n whole pills and 0 half pills: c_{n,0} = H_n. Indeed, they are the harmonic numbers.
If you have a half pill and k - 1 whole pills remaining, then because we stop once all the whole pills are broken, then thinking about the order in which the pills will get picked next/again, by symmetry the probability that the half pill will remain at the end (i.e. be the last one to get picked next/again) is 1 / k.
If p_k is the k'th last pill broken (so p_n is the first pill), then because at the point p_k is broken there are k - 1 whole pills remaining we get
E[N] = sum_k (probability p_k has half a pill remaining at the end) = sum_k (1 / k)
Standupmaths on YouTube recently produced a video called the "frog problem", which also reduces to the harmonic numbers. I believe it's for kind of the same reasons, though it's harder to see quite why.
I think the similarity is that you start with a pool that you deplete with a random action.
I was startled by the formula, though. It's the same as the Gilbert-Shannon-Reeds model for card shuffling, where the probability of a card falling from each packet scales to the number of cards left in each packet. (I wrote the "seven shuffles" paper with Persi Diaconis.)
https://oeis.org/search?q=0%2C1%2C3%2C11&language=english&go...
https://oeis.org/wiki/Rational_sequences
OEIS tells us that E(n) is the harmonic numbers.
Wrong. Plenty of memoized functions aren't "dynamic programming" and it's not always obvious whether or how a given problem can be decomposed as recursive sub-problems. Not "ho hum" at all.
God knows quite a number of us split pills.
The slowest car will with probability 1 be the first car in its own clump. The second slowest car will be the first car in a clump if it is in front of the slowest car. This happens with a probability of 1/2. The third slowest car will form a clump without the second and first slowest cars if it is in front of both of them, which will happen with probability 1/3. The fastest car will only form its own clump if it's the first car, which will happen with probability 1/n.
So the total number of clumps will be 1 + 1/2 + 1/3 + ... + 1/n
https://groups.google.com/forum/?hl=en#!searchin/alt.math.re...
But if you hang around you'll probably start to hear about the gradual disintegration of my body as I begin my slide into old age and eventually death. So you have that to look forward to at least!
MJD, this would be better written E_N(H) where H is an RV giving the number of half pills, right?