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 Head
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.