8. Suppose that the IQ score for a person selected from a certain group of people

is approximately N(�; 100). Let X1;X2; : : : ;Xn be a random sample of such IQ
scores.
(a) How large should n be so that a 90% con�dence interval for � with maximum
error " = 1 is [ x 􀀀 1:645(10)=
p
n ; x + 1:645(10)=
p
n ]?
(b) Verify your answer empirically. In particular, simulate 50 random samples
of size n from the normal distribution N(110; 100). Do approximately 90%
of these samples yield a con�dence interval that contains � = 110?

To answer part (a), we need to use the formula for the confidence interval of the mean:

CI = [x̄ - z * (s / √n), x̄ + z * (s / √n)]

Where:
- CI is the confidence interval.
- x̄ is the sample mean.
- z is the z-score corresponding to the desired level of confidence.
- s is the sample standard deviation.
- n is the sample size.

In this case, the IQ score follows a normal distribution N(μ, 100), with a mean μ and standard deviation of 10 (since the variance is 100). We want to find the value of n such that the interval has a maximum error of e = 1 and a confidence level of 90%.

Given that 1.645 is the z-score corresponding to a 1-sided confidence level of 90%, we have:

1 = 1.645 * (10 / √n)

Solving for n:

1 / (1.645 * 10) = 1 / √n

√n = 1.645 * 10

n = (1.645 * 10)^2 = 26.98

Therefore, n should be at least 27 to obtain a 90% confidence interval for μ with a maximum error of 1.

To answer part (b), we will simulate 50 random samples of size n = 27 from a normal distribution N(110, 100). For each sample, we will calculate the confidence interval using the same formula as in part (a). Then, we will check how many of these intervals contain the true mean μ = 110.

Here's the Python code to perform the simulation:

```python
import numpy as np

np.random.seed(42) # To ensure reproducibility

n_samples = 50
n = 27
mu = 110
sigma = 10

count = 0 # Counter for the number of samples containing mu

for _ in range(n_samples):
sample = np.random.normal(mu, sigma, n)
x_bar = np.mean(sample)
z = 1.645 # Z-score for a 1-sided 90% confidence level
max_error = z * (sigma / np.sqrt(n))
confidence_interval = [x_bar - max_error, x_bar + max_error]

if confidence_interval[0] <= mu <= confidence_interval[1]:
count += 1

percentage = count / n_samples * 100

print(f"Approximately {percentage}% of the samples yield a confidence interval that contains μ = {mu}.")
```

When running the code, we should expect the output to be approximately 90%, confirming that approximately 90% of the samples yield a confidence interval containing the true mean μ = 110.