4
$\begingroup$

Problem: Let's say you have a coin that might be (you don't know how biased, or even whether biased in the first place) biased, and you want to come up with a way to simulate an unbiased flip.

My reasoning (took me a few steps to get here but I'll spare you the struggle) is that no matter how biased the coin is, the probability of observing HT is the same as the probability of observing TH (assuming P(H) and P(T) are independent).

So we can assign for example H to HT and T to TH, and just wait for either sequence to take place.

I think that makes sense, but my intuition has been proven wrong so many times in the past that I really want to make sure my reasoning here is correct.

I'm also very interested to hear other ways to think about this and other kinds of intuition for this idea.

EDIT: Based on @Mariuslp's answer, I'd like to understand why we can't use a "sliding window", meaning why we have to toss away the first two flips if neither HT nor TH happens.

From my comment to his answer: The way I think about it, the probability of the entire sequence that happens before either HT or TH is the same for either HT or TH since P(H) and P(T) are independent, so it shouldn't matter. What's the problem with my thinking?

  • 2
    Your method works. In fact, it is generally attributed to John von Neumann...see, e.g.,[this](http://math.stackexchange.com/questions/146605/improving-von-neumanns-unfair-coin-solution) for some discussion.2017-01-24
  • 1
    It doesn't work if you toss the coin until you get either HT or TH (this is still biased since if you do it this way it really only comes down to the first throw). You need to toss the coin twice, and redo it if you get two equals. In other words, HHT should not count as HT, but rather as just a T, waiting for a H.2017-01-25
  • 0
    @Arthur, got it, thanks. Glad I checked...I can't remember a single time my intuition was 100% correct, hah.2017-01-25

1 Answers 1

2

As mentioned in the link provided by @lulu, you can't use a sliding window when looking at your pairs: if the two first tosses give TT, you have to discard both outputs, and toss the coin twice again.

Assume that you just concatenate your results like so: HTTTHHHTHHTHHTHT..., and look at the first valid pair (this is using a sliding window).

  • HT is the first valid output if and only if the first output of the series is H.
  • TH is the first valid output if and only if the first output of the series is T.

As a result, using a sliding window will not change the bias of the coin.

However, this caveat is avoided when you discard all incorrect pairs of tosses.

  • 0
    Can you explain why that is the case? Meaning why you can't use a sliding window? The way I think about it, the probability of the entire sequence that happens before either HT or TH is the same for either sequence, so it shouldn't matter. What's the problem with my thinking?2017-01-25
  • 0
    If your sequence starts with a T, then the next toss will either give an incorrect pair (TT), or a valid result (TH). If the result is valid, we stop, otherwise we continue. The next toss will either give an invalid result (TT), or a valid result (TH). And so on. You can see that the first valid result will be TH, as all letters before the first H are all T's. The same applies if the first letter is H.2017-01-25
  • 0
    sorry, I may be misunderstanding but in your answer you make it sound like if you get TT, you should throw the coin twice again and forget completely about the TT. But in your comment, I understand (my bad if this is wrong) that if you get TT you can throw again and if you get a H for a sequence of TTH, then that would be considered a valid result of TH.2017-01-25
  • 0
    Sorry, in my comment I talked about what happens when you use a sliding window. The result is that, with a sliding window, everything boils down to the probability of the first letter. Which is not what you want. Without sliding window, you toss every precedent result, so the probability of getting HT is the same as the one getting TH.2017-01-25
  • 0
    Ah....I got it, finally. Thank you for being patient.2017-01-25
  • 0
    No problem! Glad to help.2017-01-25