You have a coin that comes out heads with probability . But you don't need it; you need to generate an event with probability . (You know .) But you don't have any other source of randomness, so you have to use your coin.
You want to devise a strategy (an algorithm) that uses the coin to decide whether your event happens or not. You toss the coin; depending on that result and the previous results, you can either toss again, declare success, or declare failure.
Your strategy should declare success with probability exactly . And since you don't want to wait until the heat death of the universe, you should at least have some guarantee that this will finish.
This is inspired from another Brilliant problem (I forgot which one, though), where . I have a solution for part 2 for , but other values of , I don't know.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Are p and q both rational?
Log in to reply
Not necessarily. In fact, my solution for p=21 works no matter whether q is rational or not.
Log in to reply
I haven't had time to think about the second part of the problem, but here's my solution to the first part:
Algorithm: Consider a number line representing the reals from 0 to 1. On that line, place a marking on point q.
Divide the line into 2 by placing a marking at p. Now throw the coin. If it lands on heads, take the left section of the line. If it lands on tails, take the right section of the line:
If the section you have taken does not contain the marking on q, terminate the algorithm. Otherwise, repeat the above steps by dividing the section you have taken into 2 smaller sections of length ratio p−1p, with the section corresponding to ratio p to the left. Thereafter, toss the coin again and follow the same rules to indicate when to terminate:
Continue this algorithm until you terminate. There is a probability q that you terminated on the left of marking q and probability 1−q that you terminated on the right of marking q.
Log in to reply
Log in to reply
The expected number of throws to terminate for probability q is E[q]=n=1∑∞n1≤i≤n∏ai for some sequence ai∈{p,1−p}. Without loss of generality, assume p≤1−p.
For the case of p<1−p, we have that
n=1∑∞npn≤E[q]=n=1∑∞n1≤i≤n∏ai≤n=1∑∞n(1−p)n
Since p,1−p<1, both sides converge and we have E[q] is finite.
For the case of p=1−p=21, we have that
E[q]=n=1∑∞2nn=2
Hence, E[q] is finite.
It's kind of amazing, how for the case of a fair coin, we can generate a probability of 0.5 with only an expected of 2 throws
Log in to reply
This is not precisely your question, but I explored a version of this question for a class years ago. Here's some of the work.
The other Brilliant problem that you proposed is here!
Log in to reply
Yup, that's the problem. Which apparently I proposed myself.