The whole and half pill problem
November 15th, 2007The idea for this problem came to me while taking some vitamin pills. Each day I take half a pill. If I draw a whole pill from the container, I cut it in half, take one half and put the other half back in the jar, if it’s a half, I take it. Very simple… Then I asked myself what the average distribution of whole/half pills would be after i days, assuming that the probability of drawing a specific whole or half is P = 1/k where k is the number of pills (wholes and halfs) remaining (which is not rally the case for a jar - this problem can be generalized for different probability functions). So here is my reasoning.Assuming that on day i I have m(i) wholes and n(i) halves, and that m(i) + n(i) = S(i), than the probability to draw a whole is
P(m(i)) = m(i)/S(i),
and the probability to draw a half is
P(n(i)) = n(i)/S(i)
So on average, after day i I have
m(i+1) = m(i) - P(m(i)),
and
n(i+1) = n(i) + P(m(i)) - P(n(i))
because n(i) will increase if I draw a whole, and decrease if I draw a half.
So the equations are:
initial values m(0) = P, n(0) = 0
m(i+1) = m(i) - m(i)/S(i)
n(i+1) = n(i) + (m(i)-n(i))/S(i)
I simulated this in two ways in a small program, once using these set of equations and setting P = 15000, and also with a simulation of the real process using random numbers, and they both yielded the same results and graphs
The question is, how do you turn this set of recursive equations into a set of 2 non-recursive functions to represent each m(i) and n(i) as functions of i and initial conditions. Or at least, how could you determine some noticeable points, such as the point of intersection (when m(i) equals or crosses n(i)), or maximum of n(i) or the function for the sum or difference or n(i)/m(i). I have solved similar problems but the equations were somewhat simpler, and they could be reduced easily using a smart grouping of terms. I was also wondering if this could not be solved using calculus, by turning the recursive equations into functions of a continuous variable i and saying that m(i+i)-m(i) = dm (differential of m) and integrating them somehow, but the last time I integrated differential equations was in college, years ago.
From the chart, they don’t look like simple functions, although I may be wrong. The problem could be generalized for different probability functions and/or for different fractions of a pill per day.