Simulate probability p

Using only a fair coin, how do you simulate an event of probability p(0,1)p \in (0,1)?

Show hints (2)+
  1. Coin flips generate the bits of a uniform number.
  2. Compare those bits to pp's binary digits.

Answer

Reveal answer →

Compare coin-flip bits to the binary expansion of p

Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.

Asked at: Jane Street, SIG

Related questions