跳到主内容
数理基础统计推断(Statistical Inference) · 统计第1–10讲5/10模块导览 →
讲义

统计第5讲:区间估计 | Interval Estimation

从点估计扩展到区间估计,推导正态模型下的置信区间,并说明置信水平、样本量与区间宽度的关系。

完成状态保存在当前浏览器,可随时取消。

基础概念#

从点估计到区间估计#

设独立同分布随机变量X1,...,XnX_1,...,X_n服从均值为μ\mu、方差为σ2\sigma^2的分布:

  • 样本均值 (Sample Mean):
xˉ=1ni=1nxi\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i
  • 样本方差 (Sample Variance):
s2=1n1i=1n(xixˉ)2s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2
  • 标准误 (Standard Error, SE):
SE=snSE = \frac{s}{\sqrt{n}}

点估计通过xˉ±SE\bar{x} \pm SE给出估计范围,但无法量化置信程度。区间估计通过构建置信区间 (Confidence Interval) 解决这一缺陷。

核心思想#

置信区间满足:

Pr(μ[L,U])=1αPr(\mu \in [L,U]) = 1-\alpha

其中:

  • L,UL,U为区间端点

  • 1α1-\alpha置信水平 (Confidence Level)

  • α\alpha显著性水平 (Significance Level)

正态分布下的置信区间#

标准正态分位数#

ZN(0,1)Z \sim N(0,1),定义上尾分位数 (Upper-tail Quantile) zpz_p满足:

Pr(Z>zp)=pPr(Z > z_p) = p

特别地:

  • z0.5=0z_{0.5} = 0(中位数)

  • Pr(zpZzp)=12pPr(-z_p \leq Z \leq z_p) = 1-2p(对称区间概率)

置信区间构建#

当满足以下条件之一时:

  1. 总体服从正态分布(任意样本量)

  2. 大样本情况(中心极限定理适用)

95%置信区间公式:

xˉ±z0.025SE\bar{x} \pm z_{0.025} \cdot SE

具体推导:

Pr(z0.025XˉμSEz0.025)=0.95Pr(Xˉz0.025SEμXˉ+z0.025SE)=0.95\begin{aligned} Pr\left(-z_{0.025} \leq \frac{\bar{X}-\mu}{SE} \leq z_{0.025}\right) &= 0.95 \\ \Rightarrow Pr\left(\bar{X}-z_{0.025}SE \leq \mu \leq \bar{X}+z_{0.025}SE\right) &= 0.95 \end{aligned}

常用分位数值#

置信水平α\alphazα/2z_{\alpha/2}
90%0.101.645
95%0.051.960
99%0.012.576

实际应用案例#

股票收益率估计#

某股票30日收益率数据:

  • 样本均值xˉ=0.8%\bar{x} = 0.8\%

  • 样本标准差s=2.5%s = 2.5\%

计算95%置信区间:

SE=2.5%300.456%CI=0.8%±1.96×0.456%=[0.8%0.894%,0.8%+0.894%]=[0.094%,1.694%]\begin{aligned} SE &= \frac{2.5\%}{\sqrt{30}} \approx 0.456\% \\ CI &= 0.8\% \pm 1.96 \times 0.456\% \\ &= [0.8\% - 0.894\%, 0.8\% + 0.894\%] \\ &= [-0.094\%, 1.694\%] \end{aligned}

解读:有95%的置信度认为该股票的真实日均收益率在-0.094%到1.694%之间。

学习建议#

  1. 重点掌握

    • 置信区间的概率解释(不是参数落在区间的概率)

    • 标准误与标准差的区别

  2. 典型错误

    • 将"95%置信度"理解为"参数有95%概率在区间内"

    • 忽略样本量对区间宽度的影响

  3. 实践练习

code
# 使用正态近似计算总体均值的置信区间
import math
import random
import statistics

random.seed(42)
data = [random.gauss(mu=5, sigma=2) for _ in range(100)]
confidence = 0.95
sample_mean = statistics.fmean(data)
standard_error = statistics.stdev(data) / math.sqrt(len(data))
critical_value = statistics.NormalDist().inv_cdf(
    1 - (1 - confidence) / 2
)
margin_of_error = critical_value * standard_error
ci = (
    sample_mean - margin_of_error,
    sample_mean + margin_of_error,
)

print(f"样本均值:{sample_mean:.3f}")
print(f"{confidence:.0%} 置信区间:({ci[0]:.3f}, {ci[1]:.3f})")