Assume you have a source of random binary information that has a bias but no correlation between consecutive bits. John von Neumann describes an algorithm to debias the random source and output a perfectly unbiased sequence of 1s and 0s as follows:
- Extract two bits from the source
- If the two bits are the same, discard them and goto 1
- If they are different, output the first bit, discard the second one, and goto 1
A more formal description of the algorithm is: given a Bernoulli sequence $S$ where $p\neq \frac{1}{2}$, this algorithm when performed on $S$ will return a (shorter) Bernoulli sequence with $p=\frac{1}{2}$.
How would one go about proving this proposition? Thank you in advance.
Source: http://en.wikipedia.org/wiki/Randomness_extractor#Von_Neumann_extractor