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

📚 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₁)则相反:存在显著差异,或变量之间存在关联。

  • Goodness-of-fit test: H₀: The data follows a specified distribution. | 拟合优度检验:H₀:数据服从指定分布。

  • Independence test: H₀: The two variables are independent. | 独立性检验: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 | 自由度

Degrees of freedom (df) determine the shape of the chi-squared distribution and are essential for finding the critical value. For a goodness-of-fit test, df = n – 1, where n is the number of categories. For a test of independence, df = (r – 1) × (c – 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 是列数。

  • Goodness-of-fit: df = n – 1 | 拟合优度:df = n – 1

  • Independence: df = (r – 1)(c – 1) | 独立性:df = (r – 1)(c – 1)


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,可能需要合并类别,或考虑使用费希尔精确检验。此外,数据必须是随机样本,且观测值必须相互独立。

  • All expected counts ≥ 5 | 所有期望频数 ≥ 5

  • Random sampling | 随机抽样

  • Independent observations | 观测值独立


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₀。


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 年级)分组。观测数据如下表所示。

Observed Online Offline Total
Grade 11 20 30 50
Grade 12 35 15 50
Total 55 45 100

The expected frequencies are calculated using the row and column totals. For example, the expected count for Grade 11 and Online is (50 × 55) / 100 = 27.5. The complete table of expected frequencies is shown below.

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

Expected Online Offline Total
Grade 11 27.5 22.5 50
Grade 12 27.5 22.5 50
Total 55 45 100

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 计算每个单元格对 χ² 统计量的贡献。计算过程如下。

  • Cell (Grade 11, Online): (20 – 27.5)² / 27.5 = 2.045 | 单元格(11 年级,线上):(20 – 27.5)² / 27.5 = 2.045

  • Cell (Grade 11, Offline): (30 – 22.5)² / 22.5 = 2.500 | 单元格(11 年级,线下):(30 – 22.5)² / 22.5 = 2.500

  • Cell (Grade 12, Online): (35 – 27.5)² / 27.5 = 2.045 | 单元格(12 年级,线上):(35 – 27.5)² / 27.5 = 2.045

  • Cell (Grade 12, Offline): (15 – 22.5)² / 22.5 = 2.500 | 单元格(12 年级,线下):(15 – 22.5)² / 22.5 = 2.500

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% significance level, the critical value from the chi-squared distribution table is 3.841. Since the test statistic (9.090) is greater than the critical 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 | 拟合优度检验:简单示例

The chi-squared goodness-of-fit test checks whether observed data match a theoretical distribution. For example, a die is rolled 120 times, and the observed frequencies are recorded. If the die is fair, the expected frequency for each 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 考试中,必须清晰展示所有步骤,包括假设陈述、期望频数表、χ² 计算以及与临界值的比较。约简应保持一致,通常保留三位有效数字或三位小数。

  • Always state H₀ and H₁ explicitly | 始终明确写出 H₀ 和 H₁

  • Use the correct formula for df | 使用正确的自由度公式

  • Check that all expected frequencies ≥ 5 | 检查所有期望频数 ≥ 5

  • Write the conclusion in the context of the problem | 结合问题情境撰写结论

Published by TutorHao | Mathematics Revision Series | aleveler.com

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

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version