← 返回资讯屏轩教育 · 行业资讯

Chi-Squared Test: Principles and Steps | 卡方检验的原理与步骤

2026-08-30 18:06 · 本文部分内容由AI辅助创作

📚 Chi-Squared Test: Principles and Steps | 卡方检验的原理与步骤

The chi-squared test (χ² test) is a fundamental statistical tool in IB Mathematics, used to determine whether there is a significant difference between observed frequencies and expected frequencies in categorical data. It is widely applied in genetics, social sciences, and market research, making it an essential concept for examination success.

卡方检验(χ² 检验)是 IB 数学中的基础统计工具,用于判断分类数据中观测频数与期望频数之间是否存在显著差异。它广泛应用于遗传学、社会科学和市场研究等领域,是考试中不可或缺的核心概念。


1. What Is the Chi-Squared Test? | 什么是卡方检验?

The chi-squared test is a non-parametric hypothesis test that compares observed frequencies (O) with expected frequencies (E) derived from a null hypothesis. The test statistic follows a chi-squared distribution, which is defined by its degrees of freedom (df). There are two common types: the chi-squared goodness-of-fit test and the chi-squared test for independence.

卡方检验是一种非参数假设检验,它将观测频数(O)与基于零假设推导出的期望频数(E)进行比较。检验统计量服从卡方分布,该分布由自由度(df)决定。常见的类型有两种:卡方拟合优度检验和卡方独立性检验。


2. The Null and Alternative Hypotheses | 零假设与备择假设

For a chi-squared test, the null hypothesis (H₀) typically states that there is no significant difference between observed and expected frequencies, or that two categorical variables are independent. The alternative hypothesis (H₁) states the opposite: there is a significant difference, or the variables are associated.

在卡方检验中,零假设(H₀)通常指出观测频数与期望频数之间没有显著差异,或两个分类变量相互独立。备择假设(H₁)则相反:存在显著差异,或变量之间存在关联。


3. The Chi-Squared Test Statistic | 卡方检验统计量

The test statistic is calculated by summing the squared differences between observed and expected frequencies, divided by the expected frequencies. The formula is given below.

检验统计量通过将观测频数与期望频数之差的平方除以期望频数,再求和得到。公式如下。

χ² = Σ [ (Oᵢ - Eᵢ)² / Eᵢ ]

Here, Oᵢ is the observed frequency in category i, and Eᵢ is the expected frequency in category i. The sum is taken over all categories. A larger χ² value indicates a greater discrepancy between observed and expected frequencies.

其中,Oᵢ 是第 i 个类别的观测频数,Eᵢ 是第 i 个类别的期望频数。对所有类别求和。χ² 值越大,表示观测频数与期望频数之间的差异越大。


4. Degrees of Freedom | 自由度

1), where r is the number of rows and c is the number of columns in the contingency table.

自由度(df)决定卡方分布的形状,是查找临界值的关键。对于拟合优度检验,df = n - 1,其中 n 是类别数。对于独立性检验,df = (r - 1) × (c - 1),其中 r 是列联表的行数,c 是列数。


5. Expected Frequencies | 期望频数的计算

Expected frequencies are calculated under the assumption that the null hypothesis is true. For a goodness-of-fit test, the expected frequency for each category is the total sample size multiplied by the theoretical probability for that category. For an independence test, the expected frequency for each cell is the row total multiplied by the column total, divided by the grand total.

期望频数在零假设为真的前提下计算。对于拟合优度检验,每个类别的期望频数等于总样本量乘以该类别的理论概率。对于独立性检验,每个单元格的期望频数等于行合计乘以列合计,再除以总计。

Eᵢⱼ = (Row Total × Column Total) / Grand Total


6. Conditions for the Test | 检验的适用条件

To ensure the validity of the chi-squared test, certain conditions must be met. All expected frequencies should be greater than or equal to 5. If any expected frequency is below 5, categories may need to be combined, or Fisher's exact test should be considered. Additionally, the data must be a random sample, and the observations must be independent.

为确保卡方检验的有效性,必须满足特定条件。所有期望频数应大于或等于 5。如果某个期望频数低于 5,可能需要合并类别,或考虑使用费希尔精确检验。此外,数据必须是随机样本,且观测值必须相互独立。


7. Step-by-Step Procedure | 检验的实施步骤

Performing a chi-squared test involves a systematic sequence of steps. First, state the null and alternative hypotheses. Second, determine the significance level (usually 5%). Third, calculate the expected frequencies. Fourth, compute the χ² statistic. Fifth, determine the degrees of freedom and find the critical value from the chi-squared distribution table. Finally, compare the test statistic with the critical value to draw a conclusion.

执行卡方检验需要按系统步骤进行。首先,陈述零假设和备择假设。其次,确定显著性水平(通常为 5%)。第三,计算期望频数。第四,计算 χ² 统计量。第五,确定自由度并从卡方分布表中查找临界值。最后,将检验统计量与临界值比较,得出结论。

If χ² > χ²_critical, reject H₀. | 若 χ² > χ²_临界值,拒绝 H₀。


广告 / Sponsored

8. Worked Example: Independence Test | 实例分析:独立性检验

Consider a survey of 100 students on whether they prefer online or offline learning, grouped by grade level (Grade 11 and Grade 12). The observed data are shown in the table below.

考虑一项针对 100 名学生的调查,询问他们偏好线上还是线下学习,并按年级(11 年级和 12 年级)分组。观测数据如下表所示。

ObservedOnlineOfflineTotal
Grade 11203050
Grade 12351550
Total5545100

line is (50 × 55) / 100 = 27.5. The complete table of expected frequencies is shown below.

期望频数通过行合计与列合计计算。例如,11 年级且偏好线上的期望频数为 (50 × 55) / 100 = 27.5。完整的期望频数表如下所示。

ExpectedOnlineOfflineTotal
Grade 1127.522.550
Grade 1227.522.550
Total5545100

9. Calculating the χ² Statistic | 计算 χ² 统计量

Now we compute the contribution of each cell to the χ² statistic using the formula (O - E)² / E. The calculations are shown below.

现在使用公式 (O - E)² / E 计算每个单元格对 χ² 统计量的贡献。计算过程如下。

Summing these values gives the total test statistic.

将这些值求和,得到总检验统计量。

χ² = 2.045 + 2.500 + 2.045 + 2.500 = 9.090


10. Finding the Critical Value and Conclusion | 查找临界值并得出结论

For a 2 × 2 table, the degrees of freedom are (2 - 1)(2 - 1) = 1. At a 5% tical value, we reject the null hypothesis. This indicates a significant association between grade level and learning preference.

对于 2 × 2 表格,自由度为 (2 - 1)(2 - 1) = 1。在 5% 显著性水平下,卡方分布表的临界值为 3.841。由于检验统计量(9.090)大于临界值,我们拒绝零假设。这表明年级与学习偏好之间存在显著关联。

χ² = 9.090 > 3.841 ⇒ Reject H₀


11. Goodness-of-Fit Test: A Simple Illustration | 拟合优度检验:简单示例

face is 120 / 6 = 20. The χ² statistic is calculated in the same way, with df = 6 - 1 = 5.

卡方拟合优度检验用于检查观测数据是否符合理论分布。例如,掷一枚骰子 120 次,记录观测频数。如果骰子是公平的,每个面的期望频数为 120 / 6 = 20。χ² 统计量以相同方式计算,自由度为 6 - 1 = 5。

If the observed counts are very close to 20, then χ² will be small, and we do not reject the null hypothesis. If some faces appear much more often than expected, χ² will be large, suggesting the die is biased.

如果观测频数非常接近 20,χ² 值会很小,我们就不能拒绝零假设。如果某些面出现的次数远超预期,χ² 值会很大,表明骰子可能有偏。


12. Common Pitfalls and Exam Tips | 常见误区与考试技巧

Students often make mistakes when calculating expected frequencies or misreading the degrees of freedom. Always check that the sum of expected frequencies equals the grand total. In IB exams, you must show all steps clearly, including the hypothesis statement, the expected frequency table, the χ² calculation, and the comparison with the critical value. Rounding should be consistent, typically to three significant figures or three decimal places.

学生在计算期望频数或确定自由度时经常出错。务必检查期望频数之和是否等于总计。在 IB 考试中,必须清晰展示所有步骤,包括假设陈述、期望频数表、χ² 计算以及与临界值的比较。约简应保持一致,通常保留三位有效数字或三位小数。

Published by TutorHao | Mathematics Revision Series | aleveler.com

广告 / Sponsored
官网正版 国际课程数学核心词汇 唯寻国际教育 全英 学科 GCSE A Level IB MYP IB IBDP 美高…
数学 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥19.7

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao