The core idea clicked pretty fast for me: just treat the bits as a binary fraction, so bit 1 is worth 1/2, bit 2 is 1/4, and so on.
Start by proposing the binary expansion method: generate k bits, interpret them as a binary fraction to get a number in [0,1), and explain that the error is bounded by 2^{-k}. Then analyze the time complexity as O(k) rand_bit() calls, and discuss the trade-off between precision and efficiency.
Pro tip: Mention that you can achieve exact uniformity by using rejection sampling: generate bits until you get a 1, then output the binary fraction formed by the preceding bits. This yields a uniform distribution on [0,1) with expected 2 rand_bit() calls, but the worst-case number of calls is unbounded.
Generate k independent bits using rand_bit(), concatenate them into a binary fraction (e.g., 0.b1b2...bk), and output the resulting decimal value in [0,1).
The output is a multiple of 2^{-k}, so the maximum absolute error from a true uniform continuous distribution is at most 2^{-k}. As k increases, the distribution becomes closer to uniform.
The algorithm uses exactly k calls to rand_bit(), so time complexity is O(k). The precision improves exponentially with k, meaning to achieve error ε, you need k = O(log(1/ε)) bits.
Mention that fixed k gives a discrete approximation, while rejection sampling can yield exact uniformity but with variable runtime. Compare the trade-offs between simplicity, precision, and efficiency.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.