Statistics • Score 5 Strategy

Chi-Square Tests: Goodness-of-Fit, Homogeneity & Independence Guide: AP Statistics Score 5 for Carnegie Mellon University

AP Statistics Mastery Guide: Chi-Square Inference

Target Institution: Carnegie Mellon University (CMU)
Target Score: 5
Exempted Course: 36-200 Reasoning with Data (9 Units)
Acceleration Track: 36-225/226 (Probability & Mathematical Statistics) $\rightarrow$ 36-401 (Modern Regression) / 36-402 (Advanced Data Analysis)


1. Introduction & AP Exam Weight

Chi-Square ($\chi^2$) procedures form the bedrock of categorical data analysis on the AP Statistics Exam. Comprising the entirety of Unit 8 (Inference for Categorical Data: Chi-Square), this topic accounts for 2–5% of the Multiple-Choice Section and is virtually guaranteed to appear on Section II (Free-Response Questions)—frequently as FRQ 5 or as a core component of the FRQ 6 Investigative Task.

For students matriculating into Carnegie Mellon University, mastering non-parametric categorical inference is not merely an AP milestone—it is foundational. CMU’s Department of Statistics & Data Science, along with the School of Computer Science (SCS), relies heavily on contingency table analysis, independence testing, and goodness-of-fit mechanics in fields such as: * Computational Social Science * Natural Language Processing (e.g., $N$-gram association metrics) * Machine Learning (e.g., categorical feature selection via information gain and $\chi^2$-filtering)

Achieving a Score 5 grants 9 units of credit for 36-200 (Reasoning with Data), permitting immediate entry into advanced quantitative sequences that set the standard for modern statistical computing.


2. Deep Concept Breakdown

Chi-Square tests evaluate whether an observed distribution of categorical counts differs significantly from an expected distribution defined under a specific null hypothesis $H_0$.

2.1 The Pearson Chi-Square Test Statistic

For all Chi-Square tests, the discrepancy between observed counts ($O_i$) and expected counts ($E_i$) is quantified by Pearson's test statistic:

$$\chi^2 = \sum_{i=1}^{k} \frac{(O_i - E_i)^2}{E_i}$$

Where $k$ represents the total number of cells or categories.

Mathematical Intuition & Mechanics

  1. Squaring the Residuals: Squaring $(O_i - E_i)$ ensures that positive and negative deviations do not cancel each other out and penalizes larger deviations quadratically.
  2. Standardization by Expected Count: Dividing by $E_i$ scales the squared deviation relative to the magnitude of the expected frequency. A deviation of 10 units is massive if $E_i = 5$, but negligible if $E_i = 10,000$.
  3. Sampling Distribution: As sample sizes grow, if $H_0$ is true, the statistic $\chi^2$ asymptotically approaches a Chi-Square distribution with $df$ degrees of freedom. The distribution is skewed right, bounded below by 0, and approaches normality as $df \to \infty$.

2.2 Taxonomy of the Three Chi-Square Tests

Dimension Goodness-of-Fit (GOF) Test of Homogeneity Test of Independence
Number of Population / Samples 1 Population / 1 Sample 2+ Independent Populations or Treatment Groups 1 Population / 1 Sample
Number of Categorical Variables 1 Categorical Variable 1 Categorical Variable measured across groups 2 Categorical Variables measured simultaneously
Degrees of Freedom ($df$) $df = k - 1$
($k = \text{number of categories}$)
$df = (r - 1)(c - 1)$
($r = \text{rows}, c = \text{columns}$)
$df = (r - 1)(c - 1)$
($r = \text{rows}, c = \text{columns}$)
Expected Count Formula $E_i = n \cdot p_i$ $E_{ij} = \frac{(\text{Row } i \text{ Total}) \times (\text{Column } j \text{ Total})}{\text{Grand Total } N}$ $E_{ij} = \frac{(\text{Row } i \text{ Total}) \times (\text{Column } j \text{ Total})}{\text{Grand Total } N}$
Primary Objective Assesses if a sample distribution fits a hypothesized theoretical distribution. Assesses if proportions of a categorical variable are equal across distinct populations. Assesses if an association exists between two categorical variables within a single population.

2.3 Derivation of Degrees of Freedom in Two-Way Contingency Tables

For an $r \times c$ table, the expected count for cell $(i, j)$ under the independence assumption $P(A_i \cap B_j) = P(A_i)P(B_j)$ is:

$$E_{ij} = N \cdot \left(\frac{R_i}{N}\right) \cdot \left(\frac{C_j}{N}\right) = \frac{R_i \cdot C_j}{N}$$

The degrees of freedom represent the number of cell counts free to vary given fixed row and column marginal totals. * Total cells = $r \cdot c$. * Row totals impose $r$ constraints, but $\sum R_i = N$, providing $r - 1$ independent constraints. * Column totals impose $c$ constraints, but $\sum C_j = N$, providing $c - 1$ independent constraints. * Total constraints = $(r - 1) + (c - 1) + 1 = r + c - 1$.

$$df = (r \cdot c) - (r + c - 1) = r \cdot c - r - c + 1 = (r - 1)(c - 1)$$


2.4 Mandatory Conditions for Inference

To apply any Chi-Square test, you must verify three explicit conditions: 1. Randomness: The data must originate from a random sample, stratified random sample, or randomized experiment. 2. 10% Condition (Independence for Sampling Without Replacement): When sampling without replacement, the total sample size $n$ must be less than $10\%$ of the population size $N$ ($n \le 0.10 N$). (Note: This condition is not required for randomized experiments). 3. Large Counts / Expected Cell Frequencies: All expected cell counts must be at least 5 ($\forall i, j: E_{ij} \ge 5$). Crucial AP Distinction: Observed counts can be less than 5; expected counts cannot.


2.5 Programmatic Implementation (Python)

The following script computes the Pearson Chi-Square test from raw contingency matrices and verifies expected cell conditions automatically—mirroring algorithmic workflows at CMU.

import numpy as np
from scipy.stats import chi2, chi2_contingency

def comprehensive_chi2_analysis(observed_matrix):
    """
    Performs complete Chi-Square Test of Independence/Homogeneity.

    Parameters:
    observed_matrix (np.ndarray): 2D array of observed cell counts.
    """
    O = np.array(observed_matrix, dtype=float)
    row_totals = O.sum(axis=1, keepdims=True)
    col_totals = O.sum(axis=0, keepdims=True)
    grand_total = O.sum()

    # Mathematical derivation of Expected Counts
    E = (row_totals @ col_totals) / grand_total

    # Calculate Pearson Statistic manually: sum((O - E)^2 / E)
    chi2_stat = np.sum(((O - E) ** 2) / E)

    r, c = O.shape
    df = (r - 1) * (c - 1)
    p_value = 1.0 - chi2.cdf(chi2_stat, df)

    # Validate Large Counts Condition
    all_expected_ge_5 = np.all(E >= 5)

    print("--- CHI-SQUARE ANALYSIS RESULTS ---")
    print(f"Observed Counts Matrix:\n{O}")
    print(f"\nExpected Counts Matrix:\n{np.round(E, 4)}")
    print(f"\nCondition Check (All E_ij >= 5): {all_expected_ge_5}")
    print(f"Chi-Square Statistic (\u03c7\u00b2): {chi2_stat:.4f}")
    print(f"Degrees of Freedom (df): {df}")
    print(f"p-value: {p_value:.6e}")

    # Cross-verify with SciPy implementation
    chi2_sci, p_sci, df_sci, E_sci = chi2_contingency(O, correction=False)
    assert np.isclose(chi2_stat, chi2_sci), "Mathematical mismatch in statistic calculation!"

    return chi2_stat, p_value, df, E

# Example Usage: 2x3 Matrix
data = np.array([[35, 42, 23],
                 [20, 55, 25]])
comprehensive_chi2_analysis(data)

3. Common AP Exam Pitfalls & Score 5 Rubric Nuances

To earn a Score 5, your FRQs must be graded Essentially Correct (E) across all components. Below are the specific pitfalls that drop Score 4 students down to a Score 3 or 4.

The Pitfall Matrix

       [ Score 4 Traps ]                          [ Score 5 Standard ]
  ┌─────────────────────────┐                ┌──────────────────────────┐
  │ "H0: p1 = p2 = p3"      │  ───────────>  │ Written contextual       │
  │ (Using symbols in GOF)  │  Hypotheses    │ words without parameters │
  └─────────────────────────┘                └──────────────────────────┘
  ┌─────────────────────────┐                ┌──────────────────────────┐
  │ "Observed counts >= 5"  │  ───────────>  │ "All expected counts     │
  │ (Confusing O_i and E_i) │  Conditions    │  >= 5" + Matrix shown    │
  └─────────────────────────┘                └──────────────────────────┘
  ┌─────────────────────────┐                ┌──────────────────────────┐
  │ Confusing Homogeneity   │  ───────────>  │ Sampling method dictates │
  │ with Independence       │  Test Choice   │ exact test name          │
  └─────────────────────────┘                └──────────────────────────┘

Pitfall 1: Incorrect Parameter Symbolization in Hypotheses

Pitfall 2: Failing to Explicitly State Expected Counts

Pitfall 3: Homogeneity vs. Independence Misidentification


Detailed Solution Contrast: Score 4 vs. Score 5

Context:

A study selects a random sample of 200 CMU undergraduates and records their primary IDE preference (VS Code, Vim, PyCharm) across major tracks (CS, Engineering). Determine if an association exists.

Evaluation Criteria Score 4 Response (Partially Correct) Score 5 Response (Essentially Correct)
Hypotheses $H_0: \text{IDE}$ and $\text{Major}$ are independent.
$H_1: \text{They are dependent.}$ (Lacks context)
$H_0:$ There is no association between IDE preference and major track among CMU undergraduates.
$H_a:$ There is an association between IDE preference and major track among CMU undergraduates.
Conditions 1. Random sample given.
2. Counts are greater than 5 ($30 > 5, 20 > 5, \dots$). (Evaluated Observed Counts instead of Expected Counts)
1. Randomness: Random sample of 200 CMU undergraduates stated.
2. 10% Rule: $200 < 10\%$ of all CMU undergraduates.
3. Large Counts: Expected counts are calculated ($E_{11}=42.5, E_{12}=35.5, \dots$). All $E_{ij} \ge 5$.
Calculations $\chi^2 = 12.4, p = 0.002$. Reject $H_0$. (Missing degrees of freedom and explicitly calculated test components) $\chi^2 = \sum \frac{(O - E)^2}{E} = 12.431$
$df = (2 - 1)(3 - 1) = 2$
$p\text{-value} = P(\chi^2 \ge 12.431) = 0.001998$
Conclusion Because $p < 0.05$, we reject $H_0$. IDE depends on major. (Lacks explicit linkage to significance level and context) Because $p\text{-value} \approx 0.002 < \alpha = 0.05$, we reject $H_0$. We have convincing statistical evidence that an association exists between primary IDE preference and major track among CMU undergraduates.

4. Carnegie Mellon University Placement Pathway

Mastering categorical inference provides a direct yield towards degree advancement at Carnegie Mellon University.

       [ AP Statistics Score = 5 ]
                   │
                   ▼
  Exempts: 36-200 Reasoning with Data (9 Units)
                   │
         ┌─────────┴─────────┐
         ▼                   ▼
  [ Technical Track ]   [ Applied Track ]
       36-225               36-401
  Probability Theory   Modern Regression
         │                   │
         ▼                   ▼
       36-226               36-402
  Math Statistics      Adv. Data Analysis

Waiver Details

Subsequent Acceleration Sequence

Waiving 36-200 bypasses introductory exploratory analysis and immediately unlocks advanced coursework: 1. 36-225 / 36-226 (Mathematical Statistics Sequence): Derive continuous Chi-Square distributions from squared standard normals $Z^2 \sim \chi^2_1$, leading to continuous likelihood theory and Maximum Likelihood Estimation (MLE). 2. 36-401 (Modern Regression): Extends two-way contingency table analysis to generalized linear models (GLMs), specifically Logistic Regression and Poisson Regression (Log-Linear Models). 3. Machine Learning Connection (10-315 / 10-701): Categorical contingency statistics ($G^2$ Likelihood Ratio Chi-Square) serve as the foundation for Mutual Information, Kullback-Leibler (KL) Divergence, and Feature Selection Algorithms in machine learning pipelines.


5. High-Yield Practice Problem

Scenario

An AI research laboratory evaluated three distinct large language model (LLM) architectures (Transformer, State-Space, Recurrent) across three domains of reasoning (Logical, Code Generation, Creative Writing). A total of 450 benchmark prompts were randomly assigned—150 to each model architecture—and each output was classified by human evaluators as either Flawless, Minor Error, or Critical Failure.

The observed counts are recorded in the contingency table below:

Model Architecture Flawless Minor Error Critical Failure Total
Transformer 85 45 20 150
State-Space 60 60 30 150
Recurrent 45 55 50 150
Total 190 160 100 450

Tasks:

  1. (a) Identify the appropriate statistical test. State the null and alternative hypotheses in context.
  2. (b) Calculate the expected count for the (Transformer, Critical Failure) cell. State and verify all necessary conditions for inference.
  3. (c) Calculate the Chi-Square test statistic, degrees of freedom, and corresponding $p$-value.
  4. (d) Based on your $p$-value, draw an appropriate conclusion using an $\alpha = 0.01$ significance level.

Step-by-Step Solution & Scoring Checklist

Part (a): Identification and Hypotheses


Part (b): Expected Counts and Conditions


Part (c): Calculations

$$\chi^2 = \sum \frac{(O - E)^2}{E}$$

$$\begin{aligned} \chi^2 &= \frac{(85 - 63.333)^2}{63.333} + \frac{(45 - 53.333)^2}{53.333} + \frac{(20 - 33.333)^2}{33.333} \ &+ \frac{(60 - 63.333)^2}{63.333} + \frac{(60 - 53.333)^2}{53.333} + \frac{(30 - 33.333)^2}{33.333} \ &+ \frac{(45 - 63.333)^2}{63.333} + \frac{(55 - 53.333)^2}{53.333} + \frac{(50 - 33.333)^2}{33.333} \end{aligned}$$

$$\begin{aligned} \chi^2 &= 7.412 + 1.292 + 5.333 \ &+ 0.175 + 0.833 + 0.333 \ &+ 5.307 + 0.052 + 8.333 \ &= 29.068 \end{aligned}$$


Part (d): Conclusion


AP Scoring Rubric Checklist (4-Step AP Free Response Format)

Step 1: State

Step 2: Plan

Step 3: Do

Step 4: Conclude

Aiming for a Score 5 in Statistics?

Secure admission and advanced standing at top institutions like Carnegie Mellon University with elite 1-on-1 AP STEM mentorship.

無料相談・学習プラン診断