Simulate a random variable that counts the number of heads when four coins are tossed 64 times.
(a) Construct a frequency table
(b) Find the sample mean.
(c) Find the sample variance.
To generate the frequency table, use four random number generators to generate a random integer of 0 or 1 (0 for tails, 1 for heads). Then add the result. A possible frequency table is displayed below.
\[ \begin{align}
x &| f_x \\
0 &| 4 \\
1 &| 16 \\
2 &| 26 \\
3 &| 12 \\
4 &| 6 \\
\text{Total} &| 64
\end{align}\ \]
Use the definition to calculate the sample mean.
\[ \begin{align}
\text{mean} &= \frac{\sum_{i=1}^n x_i \times f_i}{64} \\
&= \frac{0(4)+1(16)+2(26)+3(12)+4(6)}{64} \\
&= \frac{128}{64} \\
&= 2
\end{align}\ \]
Use the definition to find the sample variance
set mean = m, Then
\[ \begin{align}
s^2 &= \frac{\sum_{i=1}^n f_i \times (x_i - \text{m})^2 }{N-1} \quad \\
&= \frac{4(0 - 2)^2 + 16(1 - 2)^2 + 26(2 - 2)^2}{63} \quad \\
&+ \frac{12(3 - 2)^2 + 6(4 - 2)^2}{63} \quad \\
&= \frac{68}{63} \quad \\
&= 1.08
\end{align}\ \]