The chance of picking the biased coin is 1/1000. The chance of seeing 10 heads from a fair coin is (1/2)^10 = 1/1024. These are nearly equal, so given that you've seen 10 heads, there is a 50/50 chance of having a biased coin. So the probability the next flip shows a head is
P(H) = P(biased) * P(H|biased) + P(fair) * P(H|fair)
= 0.75
The long answer -Yo want to figure out P(biased | 10H). Using Bayes rule this is
P(biased | 10H) = P(10H | biased) * P(biased) / P(10H)
= P(10H | biased) * P(biased) / (P(10H|biased) * P(biased) + P(10H|fair) * P(fair))
= 1 * (1/1000) / (1 * 1/1000 + 1/1024 * 999/1000)
~ 0.5
and you now compute the probability of the next toss being a head as above.The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row. Or did I read this wrong?
I disagree. The coin is the coin. It didn't magically transport itself or change state after flipping it 10, 100, or a billion times.
Lets change the puzzle to the simplest state: you pull a coin from the 1000-coin jar and flip it just once. What's the probability of heads?
This is why roulette and baccarat tables in Vegas have those signs showing previous outcomes. It's meant to mess with your head. Previous history has no effect on future outcomes. A fair coin could come up heads a billion times in a row as well. The next flip will still be 0.5.
0.999*0.5 + 0.001*1 = 0.5005
The important thing is that as you observe heads from the coin, you learn something about the coin. As you observe more heads it is less likely to be a fair coin and more likely to be the coin with double heads. This doesn't change anything about the coin, but it changes something about what you know about the coin. See here for the correct answer: https://news.ycombinator.com/item?id=7000523Here is perhaps a more visceral example: On any given day, your car has a 10% chance of having blown a wheel the previous night. If it has blown a wheel, every bump will feel jarring. If it hasn't blown a wheel, any given bump will feel jarring with 10% probability. You drive over a hundred bumps, and all feel jarring. Do you think the next bump will also feel jarring?
Yes, right? Because the fact that the last hundred bumps have been jarring means you probably blew a wheel last night. Even though 'previous history has no effect on future outcomes', previous history does give you information about the state of the world.
Edit: Or a better example, for this community. You're on a slightly flakey wifi connection, which sometimes drops a packet at random. Any given packet is dropped with probability 1/100. Also, any given time you connect to the router, the modem is down with probability 1/10, and all of your packets will get dropped. You connect, and the first hundred packets you send are dropped. What is the probability the next packet will get dropped? Very high, because now you know that the modem is probably down. The history of the connection gives you information about the state of the connection. Similarly, the history of coin toss results gives you information about the state of the coin.
(Why is this different from roulette? Because there the previous history doesn't give you information.)
Huh? It's a coin. You flip it. It has no knowledge of the past and no idea about the future. It lands and it's either heads 50% of the time and tails 50% of the time. It's all about the coin and nothing about what you've observed in the last N trials.
That's the simple logic that the OP is trying to see if you understand.
Explaining the bit you quoted: if you had perfect knowledge of the wind conditions, how hard the person flipped the coin, and so on, you would know precisely which side it would land on. That fact is determined. It's just because you are missing information that there's 50% probability of heads (for an unbiased coin). The probability comes out of your imperfect knowledge, and changes depending on your knowledge: for example, if you have some reason to believe the coin is biased, then you no longer think it's going to land on heads 50% of the time. Since one of the coins is biased, getting a long string of heads is reason to think that the coin they drew and are flipping is the biased coin. This information affects the probability you assign to the coin coming up heads.
def choose_coin
rand < 0.001 ? 1 : 0.5
end
def flip_coin(coin)
rand < coin ? :heads : :tails
end
def all_10_heads?(coin)
10.times { return false if flip_coin(coin) == :tails }
true
end
next_flip = { :heads => 0, :tails => 0 }
1000000.times do
coin = choose_coin
next unless all_10_heads? coin
next_flip[flip_coin(coin)] += 1
end
puts next_flip[:heads].to_f / (next_flip[:heads] + next_flip[:tails])http://en.wikipedia.org/wiki/Probabilistic_programming_langu...
https://github.com/chris-taylor/hs-probability
The code that solves this problem is:
solve = do
coin <- choose (999/1000) fair biased
tosses <- replicateM 10 coin
condition (tosses == replicate 10 Head)
nextToss <- coin
return nextToss
where
fair = choose (1/2) Head Tail
biased = certainly HeadTry thinking about it in a more brute force way: imagine literally all possible outcomes of performing this experiment. In other words, create a list like this (each coin in the jar is numbered from 000 to 999 with 999 being the only biased coin, and coin flips are represented by 0 being heads and 1 being tails):
Picked fair coin #000, flipped 00000000000 (eleven flips)
Picked fair coin #000, flipped 00000000001
Picked fair coin #000, flipped 00000000010 ...
Picked fair coin #000, flipped 11111111111
....
Picked biased coin #999, flipped 11111111111
Now select all of the lines above where the first ten flips are heads. Of these outcomes, how many have an eleventh flip of heads and how many have an eleventh flip of tails? Unless my idea of probability is flawed, this should be the same answer that the mathematicians in this thread are providing, so something right around 75% heads. 00000 00000 0
00000 00000 1
for 999 fair coins = 1998
+ 1 for fake coin = 19991000 of which has 11. flip 0
So 1000/1999 ~ 50%
00000 00000 0
00000 00000 1
For 999 fair coins = 1998And 2^11 instances of 00000 00000 0 for the biased coin = 2048.
That's 1998 + 2048 = 4046 equally likely outcomes that begin with ten heads. Of those, only 1998 / 2 = 999 outcomes feature an eleventh tails. So the odds of getting an eleventh heads after seeing ten heads is (4046 - 999) / 4046 =~ 0.753.
That's not the reason. It's because the fake coin also has two sides and therefore also 2^11 different outcomes. It just happens they all look the same.
Otherwise I agree with your argument.
You hit the nail on the head here - a fair coin would. But if there are unfair coins, things start to change. If we know there's an unfair coin, and we see an unusual run, we should consider that it may be that coin.
Think of this: increase the flips to 1000, and you're still getting heads each time. Would you bet on the next being heads or tails?
"Given that you see 10 heads, what is the probability that the next toss of that coin is also a head?"
He didn't ask you to identify the coin. He just wants to know if the flip is going to be heads.
It makes no difference what you do to it after the pick. Hold it in your hand for a day, flip it 10 times, sit on it, whatever - the end result is that p(heads) for that particular coin has not changed. p(heads) will be either 0.5 for a real coin or 1.0 for the rigged one.
The probability then comes down to what coin you picked at the start of the trial. There's a 0.999 chance you have a real one, and 0.001 chance that you have the rigged one.
Now if you pick a random coin from the jar, and you randomly observe one of the sides of the coin 1 billion times and every time you see heads, is the probability that this is the coin with both sides heads still 0.001? No, the probability that this is the coin with double heads is very close to 100%.
Now if you pick a random coin from the jar, and you flip the coin 1 billion times, and every time it comes up heads, is the probability that this is the coin with both sides heads still 0.001? No, the probability that this is the coin with double heads is very close to 100%.
How about if you flipped it 10 times and it came up heads 10 times? Turns out the probability that it is the coin with double heads is about 51%.
Probability quantifies the degree of uncertainty YOU have about the world. This can change even when the world doesn't change, namely when you observe something about the world.
According to the methodology you are advocating, the probability would be 50%, because you are only considering the initial probability of selecting a coin from the jar. But using the methodology I suggested in another comment, you would list out every possible outcome and conclude that there is a 100% chance of getting another heads.
"The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row"
This is correct, however the history of flips gives us an information on the type of coin we have in our hands
Would be interesting to see the probabilities if we had gotten 11 heads, 15 heads or 20 heads in a row.
When we have the double heads coin, the probability of getting 10 heads is 1: P(10 heads|fake) = 1. When we have a normal coin, the probability of getting 10 heads is P(10 heads|fair) = 0.5^10.
The quantity we want to compute is
P(heads|10 heads) = P(fair|10 heads)*0.5 + P(fake|10 heads)*1
= P(fair|10 heads)*0.5 + (1-P(fair|10 heads))
= 1 - P(fair|10 heads)*0.5.
To compute P(fair|10 heads) we use Bayes' rule: P(fair|10 heads) = P(10 heads|fair) * P(fair)/P(10 heads)
Here P(10 heads) = P(10 heads|fake)*P(fake) + P(10 heads|fair)*P(fair)
= 1*0.001 + 0.5^10*0.999.
We fill in the formula we got by Bayes' rule: P(fair|10 heads) = 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999)
Then we fill in the original formula: P(heads|10 heads) = 1 - 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999) * 0.5
= 0.75308947108