2

Let's say we have a fair coin. We have $1 \dots n$ different Elements. We want to select one of these n elements with the coin. Each element should have the same chance to be selected. In addition, the selection must be made in such a way that it is determinant in any case.

For example: Be $n=2$. If head falls we take the first element, if tail falls we take the second element.

But is it possible for example for $n = 3$ ?

giroalg
  • 21

4 Answers4

1

You can come quite close. Use your fair coin to create a binary number between $0$ and $1$. If your number is in $[0,\frac 13)$ that's choice $A$, and so on. The problem is that, in principle, it can take you infinitely long to decide which range you are in. In base $2$ we have $$\left( \frac 13\right)_{10}=(.01010101\cdots)_2$$ so if you alternate $0,1$ for a million tosses you won't be sure which range you are in. As a practical matter, however, this method works extremely well. And it is easy to see how to generalize this for an arbitrary $n$.

lulu
  • 70,402
1

There are various clever tricks for different values of $n$. A general method is to find the smallest power $k$ with $n \le 2^k$.

Now flip the coin $k$ times. That determines a binary number $t$ at most $2^k-1$. If $t+1 \le n$ take that element. If not, roll again.

This general strategy works with $d$-sided dice in place of of fair coins.

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
  • Thank you very much, but theotrically this process can take infinitely long. Is there no way to get around this problem ? – giroalg Apr 14 '19 at 14:00
  • With probability $1$ it will stop - it can take arbitrarily long, but not infinitely long. For $n=3$ I think I once saw a finite method but can't remember where. It might have been on this site. – Ethan Bolker Apr 14 '19 at 15:54
  • @EthanBolker No perfectly fair bounded method exists with a finite coin if $n$ is not a power of two. The problem is that $n$ will never divide perfectly into $2^k$ for any $k$. – Mike Earnest Apr 16 '19 at 01:31
0

repeatedly toss the coin and write down a binary digit $a_i\in\{0,1\}$ according to the outcome (after initially writing "$0.$"). If we perfom infinitely many tosses, we produce real number with binary expansion $a:=0.a_1a_2a_3a_4,\ldots\in[0,1]$. With probability $1$, the expansion does not end in infinitely many $1$'s. Also with probability $1$, $a$ differs from each of $\frac1n$, $\frac 2n$, and so on. Hence with probability $1$, we can decide after finitely many tosses, in which interval $[\frac {i-1}n, \frac{i}n)$ the number $a$ lies. In that case, take $i$ as outcome.

0

$n=3$ case, your Cumulative Probability moves up at $\frac{1}{3}$ and $\frac{2}{3}$.
Therefore, if you can generate a uniform random number, if the uniform random number falls in between 0 and $\frac{1}{3}$, you choose the first element. and so on.

The question is "Can we generate a uniform random number?" Yes, but, it will take infinite numbers of toss. Good news is we don't need infinite accuracy.

Here is the trick.

Every time you toss the coin, you divide a range in half and move to the upper or the lower range.

You toss a coin first, to decide whether the random number will be greater than $\frac{1}{2}$ or not. range from 0 to $\frac{1}{2}$ or from $\frac{1}{2}$ to 1. let's say you get tail and choose the lower range. you can not decide either the 1st element or the 2nd element. but obviously, your range is out of the 3rd element range.

Toss again. Again decide upper or lower, now, from 0 to $\frac{1}{4}$ or from $\frac{1}{4}$ to $\frac{1}{2}$
If it falls the lower (0~0.25), now the whole range falls into the first element range (0 to $\frac{1}{3}$) you choose the 1st element.

if not you keep tossing a coin until you random number range falls into one element range.