# Sample variance of rolling a die 100 times

The textbook gives an example of testing a null hypothesis that rolling a die 100 times will give you a value of $6$, $\frac{1}{6}$ times. In the experiment, a die was rolled 100 times and 30 of them were $6$'s.

The book obtains a $z$ score for this with the formula $$\frac{\bar{x}- \mu}{ \sqrt{ \frac{p(1-p)}{100}}} = \frac{.30- .167}{ \sqrt{ \frac{.167(1-.167)}{100}}}$$.

I understand that $\sqrt{ \frac{0.167(1-0.167)}{100}}$ must be the standard deviation of the sample mean (tell me if I'm wrong), but how did they get $0.167(1-0.167)$ as the variance?

Where did that formula come from?

-
in your case $p=0.167$ is just the probability that a particular number on the dice shows up. For Bernoulli trials the variance is simply $p(1-p)$. Hope that helps. – jay-sun Nov 26 '12 at 23:32
+1 for the gravatar – alancalvitti Nov 27 '12 at 3:34

Toss a fair die once, and let $X=1$ if the result is a $6$, and let $X=0$ otherwise. Then $E(X)=\frac{1}{6}$, and $E(X^2)=\frac{1}{6}$, and therefore $$\text{Var}(X)=E(X^2)-(E(X))^2=\frac{1}{6}-\frac{1}{6^2}=\frac{1}{6}\left(1-\frac{1}{6}\right).$$
In general, let us repeat an experiment independently $n$ times, and suppose the probability of success on any trial is $p$. Let $Y$ be the number of successes. Then $Y$ has binomial distribution. You probably have seen the fact that $Y$ has variance $npq=np(1-p)$. This can be proved in various ways. For example, let $X_i=1$ if we get a success on the $i$-th trial, and $0$ otherwise. Note that $Y=X_1+X_2+\cdots+X_n$. By an argument virtually identical to the argument of the first paragraph, each $X_i$ has variance $p(1-p)$.
But the variance of a sum of independent random variables is the sum of the variances, so $Y$ has variance $np(1-p)$.
Let $\overline{Y}$ be the sample mean. Then $\overline{Y}=\dfrac{Y}{n}$. It follows that $$\text{Var}(\overline{Y})=\frac{1}{n^2}\text{Var}(Y)=\frac{np(1-p)}{n^2}=\frac{p(1-p)}{n}.$$
Ah it's a Bernoulli equation - I didn't think of it like that. But why is $E[X^2] = \frac{1}{6}$? Shouldn't it be $\frac{1}{216}$? (Since $X^2 = \frac{1}{36}$, divided by $6, = \frac{1}{216}$) – CodyBugstein Nov 26 '12 at 23:35
Note that $X^2=X$, since $X$ only takes on values $1$ and $0$. So if $W=X^2$, then $W=1$ with probability $\frac{1}{6}$, $0$ with probability $\frac{5}{6}$. – André Nicolas Nov 26 '12 at 23:43