1

A random generator produces values from the list: 0, 1, 2 (with equal probabilty for all three values).

How to get a random number, 0 or 1, with equal probability, from no more than ten uses of the generator.

  • Let your generator draw from an array/list of numbers instead. Then put 1x0, 1x1 and 2x2 in it. So you will draw numbers from `[0, 1, 2, 2]`. This gives you `0: 25%, 1: 25%, 2: 50%`. If I got you right, thats what you want, no? – Zabuzard Jul 29 '21 at 13:42
  • I can interpret that question in many ways, but you seem to get an average of (0+1+2)/3=1 so divide sum of ten numbers with 20 and round to nearest whole number giving a value of zero or one. – Surt Jul 29 '21 at 13:49
  • If you guarantee 50% of each, then the output is not random. – stark Jul 29 '21 at 13:56
  • @stark Having equal probability of 0.5 does not guarantee 50% each. Even if 50% each were the goal that would change the problem from independent sampling to conditional probabilities, which are still random. – pjs Jul 29 '21 at 14:04
  • Roll the dice. If 2, roll again. There is a small change you roll 2 10x in a row. Not sure if that is acceptable. – dehart Jul 29 '21 at 14:11
  • @pjs Original question has been changed. – stark Jul 29 '21 at 14:59
  • @stark The changes to the question don't alter that your comment is incorrect. – pjs Jul 29 '21 at 15:02

2 Answers2

4

Your goal is ultimately to roll a 2-sided die given only a 3-sided die, using a fixed number of rolls of the 3-sided die.

However, this is impossible no matter how many rolls you do, since 2 does not divide 3 (and both are prime numbers). The best you can do here is keep rejecting 2's (and the probability of getting n 2's in a row is 1/3^n, a probability that shrinks rapidly with increasing n).

More generally, it's impossible to roll a k-sided die using a p-sided die using a fixed number of rolls of the p-sided die unless "every prime number dividing k also divides p" (see Lemma 3 in "Simulating a dice with a dice" by B. Kloeckner.

See also the following questions:

Peter O.
  • 32,158
  • 14
  • 82
  • 96
-2

With the edit, in order to shrink the range, you can do a few things

  • discard rolls of 2
  • if you are certain to roll an even number of times, choose 2 to be 0 or 1 before every other roll
    (1/3) * .5 + (2/3) * .5
ti7
  • 16,375
  • 6
  • 40
  • 68