1
$\begingroup$

This question already has an answer here:

This was a job interview question someone asked about on Reddit. (Link)

How can you generate a uniform distribution on $\{1,\dots,7\}$ using a fair die?

Presumably, you are to do this by combining repeated i.i.d draws from $\{1,\dots,6\}$ (and not some Rube-Goldberg-esque rig that involves using the die for something other than rolling it).

$\endgroup$

marked as duplicate by Micah, Community Jun 25 '15 at 20:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Hint: You can't do it in a limited number of rolls, because in $N$ rolls, you get $6^N$ different values, and that isn't divisible by $7$. $\endgroup$ – Thomas Andrews Jun 25 '15 at 20:36
  • $\begingroup$ Other related questions (abstract duplicates?) math.stackexchange.com/questions/1273214/…, math.stackexchange.com/questions/1314460/… $\endgroup$ – Micah Jun 25 '15 at 20:42
  • $\begingroup$ @Micah thanks, good finds all $\endgroup$ – shadowtalker Jun 25 '15 at 20:43
  • $\begingroup$ So you're allowed to roll the die an infinite number of times? Then if $X_1, X_2, X_3, \ldots$ are the values of the different rolls take $(X_1 - 1) / 6 + (X_2 - 1) / 6 + (X_3 - 1) / 6 + \ldots \sim$ uniform$(0, 1)$ and you can generate from any distribution whatsoever. $\endgroup$ – dsaxton Jun 25 '15 at 20:50
  • $\begingroup$ @dsaxton won't that be bell-shaped? Try it in R: x <- colMeans(replicate(500, sample(1:6, 100, replace = TRUE))); qqnorm(x). You could hack it by assuming normality and taking its inverse, u <- pnorm(x, mean(x), sd(x)), but that's... a hack. $\endgroup$ – shadowtalker Jun 25 '15 at 20:54
2
$\begingroup$

The easiest way: roll the dice twice. Now, there are 36 possible pairs. Delegate five pairs to each of 1, 2, 3, 4, 5, 6, 7 - then, if you get the remaining pair, roll the dice again. This guarantees equal probability for each of the 7 values. Note that the probability you don't have to roll again is $35/36$, so the expected value of dice you'll need to roll is pretty close to two.

$\endgroup$
2
$\begingroup$

You can't do it in a limited number of rolls, because in $N$ rolls, you get $6^N$ element in the sample space, and that isn't divisible by $7$.

So roll the die twice, use those two values to encode a number from $1$ and $36$. If the first roll is $A$ and the second $B$, you can do this by computing $6A+B-6$.

If you get $36$, roll again.

If not, reduce modulo $7$, then add $1$.

Potentially, you could be rolling forever. In reality, it is highly unlikely you'd have to roll more than 6 times to get a value.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.