Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I roll a die until it comes up $6$ and add up the numbers of spots I see.

For example, I roll $4,1,3,5,6$ and record the number $4+1+3+5+6=19$. Call this sum $S$.

Find the standard deviation of $S$.

I have been looking for an easy way to do this because I know I can use the definitions here to calculate the variance of $S$ and then take the square root of it. But I am sure there is an easier way to do this.

share|cite|improve this question
A geometric distribution seems suited to this sort of problem. – smackcrane Nov 30 '11 at 5:34
There is no easier way than calculating the variance first. – Henry Nov 30 '11 at 7:34
@Henry but how to calculate the variance here, it seems Didier has something pretty complicated. – geraldgreen Nov 30 '11 at 7:54
up vote 8 down vote accepted

I know I can use the definitions here to calculate the variance of $S$ and then take the square root of it.

Not sure I understand what you mean by that... but here we go.

Let $i=6$. For every $n\geqslant1$, call $X_n$ the result of the $n$th throw, uniformly distributed on $\{1,2,\ldots,i\}$, and $A_n$ the event that $X_k\ne i$ for every $1\leqslant k\leqslant n-1$. Then $$ S=\sum\limits_{n=1}^{+\infty}X_n\cdot[A_n]. $$ For every $n$, $\mathrm E(X_n)=x$ with $x=\frac12(i+1)$ and $\mathrm P(A_n)=a^{n-1}$ with $a=\mathrm P(X_1\ne i)$ hence $a=(i-1)/i$ and $$ \mathrm E(S)=\sum\limits_{n=1}^{+\infty}x\cdot a^{n-1}=x\cdot(1-a)^{-1}=\tfrac12i(i+1). $$ Likewise $\mathrm E(S^2)=u+2v$ with $$ u=\sum\limits_{n=1}^{+\infty}\mathrm E(X_n^2\cdot[A_n]), \qquad v=\sum\limits_{n=1}^{+\infty}\sum\limits_{k=n+1}^{+\infty}\mathrm E(X_nX_k\cdot[A_k]). $$ For every $n$, $\mathrm E(X_n^2)=y$ with $y=\mathrm E(X_1^2)=\frac16(i+1)(2i+1)$, and $X_n$ and $A_n$ are independent, hence $$ u=\sum\limits_{n=1}^{+\infty}y\cdot a^{n-1}=y\cdot(1-a)^{-1}=yi. $$ Likewise, for every $k\gt n$, $X_k$ is independent on $X_n\cdot[A_k]$ and $$ \mathrm E(X_n\mid A_k)=\mathrm E(X_n\mid X_n\ne i)=z, $$ with $z=\mathrm E(X_1\mid X_1\ne i)=\frac12i$, hence $$ v=\sum\limits_{n=1}^{+\infty}\sum\limits_{k=n+1}^{+\infty}xz\cdot a^{k-1}=\sum\limits_{n=1}^{+\infty}xz\cdot a^{n}\cdot(1-a)^{-1}=xz\cdot a\cdot(1-a)^{-2}=xzi(i-1). $$ Finally, $$ \mbox{Var}(S)=u+2v-\mathrm E(S)^2=yi+2xzi(i-1)-x^2i^2=\tfrac1{12}i(i+1)(i-1)(3i-2). $$ For $i=6$, $\mathrm E(S)=21$ and $\mbox{Var}(S)=280$.

Edit One sees that $\mathrm E(S)=\mathrm E(X_1)\mathrm E(N)$ where $N$ is the time of the first occurrence of $i$. This is Wald's formula. According to this WP page, the formula for the variance is known as Blackwell–Girshick equation. Proceeding as above, one gets $$ \mathrm{Var}(S)=\mathrm{Var}(X_1)\cdot\mathrm E(N)+\mathrm E(X_1)^2\cdot\mathrm E(N). $$

share|cite|improve this answer
Thanks a lot for Wald's formula and Blackwell-Girshick equation reference. – geraldgreen Nov 30 '11 at 19:56

Let $Y$ be the number of rolls before a $6$ is rolled. Let $X$ be the sum of the dice rolled before a $6$. Straightforward calculation yields $$ \mathsf{E}(X|Y=n)=n\;\mathsf{E}(X|Y=1)=3n $$ and $$ \mathsf{Var}(X|Y=n)=n\;\mathsf{Var}(X|Y=1)=2n $$ and $$ \mathsf{P}(Y=n)=\left(\frac{5}{6}\right)^n\frac{1}{6} $$ Using the Law of Total Variance, we get $$ \begin{align} \mathsf{Var}(X) &=\mathsf{E}(\mathsf{Var}(X|Y))+\mathsf{Var}(\mathsf{E}(X|Y))\\ &=\sum_{n=0}^\infty\;2n\left(\frac{5}{6}\right)^n\frac{1}{6}+\sum_{n=0}^\infty\;(3n)^2\left(\frac{5}{6}\right)^n\frac{1}{6}-\left(\sum_{n=0}^\infty\;3n\left(\frac{5}{6}\right)^n\frac{1}{6}\right)^2\\ &=\frac{2}{6}\frac{\frac{5}{6}}{(1-\frac{5}{6})^2}+\frac{3^2}{6}\left(\frac{2\left(\frac{5}{6}\right)^2}{(1-\frac{5}{6})^3}+\frac{\frac{5}{6}}{(1-\frac{5}{6})^2}\right)-\left(\frac{3}{6}\frac{\frac{5}{6}}{(1-\frac{5}{6})^2}\right)^2\\ &=10+495-225\\ &=280 \end{align} $$ Therefore, the standard deviation is $\sqrt{280}$.


Although not requested in the question, the expected value of $S$ is simple to compute by the linearity of expectation. Since the probability of rolling a $6$ is $\frac{1}{6}$, the mean number of rolls is $6$. Since each non-$6$ roll has a mean of $3$ and on average there will be $5$ non-$6$ rolls, we get $\mathsf{E}(S)=5\cdot3+6=21$.

We can also compute this using the set-up for the variance above. Since $S=6+X$, $$ \begin{align} \mathsf{E}(S) &=6+\mathsf{E}(X)\\ &=6+\mathsf{E}(\mathsf{E}(X|Y))\\ &=6+\sum_{n=0}^\infty3n\left(\frac{5}{6}\right)^n\frac{1}{6}\\ &=6+\frac{3}{6}\frac{\frac{5}{6}}{(1-\frac{5}{6})^2}\\ &=6+15\\ &=21 \end{align} $$

share|cite|improve this answer

A considerably less general and less detailed solution than the one provided by Didier Piau is as follows.

If the first $6$ occurs on the $N$-th roll of the die, then $N$ is a geometric random variable with parameter $\frac{1}{6}$. We have that $E[N] = 6$ and $\text{var}(N) = 30$. Given the value of $N$, we can write $$S = 6 + \sum_{i=1}^{N-1} Y_i$$ where the $Y_i$ are independent random variables uniformly distributed on $\{1,2,3,4,5\}$ and the $6$ is the contribution of the $N$th roll of the die to the sum. Since $E[Y_i] = \frac{1+2+3+4+5}{5} = 3$, $$E[S\mid N] = E\left[6 + \sum_{i=1}^{N-1} Y_i\right] = 6 + \sum_{i=1}^{N-1}E[Y_i] = 6 + 3(N-1) = 3N + 3$$ and so $$E[S] = E[E[S|N]] = E[3N + 3] = 21.$$

Since each $Y_i$ has variance $\dfrac{1^2+2^2+3^2+4^2+5^2}{5}-3^2 = 2$ and is independent of the others, $$\text{var}(S\mid N) = \text{var}\left(6 + \sum_{i=1}^{N-1} Y_i\right) = \sum_{i=1}^{N-1}\text{var}(Y_i) = 2(N-1) ~$$ and so $$E[\text{var}(S\mid N)] = E[2(N-1)] = 10$$ while $$\text{var}(E[S\mid N]) = \text{var}(3N + 3) = 9\cdot\text{var}(N) = 270$$ giving $$\text{var}(S) = E[\text{var}(S\mid N)] + \text{var}(E[S\mid N]) = 280.$$

share|cite|improve this answer
Thanks for your recent flag. I just wanted to mention that now that the question has an upvoted answer, it shouldn't be bumped anymore. – Zev Chonoles Apr 3 '12 at 16:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.