Friday, April 13, 2007

Half Pills


Every night I've been taking a half of a pill. They come in a typical little Nature Made bottle. My brain being as it is, each and every night I wonder if I'll tap out an already split pill or if I'll have to break another one in half. So I started thinking about the odds.

Clearly the first day by odds are 0% to pull out a half pill. I break one in half and return the other half to the bottle. On day #2, there is now 1 half pill and 49 whole pills, so my odds are exactly 2% in pulling a half pill. From here the numbers get non-deterministic because it depends on if I pulled the half pill or not. If I did on day #2, my odds drop back to 0% for day #3 since there are no more halves. If I had to split another one on day #2, then on day #3 there are 2 halves and 48 whole pills giving the odds of 4%. While running some simulations might be interesting to get some typical behaviors, the question that kept popping in my head is what do the odds really look like over time?

This is easily computed in a spreadsheet because the odds on the next day depend on the day before. While this isn't applicable to any particular day (since your particular observations depend on your current count of whole and half pills), it might make a pretty picture. Looking at the math, on day #1, there are 0 half pills and 50 whole pills. Given. On day #2 there is 1 half pill and 49 whole pills. Given. On day #3 you have a 2% chance of grabbing that half pill, and if you don't you add to the number of half pills by 1 (a 98% chance). Mathematically then the theoretical number of half pills on day #3 is the number on day #2 (1), plus a 98% chance of adding 1, minus a 2% chance of removing one. Or if p2 = percentage chance of pulling a half on day 2 and h2 = number of halves on day 2, then the number of half pills on day 3 is:

h3 = h2 + (1-p2) - p2

The number of whole pills on day 3 is the number on day 2 minus a 98% chance of pulling another whole one. Using 'w' to denote whole pills we have:

w3 = w2 - (1-p2)

Since we're interested at the percentage on day 3, we compute the quotient of the number of halves divided by the total of these two values, or:

p3 = h3/(h3 + w3)

Since this is too ugly to do in HTML, I'll leave it at that instead of building the whole equation. If you plug in the numbers for day #3, in general you have a 3.92% chance of getting a half pill since there are 1.96 half pills and 48.02 whole pills in the bottle. It's not obvious maybe, but there's a check you can do on the math. Consider that there are 100 total "doses" in the original bottle. After each day, the number of doses drops by 1, whether or not you had to break a pill. Therefor at any given day, mathematically the sum of 2*hN + wN = 101-N where N is the day#. Checking then, on day #3, 2*1.96 + 48.02 = 98 doses. The 101 is there instead of 100 because of where I started counting days (day #1 sees h1=0, w1=50, d=100)

You can write the equations recursively where you replace the '3's above with a subscripted "n" and replace the '2's with a subscripted "n-1". This lends itself nicely to a long column in a spreadsheet, computing the odds from day #1 through day #100. Because of the nature, we don't end up with exactly 1 half pill on day #100 and a 100% chance of getting it. But if we round to integers and step through the values, that is exactly what you will end up with of course.

Now have a look at the graphic for today's blog. This is a chart tracking various values from Day #1 through #100 on the x-axis. Counts of the number of half pills (red line, left y-axis) and the number of whole pills (green line, left y-axis) flow smoothly and as you might expect. The number of whole pills steadily decrease over time, flattening out a bit as the number of halves and wholes get closer past day #50 or so. The number of half pills increases quickly at first, then slows as they become numerous before the odds catch up and they also decrease at an ever increasing rate. The odds of pulling out a half pill (blue line, right y-axis) starts very low but increases continuously. Again, it should be 100% for all real-world cases on day #100, but here it ends at about 87%.

There are some assumptions in this graph:
  • The bottle is perfectly well mixed (half pills don't settle at the bottom)
  • You tap out only a single pill each time
  • If you do pull out multiples you randomly pick (which is impossible, so see previous)
  • You take the pill that you tapped out instead of looking for a half because you're too tired and lazy to break one that night
But I think to illustrate the point, these assumptions are all OK. I'm not trying to simulate human behavior here, but just figure out what my probable odds are of pulling out a half pill. I've verified for myself that after day #45 I'm more likely to pull a half pill while before then I should be prepared to always have to break one.

No comments: