开始使用免费开始使用

两独立样本均值的检验统计量

用于判断两个总体均值是否存在差异的假设检验,所用的检验统计量不同于第 1 章中的 z 分数。这里使用的是 "t",它可由每个样本的三个数值按下式计算:

$$ t = \dfrac{(\bar{x}_{\text{child}} - \bar{x}_{\text{adult}})}{\sqrt{\dfrac{s_{\text{child}}^2}{n_{\text{child}}} + \dfrac{s_{\text{adult}}^2}{n_{\text{adult}}}}} $$

在分析为何部分货件延迟时,您可能想知道:按时到达的货件重量是否小于延迟货件的重量。数据集 late_shipments 已按是否延迟分为 "yes" 组(late == "Yes")与 "no" 组(late == "No")。货件重量存放在变量 weight_kilograms 中。

两组的样本均值分别为 xbar_noxbar_yes。样本标准差为 s_nos_yes。样本量为 n_non_yes。已将 numpynp 名称导入。

本练习是课程的一部分

Python 假设检验

查看课程

练习说明

  • 计算 \(t\) 检验统计量的分子。
  • 计算 \(t\) 检验统计量的分母。
  • 使用这两个数计算 \(t\) 检验统计量。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Calculate the numerator of the test statistic
numerator = ____

# Calculate the denominator of the test statistic
denominator = ____

# Calculate the test statistic
t_stat = ____

# Print the test statistic
print(t_stat)
编辑并运行代码