问题: 一个硬币, 出现正面的概率为p, 出现反面的概率为 1-p, p !=1/2. 如何制造一个公平的“硬币”。
解答: 利用条件概率公式 => P(first coin is head | both coins are different) = p (1-p) / (2p(1-p)) = 1 / 2.
同理可知 P(first coin is tail | both coins are different) = p (1-p) / (2p(1-p)) = 1 / 2.
所以一个公平的硬币应该是:不停的反转直到连续两次是一正一反,然后看倒数第二次的面向
reference: http://stackoverflow.com/questions/5429045/c-puzzle-make-a-fair-coin-from-a-biased-coin