Math(s) Question: Probability scenario and formula

theprestige

Penultimate Amazing
Joined
Aug 14, 2007
Messages
80,367
Location
The Antimemetics Division
My cat has asthma, treated by half a pill, daily.

  • I start on the first day with a bottle containing a number of whole pills.
  • Each day, I reach into the bottle, and pull out either a whole pill or a half pill.
  • If I pull out a half pill, I give it to my cat, and put the bottle away.
  • If I pull out a whole pill, I break it in half. I give one half to my cat, and put the other half back in the bottle.

Is there a formula that tells me what my chances are, of pulling out a half pill vs. a whole pill, each day? For example: If I knew the number of whole pills in the bottle on the first day, and I know how many days have passed, can I calculate my chances of pulling out a half pill?
 
Last edited:
Yes, but I am not the person to explain it. I can say that on the second day - if you have, say, 50 in the full bottle the first day - the odds are 1 in 50 of pulling out a half pill (actually, the half pill) on the second day. I also suspect that the odds on any given day have to take into acount the previous results. And I suspect that for at least the first 25 days the odds will favor pulling out a whole pill.
 
Yes, but I am not the person to explain it. I can say that on the second day - if you have, say, 50 in the full bottle the first day - the odds are 1 in 50 of pulling out a half pill (actually, the half pill) on the second day. I also suspect that the odds on any given day have to take into acount the previous results. And I suspect that for at least the first 25 days the odds will favor pulling out a whole pill.

Yep, I can get that far, and I can--and have--brute forced my way through the first five or six days or so. That's when I got to thinking, shouldn't there be a formula or a function for this?
 
We're assuming that your choice is random and that the feel/shape of the whole or half pills don't matter, neither do the real-world way the smaller halves might migrate (IIRC) to the bottom of the bottle.

1st day = 100 pills, chance of pulling a whole pill is 1

2nd day = 99 pills and a half, chance of pulling out a whole pill is 99/100

3rd day = There are either 99 pills, so the chance of pulling out a whole is 1 OR
there are 98 pills and 2 halves, so the chance of pulling out a whole is 98/100

4th day = There are either 98 pills and 1 half or 97 pills and three halves. So it's either 98/99 or 97/100

5th day = There are either 98 pills or 96 pills and 4 halves. So the chances are either 1 or 96/100

Yeah, I'm completely stumped. It looks like the odds are going to either be 1 or some number with the lower limit of 1/100. That number that gets smaller will have an average of about 1/2 (50 pills, 50 halves). So, if the odds are either 1 or 1/2, I'd say that the overall odds of pulling out a whole pill will be about 75% (assuming you know nothing of the conditions before the pull other than how many "units" are in the bottle).

This has made my non-mathematical head hurt very much and I shall like very much to stop thinking about this now.
 
My cat has asthma, treated by half a pill, daily.

  • I start on the first day with a bottle containing a number of whole pills.
  • Each day, I reach into the bottle, and pull out either a whole pill or a half pill.
  • If I pull out a half pill, I give it to my cat, and put the bottle away.
  • If I pull out a whole pill, I break it in half. I give one half to my cat, and put the other half back in the bottle.

Is there a formula that tells me what my chances are, of pulling out a half pill vs. a whole pill, each day? For example: If I knew the number of whole pills in the bottle on the first day, and I know how many days have passed, can I calculate my chances of pulling out a half pill?

For one thing, the probability of pulling out a half pill is probably not equal to the probability of pulling out a whole pill, even if the numbers of each were equal. If you shake the bottle, half pills will tend to settle to the bottom because they are smaller. On the other hand, the half pills all start near the top, since you toss them back into the bottle. You also might be more or less likely to draw a half given the shape and feel. So the probabilities will strongly depend on how the bottle is handled.

To make it more of a pure math problem, you could assume half and whole pills are uniformly distributed, and that the probability of pulling out either is equal. Even in that over-simplified case there may not be a simple, closed-form expression for the probabilities as a function of starting pill number and day.

You could certainly write down some approximations - for example, if there were N pills to start with and you're on day D, the probability of drawing a half pill is D/N(1 + #D/N+...), where # is some number and that's a good approximation so long as D<<N.

Each whole pill draw reduces wholes by 1 and increases halves by 1. A half draw leaves wholes unchanged and reduces halves by 1. The net effect of one of each type of draw is to reduce wholes by 1 and leave halves unchanged. Therefore I think you will tend towards having a larger and larger fraction of halves. I could write a very simple differential equation for the number of each that would be a good approximation in the continuum limit of this problem (i.e. N>>1), but it would take a few minutes that I don't have right now.
 
Here's a set of equations valid for N>>1. w(t) is the number of whole pills, h(t) is the number of halves.


[latex]$\dot w={-w \over w + h}, \dot h={w-h \over w+h}$[/latex]. The solution to this isn't particularly simple. But it does show that the chance of drawing a half pill grows linearly with time for a while, and then rises very sharply to 1 near the end of the bottle. The probability of drawing a whole is just 1-that, of course.

One useful fact is that in this approximation 2w+h=2N-n, where N is the starting number of pills, and n is the number of draws.
 
The solution has a very simple form if we assume that whole pills have twice the probability of halves of being picked when there are equal numbers of each, which makes some sense, since they're twice as big. With that assumption, the probability of picking a whole pill (rather than a half) decreases linearly from 1 to 0 as the pills are used up.

At least, that's what the numerical evidence suggests. I haven't proved it, but I wrote a program that can calculate the probability on each day, for any initial number of pills.

I don't know how to describe the solution under the assumption that whole pills and half pills have equal probability of being picked when there are equal numbers of each, but here's a graph of the probabilities, if we start with 20 pills.
 

Attachments

  • pills.png
    pills.png
    4.4 KB · Views: 4
The first day, the chance of picking a whole pill is 100%.

The last day, the chance of picking half a pill is 100%.

Anything between the first and last day is magic.
 
On average, the chance of picking a half pill is equal to the chance of picking a whole pill. Size does not matter, as by the time you've finished the jar, you will have picked the same amount of half pills as you have picked whole pills.
If you'd like it put another way, the chance of picking a whole pill will be identical to the chance of picking half a pill in the long run as anything it gains by being twice the size, it loses by being picked earlier on.

Thus if you have n pills in a jar. The chance of you getting a whole pill is simply 1-d/(2n-1) where d is the day number (starting at day 0).

Simples!

Feel free to confirm this answer with some quick checks if you want.

Edit: I'm not totally sure I've answered the question you asked. This is a mapping of what the case will be, on average, on any given day, set from before you open the jar. It does not tell you what the probability will be on a day where you have 40 full pills and 27 half pills, or what it will be from any day after that. I will work on this addition and get back to you.
 
Last edited:
Thus if you have n pills in a jar. The chance of you getting a whole pill is simply 1-d/(2n-1) where d is the day number (starting at day 0).

Simples!

Feel free to confirm this answer with some quick checks if you want.


Really? Why does your probability come out negative? Is it supposed to be negative?


ETA: And on Day 1 (the 2nd day), it looks like the chance of picking anything is zero.
 
You do division before subtraction in an equation.
Mine can be rewritten as 1-(d/(2n-1))
 
On average, the chance of picking a half pill is equal to the chance of picking a whole pill. Size does not matter, as by the time you've finished the jar, you will have picked the same amount of half pills as you have picked whole pills.
If you'd like it put another way, the chance of picking a whole pill will be identical to the chance of picking half a pill in the long run as anything it gains by being twice the size, it loses by being picked earlier on.

I agree.

Thus if you have n pills in a jar. The chance of you getting a whole pill is simply 1-d/(2n-1) where d is the day number (starting at day 0).

Simples!

I don't see how this follows. Can you explain?

Feel free to confirm this answer with some quick checks if you want.

Suppose that you aren't more likely to pick a whole pill just because it's bigger. So, for example, if there's 1 whole pill and 1 half pill, the probability of picking either is 1/2.

Say we start with 2 pills. On day 0, we necessarily pick a whole pill, because there aren't any halves. But, on day 1, there's 1 whole pill and 1 half pill. So the probability of picking a whole pill is 1/2, whereas your formula gives 2/3.
 
On average, the chance of picking a half pill is equal to the chance of picking a whole pill. Size does not matter, as by the time you've finished the jar, you will have picked the same amount of half pills as you have picked whole pills.
If you'd like it put another way, the chance of picking a whole pill will be identical to the chance of picking half a pill in the long run as anything it gains by being twice the size, it loses by being picked earlier on.

Thus if you have n pills in a jar. The chance of you getting a whole pill is simply 1-d/(2n-1) where d is the day number (starting at day 0).
Except that you're dead wrong.

I suppose you mean that n is the number of pills initially in the bottle.

It's right for day d=0. You start with n whole pills in the bottle, so obviously you draw a whole pill with probability 1.

So you start d=1 with n-1 whole pills in the bottle and 1 half pill. The probability of drawing a whole pill is therefore (n-1)/n. Your formula gives 1 - 1/(2n-1) which is obviously different.

The recurrent formulas to work this out are a bit more difficult than you think, I suspect. The probability to draw a whole pill on day 2 is (n2 - 2n + 2)/n2.
 
Except that you're dead wrong.

I suppose you mean that n is the number of pills initially in the bottle.

It's right for day d=0. You start with n whole pills in the bottle, so obviously you draw a whole pill with probability 1.

So you start d=1 with n-1 whole pills in the bottle and 1 half pill. The probability of drawing a whole pill is therefore (n-1)/n. Your formula gives 1 - 1/(2n-1) which is obviously different.

The recurrent formulas to work this out are a bit more difficult than you think, I suspect. The probability to draw a whole pill on day 2 is (n2 - 2n + 2)/n2.

Nope. The probability of drawing a whole pill is not (n-1)/n on the second day as half pills are half the size. I am about to edit in the answer for any given set up as well :)

Edit: it won't let me edit earlier posts. The full answer is this:

On any day with x pills and y half pills, the chance of picking a pill is 2x/n where n is 2x+y
If this is day 0, then for any day d, the probability of picking a pill is (2x/n)-d(2x/(n^2-n))
Feel free to write that in a nicer way :)
If your jar has 32 half pills, and 73 pills, then the chance of picking a full pill on day 11 is 79.24% marvellous!
 
Last edited:
The solution has a very simple form if we assume that whole pills have twice the probability of halves of being picked when there are equal numbers of each, which makes some sense, since they're twice as big. With that assumption, the probability of picking a whole pill (rather than a half) decreases linearly from 1 to 0 as the pills are used up.

At least, that's what the numerical evidence suggests. I haven't proved it, but I wrote a program that can calculate the probability on each day, for any initial number of pills.

This is right. I've since proved it. (It's the same as what phelix said.)
 
I agree.



I don't see how this follows. Can you explain?



Suppose that you aren't more likely to pick a whole pill just because it's bigger. So, for example, if there's 1 whole pill and 1 half pill, the probability of picking either is 1/2.

Say we start with 2 pills. On day 0, we necessarily pick a whole pill, because there aren't any halves. But, on day 1, there's 1 whole pill and 1 half pill. So the probability of picking a whole pill is 1/2, whereas your formula gives 2/3.


I think you misunderstood me. You are more likely to pick a whole pill than a half pill because it is bigger.
If we start with 2 pills. On day 0 we necessarily pick a whole pill, and are left with 1 pill and 1 half pill. My formula gives 2/3 for picking the pill, which is correct.
We are then 2/3 likely to be left with 2 half pills, or 1/3 likely to be left with 1 whole pill, meaning the next day has a 1/3 chance overall of picking the whole pill. The formula also gets this :)

I know I am not explaining myself very well, but an easy explanation is evading me, so it is tempting to just tell you guys to trust that these formulae are correct...

I know, how about this: whenever you compare a full pill and a half pill, you are twice as likely to pick the full pill. In any given situation you are likely to have twice as many half pills as full pills (because of the above). Thus, it cancels out and you end up with 50/50.
 
Nope. The probability of drawing a whole pill is not (n-1)/n on the second day as half pills are half the size.

No. The problem statement is that he picks a pill at random, which could be a whole or half pill. We should therefore assume that the probability of picking a half pill is the ratio of half pills to total pills.

You also haven't returned the formula that was asked for -- which is, given an initial number of whole pills, what are the probabilities of pulling out a whole versus a half pill on a given subsequent day?
 
I did give that formula (the day is the "d" variable in my equations). I also gave a more complicated formula which allows you to specify the initial set up.

I'm not sure we should assume the probability is the same for a half pill or a whole pill... but I will get working on an answer with that being the assumption if this is so.
 

Back
Top Bottom