Sub topic 6
Testing a Single Mean with z and t
Assume you know the mean, variance, standard deviation, normal distribution, z-scores, and basic sampling ideas. This chapter shows how to test whether a population mean equals a specified value.
Set up the test
Suppose an analyst wants to know whether a fund’s average monthly excess return differs from 0%. Define:
- Null hypothesis: H₀: μ = μ₀
- Alternative hypothesis: Hₐ: μ ≠ μ₀, μ > μ₀, or μ < μ₀
The alternative determines the test type. Use a two-tailed test for “differs,” an upper-tailed test for “greater than,” and a lower-tailed test for “less than.”
A test statistic measures how far the sample mean is from the hypothesized mean in standard-error units.
Choose z or t
Use a z-test when the population standard deviation, σ, is known. Use a t-test when σ is unknown and the sample standard deviation, s, replaces it. The t-test is especially important for small samples from an approximately normal population.
| Test | Statistic | Reference distribution | Degrees of freedom |
|---|---|---|---|
| z-test | (x̄ − μ₀) / (σ / √n) | Standard normal | Not applicable |
| t-test | (x̄ − μ₀) / (s / √n) | t distribution | n − 1 |
For a t-test, the degrees of freedom determine the appropriate critical value. Smaller samples produce heavier-tailed t distributions, so they require more extreme statistics to reject H₀.
Worked example
A fund has ten monthly excess returns:
1.2, −0.4, 0.8, 2.1, −1.0, 0.5, 1.7, 0.3, −0.2, 1.1
Test H₀: μ = 0 against Hₐ: μ ≠ 0 at the 5% significance level. Because σ is unknown, use a two-tailed t-test with 9 degrees of freedom.
The statistic is:
t = (x̄ − 0) / (s / √10)
At the 5% level, the two-tailed critical value is approximately ±2.262. Reject H₀ if |t| exceeds 2.262. Otherwise, fail to reject H₀.
import numpy as np
from scipy import stats
returns = np.array([1.2, -0.4, 0.8, 2.1, -1.0,
0.5, 1.7, 0.3, -0.2, 1.1])
n = len(returns)
t_stat, p_value = stats.ttest_1samp(returns, popmean=0.0)
t_crit = stats.t.ppf(1 - 0.05 / 2, df=n - 1)
print("t statistic:", t_stat)
print("p-value:", p_value)
print("critical value:", t_crit)
print("Reject H0" if abs(t_stat) > t_crit else "Fail to reject H0")A p-value below 0.05 gives the same decision as the critical-value method. “Fail to reject” does not prove that the null is true. It means the sample does not provide enough evidence against it.
Exercise
A sample has n = 16, x̄ = 52, s = 8, and H₀: μ = 50. What test statistic should you use?
Show answer
Use a t-test because the population standard deviation is unknown. The statistic is t = (52 − 50) / (8 / √16) = 1.00, with 15 degrees of freedom.