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?
 A: 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}.$$
