Google Interview Question

A conditional probability (Bayes theorem) problem. About jars and coins.

Interview Answers

Anonymous

Feb 2, 2020

Jacob, thanks for giving a concrete question and applying Bayes' rule in an illustrative way. But you stopped short of answering the question-- what is the probability that the next flip is a heads. Using the probability of each coin, the answer can be calculated as: P(next toss is H) = P(double-headed) * P(H | double-headed) + P(fair) * P(H | fair) = 0.506 * 1 + (1-0.506) * ½ = 0.75308945 Doing 3 significant figures yields a final answer of 0.753. This is roughly halfway between the fair coin's head probability (0.5) and the double-sided (1.0).

6

Anonymous

Oct 25, 2017

I'm going to assume the question was something like, "A jar has 1000 coins, of which 999 are fair and 1 is double-headed. Pick a coin at random, and toss it 10 times. Given that you see 10 heads, what is the probability that the next toss of that coin is also a head? Give your answer to 3 significant figures." Prior P(fair)= .999 P(double-headed) = .001 Collect Data Probability if fair = .5^10 = 0.0009765625 Probability if double-headed: 1 Posterior P(fair)= 0.0009765625 * .999 = 0.00097558593 = 0.00097558593/0.00197558593 = 0.494 P(double-headed)= 1 * .001 = .001 = .001/0.00197558593 = 0.506 So, the coin is more likely (but just barely) to be double-headed.

2

Anonymous

Dec 5, 2018

Assuming the same question posted: The probability of having 11 heads in a row = = Prob of picking the unbiased coin * Prob of getting 11 heads with the unbiased coin + Prob of selecting the biased coin * Prob of getting 11 heads with the biased coin = 999/1000 * (1/2)^11 + 1/1000 * (1)^1 Consider a tree diagram for better understanding!

Anonymous

Dec 19, 2018

Assuming the same question posted, I argue that since we already know that the first 10 tosses are Heads, and since every toss is independent of the other, the answer would be: 0.5*0.999 + 1*0.001 Since if A and B are independent, we have: P(A|B) = P(A)

1

Anonymous

Feb 2, 2020

Someone earlier calculated the answer probability of having 11 heads in a row = 999/1000 * (1/2)^11 + 1/1000 * (1)^1 This is correct in the case that we have not already seen 10 heads, but we have seen 10 heads. Suppose all the coins were fair and we saw 10 heads. Then the probability of the 11th head is 1/2 and the probability the 11th is tail is 1/2. We do not start from scratch with "all 11 heads" because we know 10 already happened. But in this case, not all the coins are fair, so we also need to assess the probability of each type of coin. And intuitively, after 10 heads in a row, there should be a higher than 1/1000 chance that the coin was the double-sided coin. James' calculation assess this. My answer combined these two ideas-- the fact that it's the 11th flip and the probability of each type of coin (given that we already saw 10).