6
$\begingroup$

This is a slight adaptation of a google interview question that I found entertaining.

You are given a jar with N coins, K of them are fair. The remaining coins have heads on both sides. You choose a coin at random from the jar and flip it m times.

  1. If you get heads all m times, what is the probability that you selected a fair coin?

  2. If m is 3, and N is 100, how many fair coins would need to be in the jar, for you to be at least 50% sure you selected a fair coin?

$\endgroup$

closed as off-topic by Deusovi, AJL, Peter Taylor, xnor, f'' Nov 11 '15 at 18:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is off-topic as it appears to be a mathematics problem, as opposed to a mathematical puzzle. For more info, see "Are math-textbook-style problems on topic?" on meta." – Deusovi, AJL, Peter Taylor, xnor, f''
If this question can be reworded to fit the rules in the help center, please edit the question.

6
$\begingroup$

The probability is given by $P(fair|heads^m) = P(heads^m|fair) \cdot P(fair) / P(heads^m)$, where

$P(heads^m) = P(heads^m|fair)\cdot P(fair) + P(heads^m|nonfair)\cdot P(nonfair) = 1/2^m \cdot K/N + 1^m \cdot (N-K)/N$.

Hence,

$P_m = \frac{1/2^m \cdot K/N}{1/2^m \cdot K/N + 1^m \cdot (N-K)/N)} .$

Solving for $K$, we find that it must be 88.8.

$\endgroup$
  • $\begingroup$ There are two questions. I presume your answer is for the first one and is expressed in %? $\endgroup$ – ErikE Nov 6 '15 at 0:29
  • $\begingroup$ @ErikE, if you insert the numerical $m$ and $N$ into the formula for $P_m$ and set $P_m = 0.5$, you will have one unknown variable $K$. By solving this equation you get $K=88.8$, which answers the second question, right? $\endgroup$ – Carl Löndahl Nov 6 '15 at 9:03
  • $\begingroup$ Okay I see what you mean, but do you see the problem with an answer "88.8 coins"? $\endgroup$ – ErikE Nov 6 '15 at 16:57
  • $\begingroup$ I agree, the solution was correct, but I would have liked to see the answer 89 coins. (: $\endgroup$ – knrumsey Nov 6 '15 at 17:54
  • 1
    $\begingroup$ 88.8 isn't "less proper", it's incorrect. :) but +1 anyway. $\endgroup$ – ErikE Nov 6 '15 at 23:57
2
$\begingroup$

P(fair-coin|m-heads) = p(fair-coin & m heads)/p(m-heads) p(fair-coin & m-heads) = K/N * (0.5^m) p(m-heads) = p(m-heads & (fair-coin |unfair-coin)) = p(m-heads * fair-coin)+ p(m-heads *unfair-coin) p(m-heads * unfair-coin) = p(unfair-coin)*p(m-heads/unfair-coin) = N-K/N

so answer to the first part = K/N * (0.5^m)/(K/N*(0.5^m)) + (N-K)/N)

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.