# Simulate a 10 sided die with a 6 sided die [duplicate]

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!

• 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 4, 2023 at 11:31
• 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 4, 2023 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}$ Aug 4, 2023 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 4, 2023 at 11:49
• 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. Aug 4, 2023 at 12:09

## 3 Answers

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$$.

• So on the second roll, if you roll a 6, keep rolling until it is different from 6? Aug 5, 2023 at 7:24
• @HolKann That is correct. Aug 5, 2023 at 13:01

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.

• But the expectation will be (2*3) - (3.5 mod 2) = 6 - 1.5 = 4.5 whereas we need 5.5 Aug 4, 2023 at 18:14
• If you take the numbers from $1$ to $6$ mod $2$, there are three $0$s and three $1$s. The expectation of the mods is $0.5$, not $1.5$ . Aug 4, 2023 at 19:01
• I see this makes sense now. Thanks a lot! Aug 4, 2023 at 19:02

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).