# Expected Value: Rolling a die and Uniform random permutations

Question:

You repeatedly and independently roll a fair die until the result of the roll is divisible by $$3$$.

Defi ne the random variable X to be the number of times you roll the die.

For example, if the results of the rolls are $$4, 5, 1, 4, 3$$, then $$X = 5$$. What is the expected value $$E(X)$$ of $$X$$?

Attempt:

The way I attempted this was:

The result of die roll: 1 2 3 4 5 6, only 3 and 6 are divisible by 3.

That is $$Pr$$ = $$\frac{2}{6}$$

For $$E(X)$$, I did $$x$$*$$p(x)$$ for all the possibilities.

So, ($$\frac{1}{6}$$ * 1) + ($$\frac{1}{6}$$ * 2) + ($$\frac{2}{6}$$ * 3) + ($$\frac{1}{6}$$ * 4) +($$\frac{1}{6}$$ * 5) + ($$\frac{2}{6}$$ * 6) = $$5$$

Not quite the answer though. When I do just ($$\frac{2}{6}$$ * 3) * ($$\frac{2}{6}$$ * 6) = $$3$$. Gives me the correct answer but I just don't understand the logic behind it.

Question:

Let $$n$$ $$>=$$ $$2$$ be an integer and let $$a_1, a_2, ..., a_n$$ be a uniformly random permutation of the set {1,2,...n}. Let $$X$$ be the random variable with value:

$$X$$ = the number of indices $$i$$ with 1 $$<=$$ i $$<=$$ $$n-1$$ and $$a_i < a_{i+1}$$

For example, if $$n = 6$$ and the permutation is $$3, 5, 4, 1, 6, 2$$ then $$X = 2$$. What is the expected value $$E(X)$$ of $$X$$? Use indicator variables.

Answer: $$\frac{n-1}{2}$$

I define my indicator variable:

$$X = \left\{\begin{array}{rc} 1,&\text{the number of indices i with 1 <= i <= n-1 and a_i < a_{i+1} }{} \\ 0,&\text{other cases}{}\end{array}\right.$$

For $$n=2$$: {1,2} , {2,1} so $$Pr =$$ $$\frac{1}{2}$$

$$E(X) =$$ $$P(X_2) =$$ $$\frac{1}{2}$$

For $$n=3$$: {1,2, 3} , {1,3,2} , {2,3,1} so $$Pr =$$ $$\frac{3}{6}$$

Is this the correct method to solve this? I did this for $$n$$ values but when I computed there result with the answers, I never got it to be the same. How do I solve this?

For the first question you started correctly, but then you drifted at the "all possibilities" part. You gotta realize, that technically you can be throwing that thing infinitely many times and never hit your $$3$$ or $$6$$.

Lets write down all the possible results and corresponding probabilities

Just $$1$$ throw: $$P = \frac{1}{3}$$. Pretty straightforward

$$2$$ throws: Now we fail once (probability of fail is $$\frac{2}{3}$$) and then succeed (probability of fail into success is, respectively $$\frac{1}{3}*\frac{2}{3}$$

$$3$$ throws: Now we fail twice (probability of fail twice is $$(\frac{2}{3})^2$$) and then succeed (probability of fail twice into success is, respectively $$(\frac{2}{3})^2*\frac{1}{3}$$

You can continue this to infinity. So lets write the expectation then.

$$E[X] = 1*\frac{1}{3} + 2*\frac{1}{3}*\frac{2}{3} + 3*\frac{1}{3}*(\frac{2}{3})^2 + ...$$

To figure out the result you factor $$\frac{1}{3}$$ first and then create infinitely many geometric series with a different start. The following expression is something like this:

$$E[X] = \frac{1}{3}*( \frac{1}{1 - \frac{2}{3}} + \frac{\frac{2}{3}}{1 - \frac{2}{3}} + \frac{(\frac{2}{3})^2}{1 - \frac{2}{3}} + \frac{(\frac{2}{3})^3}{1 - \frac{2}{3}} ... = 1 + \frac{2}{3} + (\frac{2}{3})^2 + (\frac{2}{3})^3 + ... = \frac{1}{1 - \frac{2}{3}} = 3$$

• I tried implementing this method for a similar question where "You repeatedly and independently roll two fair die until the result of the roll is 12 ". I got the Pr(Success) to be 1/6 and Pr(fail) = 25/36. I followed along your steps and ended up with 1 / (1 - (25/36)) to get 36/11 but the answer is 36. Does the approach have to be different for this case? – Toby Dec 3 '18 at 0:25
• Erm ... 12 is 6 + 6, which should be the only possible solution and thus the success probability should be 1/36 and the fail is 35/36. – Makina Dec 3 '18 at 0:42
• wait I might be dumb, but isn't success for 2 rolls is 1/36 and failure of 2 rolls is 5/6*5/6 = 25/36? – Toby Dec 3 '18 at 2:47
• Probabilities add to 1, your probability is a chance to not roll 6 on any of the dice – Makina Dec 3 '18 at 10:11