The quiz and explanation is from Brilliant.com course "Exposing Misconceptions".
Summary of the problem:
Two random coins are flipped and put in a bag(without changing orientation).
One person draws a coin, it turns out to be heads.
Therefore, there could've been 3 cases:
- heads, heads
- heads, tails
- tails, heads
among these 3 cases, since the first person took out heads, in 1 case head remains while the other 2 cases tail remains. Therefore, it is more likely for the remaining coin to be tails (2/3)
The explanation seems to make sense... until it doesn't.
This basically means that one should be able to guess an outcome of a totally independent random function just by observing one of the samples.
To see if the probability of any remaining coin is really likely to be heads(66%) if one coin was tails, I ran the following code (javascript):
https://jsfiddle.net/novh5zc8/1/
function flip() {
if (Math.random() > 0.5)
return true // red
else
return false // blue
}
let correct = 0;
for (let i = 0; i < 1000; ++i) {
let x = flip(); // red or blue
let y = flip(); // red or blue
if (flip()) { // choose one at random
if (x) // if one is red, the other is apparently likely to be blue
correct += y == false ? 1 : 0;
else // if one is blue, the other is likely to be red
correct += y == true ? 1 : 0;
} else { // same as above
if (y)
correct += x == false ? 1 : 0;
else
correct += x == true ? 1 : 0;
}
}
alert(correct);
// average outcome: 500 correct guesses (50%)
To no one's surprise, the fact that one random sample being red making the other remainder likely to be blue was incorrect.
However, the logical explanation from Brilliant.com
looks very convincing.
Is their explanation correct, and is my code somehow different in architecture? Or if their explanation is incorrect, what is the logical flaw?