
At some point, near the end of the bag, I wondered what the probability was, if I pulled out two candies at random, that they'd have the same flavor. I looked at the candies that were in there, and it was a simple matter to figure the answer out. It was—ahh, but then I'd be giving the puzzle away.
I then turned to look away and puckishly reached into the bag and pulled out a pair of green apples. (Those are my second favorite, after the artificial grape ones, which, as you'll know if you eat them, taste nothing at all like actual grapes.) I wondered if that affected the probability at all—figuring that if anything, it would have reduced the odds—but after looking in and doing some quick figuring, I found that the odds were exactly the same as before.
"Hunh!" I thought to myself in surprise, and (if you know me at all, you know what happened next) I wondered what the odds were of that. As it so happens, that's not a question you can answer rigorously at all, without knowing the priors. But perhaps you can rigorously answer
Q1: What were the odds of drawing a matching pair of candies?
I reached in again, and this time pulled out a cherry and a grape; I did it again, and pulled out a matching pair of grapes. So this time, I thought, for sure there must be a change in the odds of drawing a match, but when I looked in again, the odds were once more exactly the same as the first time. What's more, I reached in again, pulled out a pair of green apples, looked in one last time, and the odds were again exactly the same as before!
Q2: Knowing there were no blue raspberry candies at all, how many of each of the other flavors were there, before I pulled out the first pair of green apples?
My answers to Q1 and Q2 don't fit in this window, so I'll post them one at a time.
ReplyDeleteI'd rather add than subtract, so I'll start at the end and work backward. I'll suppose that after drawing the second pair of green apples, you were left with A green apples, B grapes, C cherries, and D oranges.
Let N = A + B + C + D.
Let p be the chance of drawing a matching pair at this point. Since this was the same probability of a matching pair at the very start of the exercise, when you had at least three different flavors in the bag (at least four green apples, three grapes, and a cherry), we know p < 1.
This rules out the case where A = N. Therefore A < N.
But since you actually did draw matching pairs, we know that p > 0.
This implies that N > 1.
Then the probability that the next two candies drawn will match is
p = (A(A - 1) + B(B - 1) +
C(C - 1) + D(D - 1))/(N(N - 1)). [1]
Just before you drew the last two green apples, you had the same probability of drawing a matching pair,
p = ((A + 2)(A + 1) + B(B - 1) +
C(C - 1) + D(D - 1))/((N + 2)(N + 1)). [2]
Let
q = A(A - 1) + B(B - 1) + C(C - 1) + D(D - 1)
and
r = N(N - 1).
Then [1] implies that p = q/r. But also
(A + 2)(A + 1) + B(B - 1) +
C(C - 1) + D(D - 1) = q + 4A + 2
and
(N + 2)(N + 1) = r + 4N + 2.
Therefore [2] implies that
p = (q + 4A + 2)/(r + 4N + 2),
and so
q/r = (q + 4A + 2)/(r + 4N + 2). [3]
Cross-multiply the terms of [3]:
q(r + 4N + 2) = (q + 4A + 2)r. [4]
Cancel the qr term on each side of [4] and divide by 2:
q(2N + 1) = (2A + 1)r. [5]
That is,
q(2N + 1) = (2A + 1)N(N - 1)
= (2AN + N - 2A - 1)N
= ((2N + 1)(A - 1) + 3(N - A))N
and
(q - (A - 1)N)(2N + 1) = 3(N - A)N. [6]
But 2N + 1 and N have no common prime factors. It follows from [6] that all the prime factors of 2N + 1 (including repetitions) are factors of 3(N - A), so
3(N - A) = m(2N + 1) [7]
for some integer m. Since A < N, it follows that m > 0.
Moreover, [7] implies
3N - 2mN = 3A + m > 0,
so
3N > 2mN,
so
3 > 2m > 0.
Therefore m = 1, so
3(N - A) = 2N + 1 [8]
and
N = 3A + 1. [9]
But from [5] we can also derive
p = q/r = (2A + 1)/(2N + 1) [10]
and using [9] to substitute for N in [10], we get
p = (2A + 1)/(2(3A + 1) + 1)
= (2A + 1)/(6A + 3)
= 1/3,
which is the answer to question Q1.
I have a possible answer for the second part, but no proof that it is unique.
ReplyDeleteI observed that [9] greatly reduces the number of possible cases to be examined for any particular N (in fact it rules out many values of N immediately). I observed that [6] and [8] imply that
q − (A − 1)N = N,
so
q = AN. [12]
q = A(A − 1) + B(B − 1) + C(C − 1) + D(D − 1)
= A² − A + B² − B + C² − C + D² − D
= A² + B² + C² + D² − N.
So
A² + B² + C² + D² − N = AN,
and so
B² + C² + D²
= AN − A² + N
= A(3A + 1) − A² + 3A + 1
= 2A² + 4A + 1. [13]
But meanwhile,
A + B + C + D = N = 3A + 1,
so
B + C + D = 2A + 1, [14]
with the constraint that none of B, C, or D can be negative.
This even further limits the number of possibilities. For example, if A = 1,
then B + C + D = 3 and B² + C² + D² = 7.
But this has no solution, so A cannot be 1.
If A = 2, then B + C + D = 5
and B² + C² + D² = 17.
This has solutions where B, C, and D are any permutation of 0, 1, and 4, but no other solutions.
I then applied a spreadsheet and brute force. For each value of A, I examined each ordered set of three integers whose sum was 2A + 1, and subtracted 2A² + 4A + 1 from the sum of the their squares. If the result was zero, [13] was satisfied.
I also observed that if A were the number of green apples after drawing the first pair of green apples, then A, B, C, and D would have to satisfy [13] and [14] for the same reasons they have to satisfy [13] and [14] when A is the number of green apples after drawing the second pair. So I was looking for two values of A, one greater than the other by 2, each of which allowed solutions for [13] and [14].
For example, the spreadsheet found a solution for [13] and [14] when A = 2, but it showed there is no solution for [13] and [14] when A = 4, so this could not be the solution to the puzzle.
The least pair of values that worked were 6 and 8. If A = 6, the spreadsheet showed (by exhaustive search) that B, C, and D must be a permutation of 0, 4, and 9; and indeed, when I tried all six permutations, I found that for B=9, C=0, D=4, the probability of drawing a matching pair from a bag of A+4, B+3, C+1, and D candies (i.e., before drawing the first pair) was 1/3, and the probability of drawing a matching pair from a bag of A+2, B+3, C+1, and D candies also was 1/3.
It is therefore possible that you started with 10 green apples, 12 grapes, 1 cherry, and 4 oranges, a total of 27 candies.
You could not have started with fewer candies. But I have not yet determined that you could not have started with more candies.
Somehow I got the impression initially that there was supposed to be a simpler (and more complete) solution than I found. I wonder what I missed.
ReplyDelete