Sample Size Computation for the Population Mean Confidence Interval Section
Recall that a \((1-\alpha)\)100% confidence interval for \(\mu\) is \(\bar{x}\pm t_{\alpha/2}\dfrac{s}{\sqrt{n}}\) where the multiplier \(t\) has a t-distribution with \(df = n - 1\). Thus, the margin of error, E, is equal to:
\(E=t_{\alpha/2}\dfrac{s}{\sqrt{n}}\)
To determine the sample size, one first decides the confidence level and the half width of the interval one wants. Then we can find the sample size to yield an interval with that confidence level and with a half width not more than the specified one. The crude method to find the sample size: \(n=\left(\dfrac{z_{\alpha/2}\sigma}{E}\right)^2\) Then round up to the next whole integer.
The Iterative Method Section
A more accurate method to estimate the sample size: iteratively evaluate the formula since the t value also depends on n.
\(n=\left(\dfrac{t_{\alpha/2}s}{E}\right)^2\)
Use the example above for illustration. Start with an initial guess for $n$, plug in the formula, and iteratively solve for \(n\).
If the initial guess for \(n\) is 20, \(t_{0.05} = 1.729\) and degrees of freedom = 19,
\(n=\left(\dfrac{t_{\alpha/2}s}{E}\right)^2=n=\left(\dfrac{1.729(400)}{120}\right)^2=33.21\)
For \(n = 34\), degree of freedom = 33, and \(t_{0.05} = 1.697\)
\(n=\left(\dfrac{t_{\alpha/2}s}{E}\right)^2=n=\left(\dfrac{1.697(400)}{120}\right)^2=31.99\)
If we use \(n = 32\), the result is the same. Thus, the more accurate answer to the example is to sample 32 students.