# Number of rolls to get my desired result with a set probability

I want to know the number of rolls or throws of a die or a coin with an equal distribution to get to my desired result with a given probability.

In my specific case I want to roll at least one "1" and one "2" on an eight sided die. Before I get one of the numbers, I would have a probability of 2/8 to get one of my numbers, either "1" or "2". after I got one of these I would have a 1/8 chance to get my missing number. How often do I have to throw the dice to get both numbers with a probability of 90%?

Edit: I am throwing 1 die, and I want to know the number of throws needed to get "1" and "2" at least once with a chance of 90%.

• How many dice are you throwing? What does it mean to "get both numbers": that they each appear on at least one die on the current throw, or that each has appeared at least once among previous throws? – whuber Jan 30 '18 at 20:24
• Edited it. "Get both numbers" means throwing both numbers at least once. I am throwing 1 dice over and over again until i get both numbers at least once. That means i will get 1 of my numbers after y amount of throws, and then continue throwing until i get the second number, which takes x amount of throws. What is x if i want to have a 90% chance to get both numbers – laundmo Jan 31 '18 at 9:26
• Die is the singular of dice (tricky even for many with English as first language). – Nick Cox Jan 31 '18 at 10:13
• This is related to tail quantiles in the coupon collector problem. – Glen_b Feb 1 '18 at 3:08
• Answers to various generalizations of this question (all of which can be applied directly) appear at stats.stackexchange.com/questions/203160, stats.stackexchange.com/questions/136714, stats.stackexchange.com/questions/202313, and (for expectations only) stats.stackexchange.com/questions/90515). The first three give three different ways to obtain the formula $$\frac{6^y-2(7^y)+8^y}{8^y}=\Pr(Y\le y)$$ where $Y\ge 2$ is the number of throws. It requires numerical solution; e.g., $\Pr(Y\le y)=90\%$ has the solution $y=22.3$: you need $23$ throws. (cc @Glen_b) – whuber Feb 1 '18 at 14:43

## 1 Answer

I believe this will require 23 rolls with an 8 sided die.

the probability that you get both numbers is 1 - the probability that you either get 1 of the 2 or neither of the two P[both]=1-P[first only]-P[second only]-P[neither]

The probability of getting just one of them is the sum of the probabilities of all the possible numbers of times that you got that one roll. So if you roll 4 times, you get the one number 1, 2, 3, or 4 times. The probability of getting that is (1/8)^(that number) times the probability that you don't get the other (6/8)^(all other rolls, i.e. total rolls minus number of times you got the first) times the number of combinations that make that possible rolls choose number of times you get the number. For n rolls sum over a number k of times you got the first number of interest: $\sum_{k=1}^{4}(\frac{6}{8})^{4-k}(\frac{1}{8})^k{4\choose k}$

The probability of getting neither number for n rolls is just the probability of getting neither on a single roll (6/8) raised to power of the number of rolls (6/8)^n

$P[both]=1-\sum_{k=1}^{n}(\frac{6}{8})^{n-k}(\frac{1}{8})^k{n\choose k}-\sum_{k=1}^{n}(\frac{6}{8})^{n-k}(\frac{1}{8})^k{n\choose k}-(\frac{6}{8})^n$

$P[both]=1-2\sum_{k=1}^{n}(\frac{6}{8})^{n-k}(\frac{1}{8})^k{n\choose k}-(\frac{6}{8})^n$

Using Matlab with n=23, I get p = 0.9086

• The answer is correct, but the calculations are a little obscure. A little more explanation would be welcome. Have you considered applying the Geometric distribution? The distribution of the number of rolls is 2 plus the sum of a Geometric$(1/4)$ and Geometric$(1/8)$ distribution, which offers a different (and perhaps more efficient) way to compute the answer. – whuber Jan 31 '18 at 23:01
• Good feedback - added wording to describe where equations came from. I'll look into the goemetric path – MikeP Feb 1 '18 at 12:35