# Expected Value Problem with a 10 Sided Die

I have a $$10$$ sided die numbered $$1-10$$. I keep rolling it until it lands on a prime number. Let $$X$$ be the number of times I roll the die.

What is the expected value $$E(X)$$?

What I have so far is the probability of rolling a prime is $$P(\text{prime}) = \frac{4}{10}$$.

How do I calculate the expected value? I tried the formula: $$\sum_{s\in S} P(s) \cdot X(s) = P(1)X(1) + P(2)X(2) +P(3)X(3)+P(4)X(4)$$

Where $$P(s)$$ is the probability of rolling a prime and $$X(s)$$ is the number of rolls. I plug in $$\frac{4}{10}$$ for each $$P$$ and $$X$$ is incremented from $$1$$. I am getting $$4$$ and the answer is $$\frac{10}4$$. Can someone guide me to what is going wrong here?

• Hint: It would be an infinite sum Nov 4, 2020 at 7:54
• I don't follow. Why would it be infinite? I can roll the dice as many times as I want, but stop when I hit a prime.
– user750949
Nov 4, 2020 at 7:57
• You might not get a prime in the first 30 throws, 40 throws etc Nov 4, 2020 at 7:57

Hint

$$E(X) = \frac{4}{10} + 2 \cdot \frac{6}{10} \cdot \frac{4}{10} + 3 \cdot \left(\frac{6}{10}\right)^2 \cdot \frac{4}{10} +.... + (n+1) \cdot \left(\frac{6}{10}\right)^n \cdot \frac{4}{10} + ... \infty$$

$$E(X) = \sum_{x=1}^{\infty} xP(x)$$

The probability that you only have one dice roll (x=1) is equal to the probability that you roll a prime on the first roll. That's $$\frac{4}{10}$$

The probability that you have two dice rolls (x=2) is equal to the probability that you first roll a non-prime and then roll a prime. That's $$\frac{6}{10} \times \frac{4}{10}$$

The probability that you have $$n$$ dice rolls is equal to the probability that you first roll a non-prime for the first $$n-1$$ times and then roll a prime. That's $$(\frac{6}{10})^{n-1} \times \frac{4}{10}$$.

So using that in the formula for $$E(X)$$ gives:

$$E(X) = \sum_{x=1}^{\infty} x(\frac{6}{10})^{x-1} \times \frac{4}{10}$$

With all the help above I found the solution.

The probability of a success (getting a prime number from the die) is $$P(success) = \frac{4}{10}$$. Each trial is independent and we have no set number of trails to get a success, leading to the conclusion that this is a geometric distribution. Therefore, the solution we get is:

$$E(X) = \frac{1}{P(success)} = \frac{1}{\frac{4}{10}} = \frac{10}{4}$$.

The key thing you are doing wrong is that you need $$P(s)$$ to be the probability of rolling a prime on turn $$s$$ and not before. So $$P(1)=\frac{4}{10}$$, $$P(2)=\frac{6}{10}\times\frac{4}{10}$$, etc. It appears you just calculated $$P(s)$$ as the probability of getting a prime on turn $$s$$.

You also need to add up all the terms, not just the first four (you are not guaranteed to get a prime within four goes).

• Dumb question, but why would we multiply $P(2)$ by $\frac{6}{10}$?
– user750949
Nov 4, 2020 at 8:13
• @E__ I'm not sure I understand the question, but the probability the first prime is on turn 3, say, is the probability that the first two turns are both non-primes (probability $\frac{6}{10}$ each) and the third is a prime (probability $\frac4{10}$). These are independent events, so the probability they all happen is the product of the individual probabilities $\frac6{10}\times\frac6{10}\times\frac4{10}$. Nov 4, 2020 at 8:16
• That answers it, thank you!
– user750949
Nov 4, 2020 at 8:16