3

How do you simulate a 10 sided die using a 6 sided die.

I came across this question in my Probability textbook

My 2 approaches:

E[x] of 10 sided die = 5.5, E[x] of 6 sided die = 3.5

1st Method:

Roll the 6 sided twice. Now on the 3rd roll keep rolling until you get a (1,2,3,4,5) and reject/reroll a 6. Now divide the result of the 3rd roll by 2 and subtract from the sum of the 1st 2 rolls.

E[x] = 3.5 + 3.5 - (3/2) = 5.5

2nd Method:

Roll the 6 sided die. Now for the 2nd roll keep rolling until you get a (1,2, or 3) i.e. reject/reroll on (4,5, or 6).

E[x] = 3.5 + 2 = 5.5

I realize that the 1st method is probably better in terms of fewer rolls required on average

I am wondering if there is some other more optimal solution that reduces the average number of rolls required. Thanks!

  • 2
    Matching expectation is not the same as matching the distribution. We could just have the constant distribution $5.5$ That clearly matches expectation. – lulu Aug 04 '23 at 11:31
  • 2
    Slightly more elaborate: you could toss the $d6$ repeatedly and make a "decimal" in base $6$ out of the rolls. Then if your decimal is between $\frac {i-1}{10}$ and $\frac i{10}$ you call that a roll of $i$ on the $d10$. Of course, you might get exactly $\frac i{10}$ for some $i$ in which case this is undetermined, but that's probability $0$. – lulu Aug 04 '23 at 11:36
  • Make $2$ rolls of a 6-sided die, $r_{1}$ and $r_{2}$. Compute $[\frac{6 r_{1} + r_{2}-4}{3}]$ . If it is no greater than $10$, then it perfectly simulates a single $10$ die roll. The probability of this being true is $\frac{5}{6}$ – user3257842 Aug 04 '23 at 11:48
  • There was a typo in my prior comment so I deleted it. A better version of it: toss the $d6$ three times and keep track of the ordered triple of outcomes. There are $216$ equally likely ordered triples, so partition them into ten groups of $21$ with six left over. Then identify each group with one of the faces on the $d10$. That works unless you get one of the excess six, in which case just try again. the probability of a "failure" of this method is $\frac 6{216}=\frac 1{36}$ so in practice a few tries will get you a good result. – lulu Aug 04 '23 at 11:49
  • 3
    As an aside, it should be emphasized that whatever method you use here will necessarily require a potentially unbounded number of attempts to resolve. This is a result of the simple fact that $10$, your target, has a prime factor of $5$ which is not present in $6$, the type of die you are rolling. For instance, in @hdci's approach below (which is perfectly reasonable in practice) you could theoretically roll a result of 6 a thousand times in a row and still not have determined what your d10 result should have been, needing to continue throwing the d6 even more. – JMoravitz Aug 04 '23 at 12:09
  • General resource https://en.wikipedia.org/wiki/Rejection_sampling – qwr Aug 05 '23 at 02:42
  • @JMoravitz it should also be noted the chance of that is exponentially small. After some point you're more likely to find a hash collision or die of a freak accident than continue rolling 6s. – qwr Aug 05 '23 at 02:47

3 Answers3

5

Roll a die until its result is not six. Denote this result to be $r_1$. We have $1\leq r_1 \leq 5$.
Roll it 1 more time. Denote this to be $r_2$. We have $1\leq r_2 \leq 6$.

Compute $r_{3} = 2r_{1} - (r_2 \bmod 2)$ . This simulates a single roll of a $10$-sided die.

Now to compute the expected number of rolls.
First the expected rolls to get a non-$6$ value:

$E = \frac{5}{6} + \frac{1}{6}(E+1)$

Ie. we have $\frac{5}{6}$ chance of getting it the first try and $\frac{1}{6}$ chance of needing to try again. This gives $E = \frac{6}{5}$. The total number of rolls on average should be $1 + E = 2.2$ .

This is good if you need a single result. In limit as $n$ goes to infinity, $n$ rolls of a $10$- sided die may be simulated by $\log_{6}(10) * n$ rolls of a $6$-sided die.

user3257842
  • 3,617
5

We need a uniform distribution.

Suppose we only consider the outcomes: $$(1,1)\ (1,2)\ (1,3)\ (1,4)\ (1,5)\\(2,1)\ (2,2)\ (2,3)\ (2,4)\ (2,5)$$

Then there are ten outcomes and each one is equally likely to occur. There are two adjustments we must make: one, we must ignore sixes and two, it would be very tedious to roll until either a one or a two came up so we can use odd numbers on the first roll to represent a one and even rolls to represent a two.

Note that on the first roll we cannot ignore a six because we want either even or odd.

Therefore, we roll the die twice. If the first roll is odd we write down a $1$ and if the first roll is even we write down a $2$. On the second roll we count every thing except $6$. Then the first row above represents $1$ through $5$ and the second row represents $6$ through $10$.

John Douma
  • 11,426
  • 2
  • 23
  • 24
1

You must be sure that the probability of each integer between 1 and 10 is exactly 1/10. A safe way to do so : roll the die a first time :

  1. If you get 1, 2, 3, then roll the die as many times as required, until you get 1, 2, 3, 4 or 5 (ignoring any "6"). Thus, the probability of getting each integer between 1 and 5, knowing that the very first roll got 1, 2 or 3, is exactly 1/5
  2. Else roll the die as many times as required as previously, ignoring any "6", and add 5 to the result. Thus, the probability of getting each integer between 6 and 10, knowing that the very first roll got 4, 5 or 6, is exactly 1/5

Hence, the probability of each integer between 1 and 10 is exactly 1/10 (easy to find using the conditional probability formula).

hdci
  • 316