Math problem: bag o' coins

I have a bag containing 99 nickels. The bag also contains one novelty nickel: both sides show heads. I make a random grab from the bag and select one coin. I then flip my coin X times. It comes up heads every time.

A) Provide the equation for Y, the probability that my coin is the novelty coin…

B) (Bonus internet points!) What does the graph of the equation look like? I would assume it asymptotically approaches 1.

C) (Super bonus internet points!) Instead of 99 nickels, my bag contains Z nickels. What does the 3D graph look like?

Not homework; just came up with a problem and am vexed that I can’t solve it.

This is a classical application of Bayes theorem:

Hypothesis H0: I grabbed a normal coin
Hypothesis H1: I grabbed the novelty coin

Bayes theorem:
P(H0|X)=P(X|H0).P(H0)/P(X)
P(H1|X)=P(X|H1).P(H1)/P(X)

Use the following (quite simple):
P(X|H0)=0.5^X
P(X|H1)=1
P(H0)=Z/(Z+1)
P(H1)=1/(Z+1)

Compute P(X) as follows:
P(X)= P(X|H0).P(H0) + P(X|H1).P(H1) = 0.5^X*Z/(Z+1) + 1/(Z+1)

And your result is:
P(H1|X)= 1/(Z+1) / (0.5^X*Z/(Z+1) + 1/(Z+1))

You can check that P(H1|X)=0.0198 for Z=99 and X=1 (quite intuitive) and also that P(H1|X)=0.66666 for Z=1 and X=1 (a classic too…)

And yes, of course the graph approaches 1. Grab your favorite software and check it out.

Here’s how I see it - I’m not sure if it agrees with Oukile’s answer:

If you drew a non-trick coin, the probability of getting X consecutive heads is (1/2)^X.
The probability of drawing a non-trick coin is 99/100.

So the probability that you drew a non-trick coin and threw X heads would be (99/100)*(1/2)^X.

Therefore, the probability that you drew the trick coin would be 1-(99/100)*(1/2)^X.

Does that check out?

No, this accounts for more scenarios than just picking the bad coin. This is effectively the probability that you drew the fake coin OR didn’t throw X heads. You have to use conditional probabilities to properly capture the semantics here, but you’re working off joint probabilities. The second expression you wrote is actually P(Coin=fair,Heads=x) rather than P(Coin=fair | Heads=x).

Of course, you could just look at the nickle.

As Jragon points out, you left off the essential step in Bayes’ method. You computed 1-P[sub]B[/sub], where B is the alternative to A, but need to compute P[sub]A[/sub] / (P[sub]A[/sub] + P[sub]B[/sub]) instead, as Oukile did.

P[sub]A[/sub] = 1/100, yielding 1 / (99*.5^x + 1) as the final answer.

Here’s Wolfram Alpha’s graph of the probability as a function of the number of tosses. By the time you’ve tossed the coin 20 times, you can be 99.99% sure that you’ve gotten the trick coin. It becomes more likely than not that you’ve got the trick coin for the first x for which 2[sup]x[/sup] exceeds 99, i.e., after the seventh toss.

ETA: And here’s the 3-D graph as a function of the number of nickels.

And this is quite intuitive. If you grab a nickel and throw seven heads in a row, then you know that something unlikely has happened, but you don’t know which something unlikely it was: Either you were lucky enough to grab the one trick coin out of a hundred, or you were lucky enough to get a long string of heads from a fair coin. Which unlikely thing was more unlikely?

Thanks guys. I’m thrilled with this answer because 1) I never took statistics so I feel vindicated for not being able to solve it, and 2) I learned something new and useful today. Now I’ve just got to wrap my head around it.

correct so far.

No, you skipped a step.

Forget about the Baye’s Theorem formula. Here’s an easier way to picture it. Suppose you have 1,000 people draw a coin and flip it 5 times then put it back in the bag for the next person, and it turns out this way…
31 people drew a normal coin and got 5 heads.
959 people drew a normal coin and didn’t get 5 heads.
10 people drew the trick coin and got 5 heads.
0 people drew the trick coin and didn’t get heads (can’t be done).
Now, if one of those 1,000 people walks up to you the next day and says “Hey! remember me? I was one of the people who got 5 heads!”… what’s the probability that she drew the trick coin?
First, ignore the 959 people who didn’t get heads, because you know she isn’t one of those. So that leaves 41 people, 31 of which had a normal coin and 10 of which had the trick coin.

The conditional probability that she had the trick coin, given the fact that you know she got 5 heads, is 10/41.

Of course, that example was talking about historical probability rather than theoretical probability. So now let’s go to the theoretical probability, where X is the number of flips.

Option #1 drew normal coin and got X consecutive heads. Probability is (99/100)*(1/2)^X.

Option #2 drew a normal coin and did not get X consecutive heads. Probability is 1-(99/100)*(1/2)^X.

Option #3 drew a trick coin and got X consecutive heads. Probability is (1/100).

Option #4 drew a trick coin and did not get X consecutive heads. Probability is 0.

Now we put this all together. Given that we got X consecutive heads, we can discard options #2 and #4. The only possibilities are 1 and 3. So we need the total of #1 and #3, which is (99/100)*(1/2)^X+1/100. That’s the denominator.

The conditional probability for Option #3 is:
(1/100)

(99/100)*(1/2)^X+1/100

What color is a nickle?

Hint: read the question carefully.

A nickle is a European woodpecker. It’s green. Wikipedia