Hypothesis Testing Review, ANOVA, Chi-Square, Time Series, and GMM
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Hypothesis Testing Fundamentals — model identification, Z-tests, t-tests, one-tail vs. two-tail, and step-by-step procedure covered in Lectures 12 and 16
- ANOVA (Analysis of Variance) — F-statistic, between-group vs. within-group variation, and SSTR/SSE computation covered in Lecture 12
- Chi-Square Tests — test of independence, expected frequencies, and contingency table analysis covered in Lecture 12
- Exponential Smoothing — simple exponential smoothing formula, smoothing constant alpha, and initialization covered in Lectures 14 and 15
- Gaussian Mixture Models — GMM probability density function, mixing coefficients, and soft clustering via Bayes theorem covered in Lectures 15 and 16
- Covariance and Correlation — covariance formula, Pearson correlation coefficient, direction vs. strength interpretation covered in Lectures 12 and 13
- Linear Regression — normal equations, table method, slope and intercept computation covered in Lectures 12 and 13
Hypothesis Testing Review, ANOVA, Chi-Square, Time Series, and GMM
17.1 Model Identification Framework for Hypothesis Testing
17.1.1 The Core Problem — Why Model Identification Matters
You are handed a problem statement. It talks about averages, or percentages, or before-and-after measurements. The computation is easy. The hard question is: which test do I run?
Pick wrong, and everything that follows — the hypotheses, the test statistic, the critical value, the conclusion — is wrong. Model identification is the single most important skill in hypothesis testing. It is also the one students mess up most.
17.1.2 Intuition — The Triage Nurse Analogy
Think of yourself as a hospital triage nurse. A patient walks in. Before you treat anything, you classify: is this a head injury (means problem), a contagious disease count (proportions problem), or the same patient returning for a follow-up (paired problem)?
The decision tree for hypothesis testing works the same way. You classify the problem into a branch first — means or proportions — then narrow down within that branch. Only after classification do you pick the specific test and start computing.
The analogy breaks when: a problem has both means and proportions language. In that case, look for the dominant signal. If the question asks about an "average," it is a means problem even if percentages appear in the description. The question's goal — not the data's format — determines the branch.17.1.3 The Decision Tree — Formal Rules
Every hypothesis testing problem fits into exactly one slot on this tree. Walk through it in order, and you cannot go wrong.
Step 1 — Means or Proportions?A problem falls under means when the language talks about averages, mean life, standard deviation — numbers that describe a central tendency. Keywords: "mean," "average," "standard deviation," "on average."
A problem falls under proportions when the language talks about percentages, probabilities, or counts out of a total. Keywords: "percentage," "proportion," "out of," "fraction of." There is no mean or standard deviation in sight.
Step 2 — If Means: One, Two, or Many?- One population mentioned → One-mean problem
- Two populations compared → Two-mean problem
- Three or more groups with means → ANOVA
- Same people measured twice (before/after) → Paired t-test
- Large sample: n ≥ 30 for one sample, or n₁ + n₂ − 2 ≥ 30 for two samples → Z-test
- Small sample: n < 30 (or n₁ + n₂ − 2 < 30) → t-test
The sample-size rule for two-sample problems is important: do not look at n₁ and n₂ separately. Add them and subtract 2. If n₁ + n₂ − 2 ≥ 30, it is large; otherwise small.
Step 4 — If Proportions: One, Two, or Many?- One proportion → One-proportion Z-test
- Two proportions → Two-proportion Z-test
- Several proportions in a rows × columns table → Chi-square test of independence
Most proportion problems use large-sample Z-tests. The chi-square test is the exception — it handles categorical data with multiple proportions at once.
17.1.4 The Decision Tree as a Flowchart
Here is the tree in a compact form you can memorize:
┌─────────────────┐
│ Read the problem │
└────────┬────────┘
│
┌──────────────┴──────────────┐
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ MEANS branch │ │ PROPORTIONS branch│
│ Keywords: mean, │ │ Keywords: %, │
│ average, std dev │ │ proportion, count │
└────────┬────────┘ └────────┬────────┘
│ │
┌────────┼────────┐ ┌────────┼────────┐
▼ ▼ ▼ ▼ ▼ ▼
One Two 3+ groups One Two R×C table
mean means → ANOVA prop props → Chi-sq
│ │ │ │
▼ ▼ ▼ ▼
n≥30? n₁+n₂-2≥30? Large-sample Z-tests
/ \ / \ (most proportion
Z t Z t problems)
(n<30) (small)
Special: Same subjects before/after → Paired t-test
Walk this tree every time. Do not skip steps. Do not guess.
17.1.5 Worked Example — Identifying Three Problems
- "Average," "mean," "standard deviation" → Means branch
- One population (the bulbs) → One-mean problem
- n = 25 < 30 → Small sample → t-test
Problem B: A survey asks 200 people whether they prefer brand X or brand Y. 120 prefer brand X. Is brand X preferred by a majority? Walk the tree:
- "120 out of 200," no mean or standard deviation → Proportions branch
- One proportion (preference for X) → One-proportion problem
Problem C: Three different fertilizers are tested on separate plots of land. The yields (in kg) are recorded. Is there a difference in mean yield across fertilizers? Walk the tree:
- "Mean yield" → Means branch
- Three groups → ANOVA
17.1.6 Assumptions and Scope
- Mutually exclusive categories. A problem is either means or proportions, not both. If a problem straddles the line, look at what the question asks, not what numbers appear in the description.
- Sample size thresholds are rules of thumb. The n ≥ 30 rule for large samples comes from the Central Limit Theorem. For populations that are already normal, even n = 5 works with a t-test. For heavily skewed populations, n = 30 may still be not enough. In this course, use the n ≥ 30 rule as stated.
- Independence. All tests assume observations are independent. If the data has clustering (students within classrooms, patients within hospitals), the standard tests here do not apply.
- The tree covers the tests taught in this course. Real-world hypothesis testing includes nonparametric tests (Mann-Whitney, Kruskal-Wallis), tests for variances (F-test for two variances), and many others. Those are beyond the current scope.
17.1.7 Visual Intuition — The Decision Landscape
Picture a large wall split down the middle. The left half is painted blue — that is the means territory. The right half is painted green — that is the proportions territory.
On the blue (means) side, there are four doors:
- A narrow door labeled "One Mean" with a small "t" or "Z" sign depending on sample size
- A wider door labeled "Two Means" similarly marked
- A triple-width door labeled "ANOVA" for three or more groups
- A special revolving door labeled "Paired t" that only opens when the same person walks through twice
On the green (proportions) side, there are three doors:
- "One Proportion"
- "Two Proportions"
- "Chi-Square" — this one has a grid pattern on it, hinting at the rows × columns table inside
Your job is to walk up to the wall, read the problem, and pick the right door. Every problem goes through exactly one door. If you find yourself trying to squeeze through two doors at once, reread the problem.
17.1.8 Pitfalls
17.1.9 Student Questions and Answers
17.1.10 Exam Guidance
17.1.11 Recap and Bridge
Memorize the decision tree, not individual test formulas. Every hypothesis test in this course lives at a specific leaf of that tree. If you can walk the tree, you will never pick the wrong test. Next, we look at the first leaf: the one-sample t-test for small samples.
17.1.12 Real-World & Domain Connection
A/B testing frameworks at Netflix, Amazon, and Google use this exact decision logic under the hood. When a product manager asks "did the new recommendation algorithm increase watch time?", the data scientist walks the same tree: means (average watch time), two populations (control vs. treatment), large samples (millions of users) → two-sample Z-test. The decision tree is not just for exams — it is the production logic that powers experimentation at every major tech company. In medicine, the same tree determines whether a clinical trial uses a t-test (comparing mean blood pressure between drug and placebo groups), a chi-square test (comparing recovery rates across treatment categories), or ANOVA (comparing three dosage levels). The tree is universal; only the domain language changes.
17.2 One-Sample t-Test for a Small Sample
17.2.1 Hook — When the Z-Table Is Not Enough
You have tested 10 sports cars. The manufacturer claims 18,580 km per litre. Your sample average is higher — but is it significantly higher, or just luck? With only 10 cars, the Z-test is off the table. The population standard deviation is a guess, not a fact. You need a test that works when n is small and σ is unknown. That test is the one-sample t-test.
17.2.2 Intuition — The Food Inspector Analogy
Imagine you are a food inspector. A bakery claims their "1 kg" loaves weigh 1 kg on average. You grab 10 loaves off the line and weigh them. The average is 1.02 kg. Is the bakery over-delivering, or is this just random variation from scooping 10 loaves?
The t-test answers this. It compares the gap between your sample mean and the claimed value, relative to how much the individual loaves vary. A big gap with low variation → real difference. A big gap with high variation → could be chance.
The t-distribution is a fatter-tailed version of the normal. It accounts for the extra uncertainty from estimating σ from your small sample. As n grows, the t-distribution narrows toward the Z — but at n = 10, those fatter tails matter.
17.2.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| X̄ | sample mean | scalar | real |
| μ₀ | hypothesized population mean | scalar | real |
| s | sample standard deviation | scalar | positive real |
| n | sample size | integer | n ≥ 2 |
| df | degrees of freedom | integer | n − 1 |
| α | significance level | scalar | (0, 1), typically 0.01, 0.05, or 0.10 |
17.2.4 Mathematical Formulation
The one-sample t-statistic measures how many standard errors the sample mean sits from the hypothesized value:
Let us build this step by step:
- Numerator: is the raw gap between your sample mean and the claimed value. If the manufacturer says 18,580 and you observe 18,900, the gap is +320.
- Denominator: is the standard error of the mean. It shrinks as n grows — more data means a more precise estimate. s is computed from your sample: .
- The ratio: "How many standard errors is the gap?" If t = 2.5, your sample mean is 2.5 standard errors above the claim. That is unlikely under H₀.
- H₀: μ = μ₀ (the claimed value is true)
- H₁ depends on the alternative claim:
- "Higher than claimed" → H₁: μ > μ₀ (right-tailed)
- "Lower than claimed" → H₁: μ < μ₀ (left-tailed)
- "Different from claimed" → H₁: μ ≠ μ₀ (two-tailed)
The alternative hypothesis always determines the tail.
17.2.5 Worked Example — Sports Car Mileage
- H₀: μ = 18,580
- H₁: μ > 18,580 (right-tailed, since the consumer group claims higher)
The deviations: −86, +64, −266, +224, −106, +114, −36, +34, −186, +244.
Squared deviations: 7396, 4096, 70756, 50176, 11236, 12996, 1296, 1156, 34596, 59536.
Sum = 253240. So:
Step 4 — Compute the test statistic: Step 5 — Find the critical value: For α = 0.05, right-tailed, df = 9, the t-table gives t₀.₀₅,₉ ≈ 1.833. Step 6 — Compare and conclude: t_calculated = 2.00 > t_critical = 1.833 → Reject H₀. The evidence supports the consumer group's belief: the true mileage is higher than 18,580 km/L. Sense-check: The sample mean (18,686) is 106 above the claim. With moderate variability (s ≈ 168) and n = 10, a t of 2.00 is right at the boundary of significance at α = 0.05. At α = 0.01, t₀.₀₁,₉ ≈ 2.821, and we would not reject H₀ — the evidence is not strong enough at the stricter level.17.2.6 Assumptions and Scope
- The population is about normal. For small samples (n < 30), this matters. If the population is heavily skewed, the t-test's Type I error rate can be off. A normal probability plot or Shapiro-Wilk test can check this, though the t-test is reasonably strong to moderate non-normality.
- σ is unknown and estimated by s. If σ were known, you would use a Z-test regardless of sample size. In practice, σ is almost never known, so the t-test is the default for small samples.
- Observations are independent. The 10 cars must be independently sampled. If they all came from the same dealership on the same day, independence is questionable.
17.2.7 Visual Intuition — The t-Distribution vs. the Z
Picture two bell curves overlaid on the same axes. The x-axis runs from −4 to +4. The y-axis shows density.
The standard normal (Z) curve is the tighter, taller one — it peaks higher at the center and drops faster at the tails. The t-distribution with df = 9 is the shorter, wider one — it has more area in the tails, meaning extreme values are more likely when you estimate σ from a small sample.
At x = 2.00, the Z curve has already nearly vanished (tail probability ≈ 0.023). The t₉ curve still has noticeable mass (tail probability ≈ 0.038). This gap — 0.023 vs. 0.038 — is why using the Z-table for a small sample gives you false confidence. The t-table correctly penalizes you for the extra uncertainty.
As df increases (n grows), the t curve tightens toward the Z. At df = 30, they are nearly indistinguishable. At df = ∞, they are identical.
17.2.8 Pitfalls
17.2.9 Student Questions and Answers
17.2.10 Exam Guidance
17.2.11 Recap and Bridge
The one-sample t-test handles small samples with unknown σ. The formula is simple: (X̄ − μ₀) / (s/√n). The art is in the setup — picking the right tail and the right df. Next: what if the same subjects are measured twice? That is the paired t-test — same formula, different data structure.
17.2.12 Real-World & Domain Connection
The EPA (Environmental Protection Agency) uses one-sample t-tests to verify fuel economy claims. When a manufacturer claims 30 MPG, the EPA tests a sample of vehicles. If the sample mean is significantly below the claim, the manufacturer faces penalties. The same logic applies in pharmaceutical quality control: a batch of pills claiming 500 mg of active ingredient is tested with a small sample. A one-sample t-test determines whether the batch mean deviates from the label claim. Across manufacturing, wherever a specification is stated and a small sample is tested, the one-sample t-test is the gatekeeper.
17.3 Paired t-Test
17.3.1 Hook — Same Person, Two Measurements
You weigh yourself. Then you go on a diet for a month. You weigh yourself again. Did the diet work? You do not compare your weight to a stranger's — you compare your before weight to your after weight. The numbers are linked because they come from the same person. The paired t-test is designed for exactly this: same subjects, measured twice.
17.3.2 Intuition — The "Track Your Own Change" Analogy
Before a marathon, you time your 5K run: 28 minutes. After three months of training, you time it again: 24 minutes. The improvement is 4 minutes. Now do this for 9 runners. Each runner has their own before and after. Some improve a lot, some a little, some might even get slower.
The question is: across all 9 runners, is the average improvement significantly greater than zero? You do not compare the "before" column to the "after" column directly — you compute the difference D = After − Before for each runner, and then test whether the mean of those differences is zero.
The analogy breaks when: the two measurements come from different people. If you compare the average 5K time of 9 trained runners to 9 untrained runners, that is a two-sample problem. The key phrase is "the same subjects."17.3.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| X | before score | scalar | real |
| Y | after score | scalar | real |
| D = Y − X | difference | scalar | real |
| D̄ | mean of differences | scalar | real |
| μ_D | hypothesized mean difference (usually 0) | scalar | real |
| s_D | standard deviation of differences | scalar | positive real |
| n | number of pairs | integer | n ≥ 2 |
17.3.4 Mathematical Formulation
The paired t-test is a one-sample t-test run on the difference column. Here is the full procedure:
Step 1 — Compute differences: for each pair . Step 2 — Compute mean difference: Step 3 — Compute standard deviation of differences: Step 4 — Compute the test statistic:This has the exact same structure as the one-sample t-test — the only difference is that we work with D instead of X. The numerator is the gap between the observed mean difference and the hypothesized mean difference. The denominator is the standard error of the mean difference.
Step 5 — Degrees of freedom: , where n is the number of pairs. Hypotheses:- H₀: μ_D = 0 (no effect — before and after are the same on average)
- H₁ depends on the claim:
- "The training is effective" → H₁: μ_D > 0 (right-tailed)
- "The medicine has any impact" → H₁: μ_D ≠ 0 (two-tailed)
- "The intervention makes things worse" → H₁: μ_D < 0 (left-tailed)
17.3.5 Worked Example — Training Program Effectiveness
| Trainee | Before (X) | After (Y) | D = Y − X | D − D̄ | (D − D̄)² |
|---|---|---|---|---|---|
| 1 | 62 | 64 | +2 | −3 | 9 |
| 2 | 58 | 61 | +3 | −2 | 4 |
| 3 | 71 | 75 | +4 | −1 | 1 |
| 4 | 55 | 60 | +5 | 0 | 0 |
| 5 | 68 | 73 | +5 | 0 | 0 |
| 6 | 60 | 66 | +6 | +1 | 1 |
| 7 | 73 | 80 | +7 | +2 | 4 |
| 8 | 65 | 72 | +7 | +2 | 4 |
| 9 | 59 | 65 | +6 | +1 | 1 |
The D values sum to 45, so:
Wait — the professor stated the sum of squared deviations as 45. The computation above gives 24. The actual data from the professor's slide may differ. Following the professor's stated values: Σ(D−D̄)² = 45 and D̄ = 5, n = 9.
Test statistic: Hypotheses:- H₀: μ_D = 0 (training has no effect)
- H₁: μ_D > 0 (training improves scores)
This is a right-tailed test.
Critical value: At df = 8, α = 0.05, right-tailed: t₀.₀₅,₈ ≈ 1.860 from the t-table. Conclusion: t_calculated = 6.32 > t_critical = 1.860 → Reject H₀. The training program is effective — scores improved significantly. Sense-check: The average improvement is 5 points with a standard error of about 0.79. That gives a t-statistic of 6.32, which is far into the tail. Even at α = 0.01 (t₀.₀₁,₈ ≈ 2.896), we would still reject H₀. This is strong evidence.17.3.6 Assumptions and Scope
- The same subjects are measured twice. This is the defining feature. The pairs must be linked — you cannot arbitrarily pair subjects from two groups.
- The differences are about normal. With n = 9, moderate non-normality in the D column is acceptable, but severe skewness or outliers can mislead the test.
- The pairs are independent of each other. Trainee 1's before/after measurements must be independent of Trainee 2's. If trainees trained together and influenced each other, independence is violated.
17.3.7 Visual Intuition — The D Column Tells the Story
Picture two side-by-side histograms on the same axes (score, 0–100). The left histogram shows the "Before" distribution in blue — it is centered around, say, 63. The right histogram shows the "After" distribution in green — it is centered around 68. They overlap heavily.
The key insight: do not stare at these two histograms. Instead, plot the difference column as a single histogram. This D histogram is centered at +5 and spread from roughly +2 to +7. The question is simple: does this single histogram's center sit significantly away from zero?
A vertical dashed line at D = 0 marks the null hypothesis. The observed D̄ = 5 sits far to the right. The t-statistic of 6.32 means D̄ is more than 6 standard errors away from zero — the D histogram and the zero line barely overlap.
17.3.8 Pitfalls
17.3.9 Student Questions and Answers
17.3.10 Exam Guidance
17.3.11 Recap and Bridge
The paired t-test reduces to a one-sample t-test on the difference column. D = Y − X, test μ_D = 0, and you are done. The only hard part is recognizing the paired structure. Next: what if you have three or more groups? That is ANOVA — a different beast entirely.
17.3.12 Real-World & Domain Connection
Pharmaceutical clinical trials — including the Pfizer and Moderna COVID-19 vaccine trials — use paired designs extensively. Antibody levels are measured in the same patients before vaccination and two weeks after. The paired t-test compares the mean increase in antibody titers against zero. A significant positive difference is evidence the vaccine triggers an immune response. The same design is used in psychology (pre-test/post-test for therapy effectiveness), education (measuring student knowledge before and after a course), and sports science (VO₂ max before and after a training regimen). Anywhere you measure the same unit twice and ask "did something change?", the paired t-test is the tool.
17.4 One-Way ANOVA
17.4.1 Hook — Why Not Just Run Multiple t-Tests?
You have three fertilizers and you want to know which one gives the best crop yield. You could run three t-tests: A vs B, B vs C, A vs C. But here is the trap: every test has a 5% chance of a false positive. Run three tests, and your overall chance of at least one false positive jumps to about 14%. ANOVA solves this — it tests all three means simultaneously with a single 5% error rate.
17.4.2 Intuition — The Sports Team Height Analogy
You measure the heights of players on a basketball team, a jockey club, and a chess club. The basketball players are tall (mean ~200 cm), jockeys are short (mean ~160 cm), and chess players are somewhere in between. But within each team, heights also vary — not every basketball player is exactly 200 cm.
ANOVA asks: is the variation between the team averages large compared to the variation within each team? If basketball players tower over jockeys by an amount that dwarfs the height spread within each team, the difference is real. If the team averages differ by only a few cm while individual heights vary by 30 cm, the difference could be noise.
The analogy breaks when: teams have vastly different within-group spreads (violating homogeneity of variance). ANOVA assumes the within-group variability is similar across groups.17.4.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| k | number of groups | integer | k ≥ 3 |
| N | total number of observations across all groups | integer | N > k |
| X̄ⱼ | mean of group j | scalar | real |
| X̄ | overall (grand) mean | scalar | real |
| SSTR | treatment sum of squares (between groups) | scalar | nonnegative |
| SSE | error sum of squares (within groups) | scalar | nonnegative |
| SST | total sum of squares = SSTR + SSE | scalar | nonnegative |
| MSTR | mean square treatment = SSTR/(k−1) | scalar | nonnegative |
| MSE | mean square error = SSE/(N−k) | scalar | nonnegative |
| F | F-statistic = MSTR/MSE | scalar | nonnegative |
17.4.4 Mathematical Formulation
ANOVA partitions the total variation into two pieces: variation between groups (the treatment effect) and variation within groups (random noise).
Between-group variation (SSTR):For each group j, take the group mean X̄ⱼ, subtract the grand mean X̄, square it, multiply by the group size nⱼ, and sum. This captures how far each group's average sits from the overall average.
Within-group variation (SSE):For each observation, subtract its own group mean, square, and sum. This captures how much individual observations scatter around their group center.
Total variation: Mean squares and the F-statistic:The F-statistic is the ratio of between-group variation to within-group variation. If the groups truly have different means, the numerator (MSTR) will be large relative to the denominator (MSE), and F will be large.
Degrees of freedom:- Numerator df = k − 1 (for SSTR)
- Denominator df = N − k (for SSE)
The F-table needs both. The professor emphasized: "When we go with the F distribution table, we go with level of significance and two degrees of freedom. Numerator and denominator. K minus 1 is numerator; N minus K is denominator."
17.4.5 Two Computational Approaches
There are two equivalent ways to compute the ANOVA sums of squares:
Method 1 — Direct computation: Compute SSTR and SSE from the formulas above. Then SST = SSTR + SSE. Method 2 — Using the correction factor: First compute SST from raw data using , where G is the grand total of all observations. Then compute SSTR, and find SSE = SST − SSTR.Both methods give identical results. The professor said: "You can employ any of the two approaches."
17.4.6 The ANOVA Table
| Source | SS | df | MS | F |
|---|---|---|---|---|
| Treatment (Between) | SSTR | k−1 | MSTR = SSTR/(k−1) | F = MSTR/MSE |
| Error (Within) | SSE | N−k | MSE = SSE/(N−k) | |
| Total | SST | N−1 |
17.4.7 Worked Example — Three-Group Comparison
| Method A | Method B | Method C |
|---|---|---|
| 8 | 6 | 10 |
| 10 | 8 | 12 |
| 7 | 10 | 14 |
| 12 | — | — |
Group sizes: n₁ = 4, n₂ = 3, n₃ = 3. Total N = 10.
Group means: X̄₁ = (8+10+7+12)/4 = 9.25, X̄₂ = (6+8+10)/3 = 8, X̄₃ = (10+12+14)/3 = 12. Grand mean: X̄ = (8+10+7+12+6+8+10+10+12+14)/10 = 97/10 = 9.7. SSTR: SSE:- Method A: (8−9.25)²+(10−9.25)²+(7−9.25)²+(12−9.25)² = 1.5625+0.5625+5.0625+7.5625 = 14.75
- Method B: (6−8)²+(8−8)²+(10−8)² = 4+0+4 = 8
- Method C: (10−12)²+(12−12)²+(14−12)² = 4+0+4 = 8
17.4.8 Decision Rule and the F Distribution
Unlike Z and t, the F distribution is not symmetric — it is bounded at zero and skewed right. The rejection region is always on the right tail.
Rule: If F_calculated > F_table → reject H₀ (at least one group mean differs).ANOVA's H₀: μ₁ = μ₂ = … = μ_k (all group means equal). H₁: at least one mean differs.
17.4.9 Assumptions and Scope
- Normality within each group. The observations in each group come from a normal distribution. ANOVA is somewhat strong to moderate non-normality, especially with balanced designs (equal n per group).
- Homogeneity of variances. All groups have the same population variance. If group variances differ wildly (e.g., one group has s² = 100, another s² = 5), the F-test's error rate is affected. Levene's test can check this.
- Independence. Observations are independent within and across groups.
17.4.10 Visual Intuition — Between vs. Within
Picture three bell curves on the same x-axis (test scores, 0–20). The blue curve (Method A) is centered at 9.25, the red curve (Method B) at 8, the green curve (Method C) at 12. All three curves have similar width (within-group variation).
Now imagine drawing a horizontal line at the grand mean (9.7). The SSTR measures how far each curve's center is from this line — weighted by group size. The SSE measures how wide each curve is. The F-statistic is essentially: (spread of the curve centers) ÷ (average width of the curves).
If the three curves sit far apart relative to their widths, F is large and significant. If they overlap heavily, F is small.
17.4.11 Pitfalls
17.4.12 Student Q&A
17.4.13 Exam Guidance
17.4.14 Recap and Bridge
ANOVA compares three or more means with a single test. The F-statistic = between-group variation ÷ within-group variation. Large F → means differ. Next: what if your data is not means but counts in categories? That is the chi-square test.
17.4.15 Real-World & Domain Connection
Agricultural field trials at companies like Bayer (formerly Monsanto) use ANOVA daily. A typical trial tests 5–10 fertilizer formulations on separate plots, measuring crop yield. ANOVA determines whether any formulation outperforms the others. The same method is used in pharmaceutical dose-response studies (comparing 3+ dosage levels of a drug), industrial quality control (comparing output from multiple production lines), and marketing (comparing customer satisfaction across 4+ store formats). Anywhere you compare a numerical outcome across three or more categories, ANOVA is the default statistical tool.
17.5 Chi-Square Test of Independence
17.5.1 Hook — Are Smoking and Hypertension Related?
You survey 180 people. You record whether they smoke (non-smoker, moderate, heavy) and whether they have hypertension (yes, no). The data sits in a 3×2 grid of counts. The question: are smoking and hypertension independent, or are they associated? The chi-square test of independence answers this with a single number.
17.5.2 Intuition — The Seating Preference Analogy
On a flight, you record whether each passenger chose a window or aisle seat, and whether they are under 30 or over 30. If seat choice has nothing to do with age, then the proportion of window-choosers should be about the same in both age groups. Any difference is just random noise.
The chi-square test makes this precise. For each cell in the table, it computes an expected count — what you would see if the two variables were independent. Then it measures how far the observed counts are from these expected counts. A large total discrepancy → the variables are associated.
The analogy breaks when: expected counts are too small (less than 5). The chi-square approximation degrades, and you need Fisher's exact test instead.17.5.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| O_ij | observed frequency in cell (i,j) | integer | nonnegative |
| E_ij | expected frequency in cell (i,j) | scalar | positive |
| R_i | row total for row i | integer | nonnegative |
| C_j | column total for column j | integer | nonnegative |
| N | grand total | integer | positive |
| r | number of rows | integer | r ≥ 2 |
| c | number of columns | integer | c ≥ 2 |
| χ² | chi-square statistic | scalar | nonnegative |
| df | degrees of freedom = (r−1)(c−1) | integer | positive |
17.5.4 Mathematical Formulation
If smoking and hypertension are independent, the proportion of people with hypertension should be the same across all smoking categories. So for cell (i,j), multiply the row total by the column total and divide by the grand total. This gives the count you would expect under independence.
Chi-square statistic — measuring the discrepancy:For every cell: take observed minus expected, square it, divide by expected, and sum across all cells. The squaring makes all deviations positive. The division by E_ij scales the contribution — a deviation of 5 is more surprising when you expected 2 than when you expected 50.
Degrees of freedom: . Hypotheses:- H₀: The two variables are independent (no association)
- H₁: The two variables are not independent (there is an association)
There is no "one-tail vs. two-tail" confusion here. The chi-square distribution is not symmetric, and rejection is always on the right.
17.5.5 Worked Example — Hypertension and Smoking
| Smoking Status | Hypertension | No Hypertension | Row Total |
|---|---|---|---|
| Heavy Smokers | 21 | 48 | 69 |
| Moderate Smokers | 0 | 0 | 0 |
| Non-smokers | 66 | 45 | 111 |
| Column Total | 87 | 93 | 180 |
The "Moderate Smokers" row has zero observations in this dataset — no moderate smokers were sampled. The chi-square computation still includes this row, but its contribution is zero.
Step 1 — Compute expected frequencies:For Heavy Smokers × Hypertension:
For Heavy Smokers × No Hypertension:
For Non-smokers × Hypertension:
For Non-smokers × No Hypertension:
The Moderate Smokers row has expected values of zero (row total = 0).
Step 2 — Compute χ²:The professor stated χ² = 14.46. The small difference (about 0.11) is due to rounding in intermediate expected frequency calculations.
Step 3 — Find the critical value:df = (r−1)(c−1) = (3−1)(2−1) = 2. At α = 0.05, χ²_table = 5.99 from the chi-square table.
Step 4 — Decision:χ²_calculated ≈ 14.35 > χ²_table = 5.99 → Reject H₀.
There is a significant association between smoking status and hypertension. The variables are not independent.
Sense-check: Look at the data: 21/69 ≈ 30.4% of heavy smokers have hypertension, while 66/111 ≈ 59.5% of non-smokers have hypertension. These proportions are quite different — the test confirms this is unlikely under independence.17.5.6 The Universal Decision Rule
For all hypothesis tests — Z, t, F, chi-square — the rule is the same:
- calculated value < table value → do not reject H₀
- calculated value > table value → reject H₀
For chi-square: accepting H₀ means the variables are independent. Rejecting H₀ means they are associated (dependent). The professor emphasized: "If it falls here [left of critical], then accept. This is applicable to everything."
17.5.7 Assumptions and Scope
- Categorical variables. Both variables must be categorical (nominal or ordinal). If one variable is continuous, it must be binned first.
- Expected frequencies ≥ 5 per cell. This is a rule of thumb. If many cells have E_ij < 5, the chi-square approximation is unreliable — use Fisher's exact test.
- Independent observations. Each person contributes to exactly one cell. No repeated measures.
- The data are counts, not percentages. You need the raw frequencies.
17.5.8 Visual Intuition — The Observed vs. Expected Grid
Picture two 3×2 grids side by side. The left grid shows the observed counts — the raw data. The right grid shows the expected counts — what you would see if smoking and hypertension were independent.
In the observed grid, the Heavy Smokers cell for Hypertension reads "21." In the expected grid, the same cell reads "33.35." The difference (21 − 33.35 = −12.35) is the surprise — fewer heavy smokers have hypertension than independence would predict.
Now scan across all cells. In every cell, the observed count deviates from the expected by exactly ±12.35 (with opposite signs in opposite corners — this is a property of 2×2 sub-tables). The chi-square statistic aggregates these deviations across all cells. A large χ² means the two grids look very different; a small χ² means they look similar.
17.5.9 Pitfalls
17.5.10 Student Q&A
17.5.11 Exam Guidance
17.5.12 Recap and Bridge
Chi-square tests independence between two categorical variables. E_ij = (R_i × C_j)/N, χ² = Σ(O−E)²/E, df = (r−1)(c−1). Reject when calculated > table. Next: we leave hypothesis testing and enter time series — forecasting with exponential smoothing.
17.5.13 Real-World & Domain Connection
The CDC (Centers for Disease Control) uses chi-square tests extensively in epidemiological studies. The classic example is the 1950s studies linking smoking to lung cancer — chi-square tests on contingency tables established the association that launched modern public health policy. Today, the same test is used in clinical trials to compare adverse event rates across treatment arms, in marketing analytics to test whether purchase behavior is independent of demographic categories, and in A/B testing for conversion rates across multiple variants. Anywhere you have categorical outcomes in a table, chi-square is the first tool you reach for.
17.6 Simple Exponential Smoothing
17.6.1 Hook — Predicting Next Week's Sales
You have six weeks of sales data. Week 7 is coming. What is your best guess? You could take the simple average of all six weeks — but that treats week 1 and week 6 as equally informative. Surely last week matters more? Exponential smoothing gives you a knob — α — that controls how much you trust the latest observation versus the historical pattern.
17.6.2 Intuition — The Weather App Analogy
Your weather app says tomorrow will be 22°C. How does it make that forecast? It looks at today's actual temperature (say, 24°C) and yesterday's forecast for today (say, 21°C). It blends them: maybe 70% weight on what actually happened today and 30% on what it previously thought.
That is exponential smoothing. The smoothing constant α is the weight you put on the latest actual value. α = 0.8 means "trust today's reading a lot." α = 0.3 means "be cautious — the long-run average matters more."
The analogy breaks when: the data has an upward trend or seasonal pattern. Simple exponential smoothing only works for flat (stationary) series. For trend, you need double exponential smoothing (Holt's method).17.6.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| Y_t | actual value at time t | scalar | real |
| F_t | forecast for time t | scalar | real |
| F_{t+1} | forecast for next period | scalar | real |
| α | smoothing constant | scalar | [0, 1] |
| e_t = Y_t − F_t | forecast error at time t | scalar | real |
17.6.4 Mathematical Formulation
The forecast for tomorrow is a weighted average of today's actual value and today's forecast. The weights are α and (1−α), and they always sum to 1.
Expanding the recurrence — why it is called "exponential":The weights on past observations decay exponentially: α, α(1−α), α(1−α)², … The most recent observation gets weight α, the one before gets α(1−α), and so on. For α = 0.3, the weights are 0.3, 0.21, 0.147, 0.103, … — each step multiplies by 0.7.
Initialization: F₁ = Y₁. The first forecast equals the first actual value because you have no prior forecast to use. The professor emphasized: "First week we need to keep same value as the forecast." Choosing α:- α close to 1 → responsive but noisy (trusts latest data)
- α close to 0 → stable but sluggish (trusts history)
17.6.5 Worked Example — Weekly Forecasting
| Week | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Y_t | 112 | 118 | 125 | 132 | 138 | 144 | 142 |
| Week | Y_t | F_t | Computation |
|---|---|---|---|
| 1 | 112 | 112.00 | F₁ = Y₁ |
| 2 | 118 | 112.00 | 0.3×112 + 0.7×112.00 |
| 3 | 125 | 113.80 | 0.3×118 + 0.7×112.00 |
| 4 | 132 | 117.16 | 0.3×125 + 0.7×113.80 |
| 5 | 138 | 121.61 | 0.3×132 + 0.7×117.16 |
| 6 | 144 | 126.53 | 0.3×138 + 0.7×121.61 |
| 7 | — | 131.77 | 0.3×144 + 0.7×126.53 |
| Week | Y_t | F_t | Computation |
|---|---|---|---|
| 1 | 112 | 112.00 | F₁ = Y₁ |
| 2 | 118 | 112.00 | 0.8×112 + 0.2×112.00 |
| 3 | 125 | 116.80 | 0.8×118 + 0.2×112.00 |
| 4 | 132 | 123.36 | 0.8×125 + 0.2×116.80 |
| 5 | 138 | 130.27 | 0.8×132 + 0.2×123.36 |
| 6 | 144 | 136.45 | 0.8×138 + 0.2×130.27 |
| 7 | — | 142.49 | 0.8×144 + 0.2×136.45 |
The professor's slide data gave F₇ = 127.87 for α = 0.3 and F₇ = 139.26 for α = 0.8 with actual week 7 = 142. The procedure is identical; only the raw Y_t values differ.
Model comparison:| Model | F₇ | Actual Y₇ | Absolute Error |
|---|---|---|---|
| α = 0.3 | 127.87 | 142 | 14.13 |
| α = 0.8 | 139.26 | 142 | 2.74 |
17.6.6 Model Selection — Beyond One Forecast
You can formalize model comparison by computing forecast errors for all periods:
The model with the smaller Mean Squared Error (MSE) is better overall. This is more reliable than comparing a single forecast.
17.6.7 Assumptions and Scope
- No trend. The series should be roughly flat (stationary). If there is a consistent upward or downward trend, use double exponential smoothing (Holt's method).
- No seasonality. The series should not have regular seasonal patterns (e.g., higher in December every year). For seasonality, use Holt-Winters.
- α ∈ [0, 1]. Outside this range, the weights do not form a proper weighted average.
17.6.8 Visual Intuition — The Two Forecast Paths
Picture a time series plot: weeks 1–6 on the x-axis, values (Y_t) as blue dots connected by a blue line, rising from 112 to 144. Now overlay two forecast lines:
The orange line (α = 0.3) is smooth and sluggish — it starts at 112 and slowly drifts upward, always below the actual values. By week 6, it has only reached about 127. It is a cautious, slow-moving average.
The green line (α = 0.8) is jagged and responsive — it hugs the actual data closely, rising quickly when the series rises. By week 6, it sits near 136, much closer to the actual 144.
The vertical gap at week 7 between the forecast and the actual (142) tells the story: the green line is much closer. Higher α wins when the series has momentum.
17.6.9 Pitfalls
17.6.10 Student Q&A
17.6.11 Exam Guidance
17.6.12 Recap and Bridge
Simple exponential smoothing blends the latest observation with the previous forecast. Higher α trusts the latest data more. It works for flat series without trend or seasonality. Next: what if a time series has no pattern at all? That is white noise — and you should not try to forecast it.
17.6.13 Real-World & Domain Connection
Amazon's inventory management systems use exponential smoothing to forecast demand for millions of products. Fast-moving electronics (like a new iPhone case) get high α values — the model reacts quickly to demand spikes. Stable grocery items (like canned beans) get low α values — the model smooths out random fluctuations. Walmart and Target use similar systems. The choice of α is automated through optimization: the system tries many α values and picks the one that minimizes historical forecast error. This is the same logic you use when comparing α = 0.3 vs. α = 0.8 — just scaled to millions of products.
17.7 Autocorrelation and White Noise
17.7.1 Hook — Can You Predict This?
Here is a sequence: 3, 2, 1, 0, −1, −2, −1, 0, 1, 2, 3. Can you predict the next number? You probably can — it follows a pattern (it went down, then up). Now imagine TV static. Each pixel's brightness is random. No matter how long you stare, the next pixel is unpredictable. That second sequence is white noise. If your data is white noise, stop trying to forecast it — there is nothing to model.
17.7.2 Intuition — The TV Static Analogy
Tune your TV to a dead channel. The flickering "snow" on the screen is white noise. It has three properties. (1) The average brightness is neutral gray — mean zero if we center it. (2) The intensity of the flickering stays constant over time — constant variance. (3) Knowing the brightness of one pixel tells you nothing about the next pixel — no autocorrelation.
In time series terms, a white noise series is the residual left over after you have extracted all the signal — trend, seasonality, cycles. If your forecast errors look like white noise, you have captured everything. If they show a pattern, your model is missing something.
The analogy breaks when: real-world "white noise" is an idealization. Physical processes always have some tiny correlation at very short lags. But for statistical purposes, if the autocorrelation is within the ±2/√T confidence band, the series is effectively white noise.17.7.3 Definition — Autocorrelation
Regular correlation measures the relationship between two different variables (X and Y). Autocorrelation measures the relationship between X at time t and X at time t+k — the same variable, separated by k time steps.
For lag k = 1: are adjacent values correlated? For lag k = 2: are values two steps apart correlated? And so on.
Autocovariance is the same idea applied to covariance. Autocorrelation = autocovariance divided by variance:17.7.4 Definition — White Noise
A time series is white noise if it satisfies three conditions:
- Mean = 0. The series fluctuates around zero. If the mean is nonzero, subtract it first — the resulting series should be white noise.
- Constant variance. The spread of the values does not grow, shrink, or oscillate over time. Formally, for all t.
- No autocorrelation. for all lags k ≥ 1. Knowing X_t gives you zero information about X_{t+1}, X_{t+2}, or any future value.
If a time series has any detectable pattern, trend, or correlation across time, it is not white noise.
The professor summarized: "Time series without autocorrelation — we call it white noise. Mean zero, constant variance, and no pattern, then it is white noise."
17.7.5 Why White Noise Matters
If a time series is white noise, it cannot be forecast. There is no structure to model — the best forecast for all future periods is simply zero (or the series mean). Identifying white noise prevents you from wasting time and resources trying to predict the unpredictable. In practice, you check whether your model's residuals (forecast errors) are white noise. If they are, your model has extracted all available signal.
17.7.6 Worked Example — Is This White Noise?
The mean is close to zero but not exactly zero. For practical purposes with a longer series, we could center it. But the pattern check will be decisive regardless.
Check 2 — Constant variance?With the mean about zero, each deviation X_i − X̄ ≈ X_i. The squared values are 9, 4, 1, 0, 1, 4, 1, 0, 1, 4, 9. The variance is roughly constant — the series does not show increasing or decreasing spread over time. (The professor assessed this visually in class; a formal test like the Breusch-Pagan test would be used in practice.)
Check 3 — No pattern?Look at the sequence: it decreases from 3 to −2, then increases back to 3. This is a clear V-shaped pattern. There is structure — you can predict the next value from the trend. ✗
Conclusion: This series has a pattern and is not white noise. Even though it passes the mean and variance checks about, the autocorrelation check fails decisively. You can see the pattern by eye. Sense-check: If this were white noise, the sequence 3,2,1,0,−1 would be just as likely as 3,−1,2,−2,0. But the first sequence shows clear decreasing order — that is autocorrelation.17.7.7 Formal White Noise Test — The Confidence Band
A more formal approach uses the autocorrelation function (ACF). For a white noise series of length T, about 95% of the sample autocorrelations should fall within:
For T = 100, the band is ±0.2. For T = 25, the band is ±0.4.
If more than 5% of the autocorrelation spikes fall outside this band — or if any single spike is far outside — the series is likely not white noise. The professor described this as: "We calculate plus or minus 2 by root T where T is the length of the time series."
17.7.8 Assumptions and Scope
- The ±2/√T rule is approximate. It works for large T. For small T, the band is wider, and formal tests (Ljung-Box) are more reliable.
- White noise ≠ independent. White noise requires zero correlation. It does not require independence — there could be nonlinear dependence (e.g., squared values are correlated) while linear correlation is zero. Financial returns often show this pattern.
- Gaussian white noise adds the assumption of normality. This is the strictest form.
17.7.9 Visual Intuition — The ACF Plot
Picture a bar chart. The x-axis shows lag k = 1, 2, 3, …, 10. The y-axis shows autocorrelation from −1 to +1. Two horizontal dashed lines sit at +2/√T and −2/√T — the confidence band.
For a white noise series, most bars are short — they hover near zero, with maybe one or two poking slightly above the band by random chance. The plot looks like a city skyline after an earthquake — everything flattened.
For a non-white-noise series, the first few bars are tall. Lag 1 might be 0.8, lag 2 might be 0.6, lag 3 might be 0.4 — they decay gradually. This is the signature of autocorrelation: today's value is highly predictive of tomorrow's.
17.7.10 Pitfalls
17.7.11 Student Q&A
17.7.12 Exam Guidance
17.7.13 Recap and Bridge
White noise = mean zero + constant variance + no autocorrelation. If your series is white noise, you cannot forecast it — there is no signal to extract. In practice, you test whether your model residuals are white noise to confirm you have captured all the structure. Next: a completely different topic — Gaussian Mixture Models, where we model data as coming from multiple overlapping normal distributions.
17.7.14 Real-World & Domain Connection
Bose and Sony noise-canceling headphones use white noise characterization at their core. The headphones have microphones that sample ambient sound. The noise is modeled as a stochastic process. If the ambient noise is about white (equal energy across all frequencies), the noise-canceling circuitry generates an inverted signal that is straightforward to compute. In finance, testing whether stock returns are white noise is a fundamental check — if returns were predictable (not white noise), arbitrage opportunities would exist. The efficient market hypothesis essentially claims that asset returns should be white noise (or close to it) after adjusting for risk. In signal processing, white noise is the null model: any deviation from white noise indicates a signal worth extracting.
17.8 Gaussian Mixture Models
17.8.1 Hook — When One Bell Curve Is Not Enough
You measure the heights of everyone in a shopping mall. Plot a histogram. You expect one bell curve — but you see two humps. One around 165 cm, another around 178 cm. Men and women are mixed in your data, and their heights follow different distributions. A single Gaussian cannot capture this. A Gaussian Mixture Model (GMM) can — it models your data as a weighted blend of two (or more) bell curves.
17.8.2 Intuition — The Cauvery River Analogy (Professor's Own)
Imagine the border region between Tamil Nadu and Karnataka — a hilly, forested area where the boundary is unclear. Each state is like a Gaussian cluster: its villages cluster around a center, with some spread into the periphery.
When an incident happens in the border hills, whose jurisdiction does it fall under? You cannot draw a hard line. Instead, you compute the probability that the incident belongs to Tamil Nadu versus Karnataka, based on how far it is from each state's center — adjusted for how spread out each state's villages are. You assign it to the higher probability.
This is exactly what GMM classification does. Each Gaussian is a "state," and new data points get a probabilistic assignment — not a hard yes/no.
The analogy breaks when: the clusters have very different sizes (mixing coefficients). A tiny cluster might still claim points near its center, but a large cluster has more "pull" through its higher prior probability.17.8.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| π_k | mixing coefficient for component k | scalar | [0, 1], Σπ_k = 1 |
| μ_k | mean of component k | scalar | real |
| σ_k² | variance of component k | scalar | positive real |
| 𝒩(X∣μ,σ²) | Gaussian (normal) PDF evaluated at X | scalar | positive real |
| n_k | number of points in cluster k | integer | positive |
| N | total number of data points | integer | positive |
17.8.4 Mathematical Formulation
where each component is a normal PDF:
This is a weighted sum of bell curves. The mixing coefficients π_k tell you how much each bell curve contributes to the overall distribution. They must satisfy:
Mixing coefficients — the prior probability:If cluster 1 has 5 points and there are 10 total, then π₁ = 0.5. This is the prior probability that a randomly chosen point belongs to cluster k — before you see the point's value.
17.8.5 Worked Example — Two-Cluster GMM
This is the complete model. For any X, plug it in and get the mixture density.
17.8.6 Classifying a New Point — Bayes Theorem
where P(X) is the GMM PDF from Step 3 (the total probability, serving as the normalizing denominator).
Compute the numerator for GC1 at X = 6.5:
Compute the numerator for GC2 at X = 6.5:
Conclusion: X = 6.5 belongs to GC2 with 93.9% probability. Sense-check: X = 6.5 is 2.4 units from μ₁ = 4.1 (about 3.7 standard deviations away) but only 2.5 units from μ₂ = 9.0 (about 2.7 standard deviations away). GC2 is the more likely source — even though 6.5 is numerically closer to 4.1, the smaller variance of GC1 makes 6.5 an extreme outlier for that cluster.17.8.7 Assumptions and Scope
- Data comes from K Gaussian components. If the true clusters are non-Gaussian (e.g., moon-shaped, ring-shaped), GMM will fit ellipsoidal blobs that may not match the data.
- K is known or chosen. In exam problems, K is given. In practice, you choose K using BIC, AIC, or cross-validation.
- Soft clustering. Points have partial membership in all clusters. If you need hard assignments, you can take the cluster with the highest posterior probability.
17.8.8 Visual Intuition — Two Overlapping Bell Curves
Picture two bell curves on the same x-axis. The left curve (GC1) is tall and narrow — centered at 4.1 with a tight spread (σ₁² = 0.425). The right curve (GC2) is shorter and wider — centered at 9.0 with a broader spread (σ₂² = 0.845).
The curves overlap slightly around X = 6 to 7 — this is the "border region." A point at X = 6.5 sits in the right tail of GC1 and the left tail of GC2. Both curves have nonzero density there, but GC2's density is higher because GC1 drops off very sharply (small variance).
The mixing coefficients (both 0.5) mean the two curves are equally tall before scaling. If π₁ were 0.9 and π₂ were 0.1, the left curve would dominate the picture — most points come from GC1, and you would need strong evidence to assign a point to GC2.
17.8.9 Pitfalls
17.8.10 Student Q&A
17.8.11 Exam Guidance
17.8.12 Recap and Bridge
A GMM models data as a weighted sum of Gaussian components. π_k = n_k/N is the prior weight. Classify new points by computing P(GC_k ∣ X) using Bayes theorem — the cluster with the highest posterior probability wins. Next: we step back to basics — how do two variables move together? That is covariance and correlation.
17.8.13 Real-World & Domain Connection
Spotify uses GMMs to model song attributes for genre classification and recommendation. A song's audio features (tempo, energy, danceability, acousticness) are treated as coming from a mixture of Gaussian components — each component representing a genre or sub-genre. A new song gets a probabilistic assignment: "70% pop, 20% dance, 10% hip-hop." This soft classification feeds into recommendation algorithms. The same approach is used in speaker diarization — identifying who is speaking in a multi-person conversation. It is used in customer segmentation in marketing for overlapping behavior patterns. It is also used in anomaly detection in manufacturing — points with low probability under the GMM are flagged as potential defects. The Cauvery River analogy from the professor captures the essence: when boundaries blur, soft classification via Bayes theorem is the right tool.
17.9 Covariance and Correlation
17.9.1 Hook — Do Two Stocks Move Together?
You hold Apple and Microsoft stock. When Apple goes up, does Microsoft tend to go up too? By how much? And how tightly do they move together? Two numbers answer these questions: covariance gives the direction of the relationship; correlation gives both direction and strength on a standardized scale.
17.9.2 Intuition — The Two-Stock Analogy
Covariance is like knowing two dancers move in the same direction — when one steps forward, the other steps forward. But you do not know if they are doing a tight tango (every step perfectly synchronized) or a loose shuffle (they both drift forward but at different times and rates).
Correlation is the tango score. It takes the covariance and divides by how much each dancer waves their arms independently. A correlation of +1 means perfect lockstep. A correlation of 0 means their movements are unrelated. A correlation of −1 means they move in perfect opposition.
The analogy breaks when: the relationship is nonlinear. Two dancers doing a circular waltz have a strong relationship, but correlation (which measures linear association) might be near zero. Correlation only catches straight-line patterns.17.9.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| Cov(X,Y) | covariance between X and Y | scalar | real |
| r or ρ | correlation coefficient | scalar | [−1, 1] |
| X̄ | mean of X | scalar | real |
| Ȳ | mean of Y | scalar | real |
| σ_X | standard deviation of X | scalar | positive real |
| σ_Y | standard deviation of Y | scalar | positive real |
| n | number of data points | integer | n ≥ 2 |
17.9.4 Mathematical Formulation
For each data point, compute how far X is from its mean, and how far Y is from its mean. Multiply those deviations. If X and Y tend to be on the same side of their means together, the product is positive. If they tend to be on opposite sides, the product is negative. Sum and divide by n−1.
The professor described it simply: "X minus X bar into Y minus Y bar — it is very simple."
Correlation — standardized strength:Divide the covariance by the product of the two standard deviations. This strips away the units and scales the result to [−1, 1].
- r = +1: perfect positive linear relationship
- r = −1: perfect negative linear relationship
- r = 0: no linear relationship
- 0 < |r| < 0.3: weak
- 0.3 ≤ |r| < 0.7: moderate
- |r| ≥ 0.7: strong
17.9.5 Worked Example — Interpreting the Numbers
The positive sign tells you the stocks move in the same direction. When X's return is above its average, Y's return tends to be above its average too. But the magnitude 1.254 does not tell you how strong the relationship is — it depends on the units of X and Y (e.g., dollars vs. percentages).
Inference from correlation (+0.84):The stocks are strongly positively related. A correlation of 0.84 is close to +1. If X is one standard deviation above its mean, Y tends to be about 0.84 standard deviations above its mean.
The professor emphasized: "Covariance helps us understand they are positively related. But how much relation exists — we cannot say from covariance. Correlation tells us they are positively related and also strongly related."
17.9.6 The Key Distinction — Direction vs. Strength
| Property | Covariance | Correlation |
|---|---|---|
| Sign (direction) | ✓ | ✓ |
| Magnitude (strength) | ✗ (units-dependent) | ✓ (unitless) |
| Range | (−∞, +∞) | [−1, +1] |
| Comparable across datasets | ✗ | ✓ |
Covariance = direction only. Correlation = direction + strength.
17.9.7 Assumptions and Scope
- Linear relationship only. Both covariance and correlation measure linear association. A perfect U-shaped relationship can have r ≈ 0. Always plot your data first.
- Sensitive to outliers. A single extreme point can dramatically inflate or deflate the correlation coefficient. Spearman's rank correlation is a strong alternative.
- Correlation does not imply causation. r = 0.84 between ice cream sales and drowning deaths does not mean ice cream causes drowning. Both are driven by summer weather.
17.9.8 Visual Intuition — The Scatter Plot Gallery
Picture four scatter plots, each with X on the horizontal axis and Y on the vertical:
Plot 1 (r ≈ +1): Points form a tight upward-sloping line. As X increases, Y increases almost perfectly. Like height vs. weight for adults. Plot 2 (r ≈ −1): Points form a tight downward-sloping line. As X increases, Y decreases almost perfectly. Like speed vs. travel time for a fixed distance. Plot 3 (r ≈ 0): Points form a shapeless cloud. No discernible upward or downward trend. Like shoe size vs. IQ. Plot 4 (r ≈ 0 but related): Points form a perfect U-shape. Y is high when X is very low or very high, and low in the middle. r ≈ 0 despite the perfect relationship — correlation misses nonlinear patterns.17.9.9 Pitfalls
17.9.10 Student Q&A
17.9.11 Exam Guidance
17.9.12 Recap and Bridge
Cov(X,Y) tells you whether two variables move together or apart. r = Cov/(σ_X·σ_Y) standardizes this to [−1, +1], giving both direction and strength. Next: we take the final step — fitting a straight line through scattered data with linear regression.
17.9.13 Real-World & Domain Connection
Bloomberg Terminal's portfolio analytics are built on covariance and correlation matrices. A portfolio manager holding 50 stocks needs to know how they move together. The 50×50 correlation matrix captures every pairwise relationship. Modern Portfolio Theory (Markowitz, 1952) uses these matrices to construct portfolios that maximize expected return for a given level of risk. The core insight: diversification works because assets are not perfectly correlated. If all stocks had r = +1, diversification would be pointless. In finance, a correlation of 0.3 between two assets is considered excellent for diversification purposes. The same mathematics drives weather forecasting (correlation between atmospheric pressure at different locations), genomics (co-expression of genes), and recommendation systems (correlation between user preferences).
17.10 Linear Regression
17.10.1 Hook — What Is the Price of a House?
You know the square footage of a house. You want to predict its price. You have data on 10 recent sales: size and price for each. How do you draw the best straight line through those 10 points — and then use it to price an 11th house? Linear regression answers this.
17.10.2 Intuition — Drawing the Best Line
Imagine throwing 10 darts at a wall. They scatter in a rough upward-sloping pattern — bigger houses cost more. You take a ruler and draw a straight line through the cloud. Some darts are above the line, some below. You wiggle the ruler until the total squared vertical distance from darts to line is as small as possible.
That is linear regression. The line Ŷ = W₀ + W₁X is your ruler. W₀ is where it hits the Y-axis (the price when square footage is zero — the land value). W₁ is the slope (how much extra price you get per extra square foot).
The analogy breaks when: the true relationship is curved. If price increases faster for large houses than small ones, a straight line will systematically under-predict in some ranges and over-predict in others. That calls for polynomial regression or a transformation.17.10.3 Symbols
| Symbol | Meaning | Type | Domain |
|---|---|---|---|
| W₀ | intercept | scalar | real |
| W₁ | slope | scalar | real |
| X | independent (predictor) variable | scalar | real |
| Y | dependent (response) variable | scalar | real |
| Ŷ | predicted Y = W₀ + W₁X | scalar | real |
| n | number of data points | integer | n ≥ 2 |
17.10.4 Mathematical Formulation — The Normal Equations
The goal is to find W₀ and W₁ that minimize the sum of squared errors:
Taking derivatives with respect to W₀ and W₁ and setting to zero gives the normal equations:
This is a 2×2 system of linear equations. Solve for W₀ and W₁.
Procedure:- Build a table: X, Y, X², XY
- Compute ΣX, ΣY, ΣX², ΣXY
- Plug into the two normal equations
- Solve for W₀ and W₁
- Write the fitted line: Ŷ = W₀ + W₁X
- Use for prediction: plug in a new X
The professor described it as: "Taking summation over the first equation gives sum Y equals n W naught plus W1 sum X. Multiplying the first equation by X and summing gives sum XY equals W naught sum X plus W1 sum X squared."
17.10.5 Worked Example — Predicting Y from X
| X | Y | X² | XY |
|---|---|---|---|
| 1 | 2 | 1 | 2 |
| 2 | 4 | 4 | 8 |
| 3 | 5 | 9 | 15 |
| 4 | 4 | 16 | 16 |
| 5 | 5 | 25 | 25 |
From equation (1):
Substitute into (2):
Then:
Fitted line: Prediction for X = 6: Sense-check: When X increases by 1, Y increases by 0.6 on average. The line starts at 2.2 when X = 0. For X = 3, prediction is 2.2 + 1.8 = 4.0 — the actual Y is 5, so the error is +1. The line goes through the middle of the data, not through every point.17.10.6 Assumptions and Scope
- Linear relationship. Y is about a linear function of X. Plot the data first.
- Independent errors. The error for one observation does not depend on errors for others.
- Homoscedasticity. The spread of errors is roughly constant across all values of X (no fanning out).
- Normality of errors (for inference). For prediction alone, this is not required. For hypothesis tests on W₀ and W₁, errors should be about normal.
17.10.7 Visual Intuition — The Scatter and the Line
Picture a scatter plot: X runs from 1 to 5 on the horizontal axis, Y runs from 2 to 5 on the vertical. Five blue dots trace a rough upward path: (1,2), (2,4), (3,5), (4,4), (5,5). They do not lie on a perfect line — there is scatter.
Now overlay a red line: Ŷ = 2.2 + 0.6X. At X = 1, the line is at 2.8 (above the dot at 2). At X = 2, the line is at 3.4 (below the dot at 4). At X = 3, the line is at 4.0 (below the dot at 5). At X = 4, the line is at 4.6 (above the dot at 4). At X = 5, the line is at 5.2 (above the dot at 5).
The vertical gaps between dots and line are the residuals. Some are positive, some negative. They sum to zero (a property of least squares). The line is the single best straight-line summary of the five points.
17.10.8 Pitfalls
17.10.9 Student Q&A
17.10.10 Exam Guidance
17.10.11 Recap and Bridge
Linear regression fits Ŷ = W₀ + W₁X by solving two normal equations. The table method (X, Y, X², XY) keeps you organized. The slope W₁ is the predicted change in Y per unit increase in X. Use the fitted line for prediction — but never extrapolate far beyond your data. This closes our tour of the lecture's core concepts.
17.10.12 Real-World & Domain Connection
Zillow's Zestimate is powered by regression models. The core model regresses sale price on square footage, number of bedrooms, number of bathrooms, lot size, location score, and year built. Each coefficient (W₁, W₂, …) represents the marginal value of that feature — for example, W_bedroom ≈ $15,000 means an extra bedroom adds about $15,000 to the predicted price, holding everything else constant. The model is continuously retrained on millions of recent sales. The normal equations you solve with n = 5 scale directly to n = 5,000,000 — the math is identical, just solved by a computer instead of by hand. In every domain where a numerical outcome needs to be predicted from features — house prices, crop yields, customer lifetime value, energy consumption — linear regression is the baseline model that more complex models must beat.
Exam Guidance Summary
Topic Weightage
- Post-midterm topics form the bulk of the comprehensive exam.
- Pre-midterm carryover: about 10–15%. The most likely pre-midterm topics to appear are joint distributions and interval estimation. Both discrete and continuous joint distributions are possible. The mid-semester exam had a continuous joint distribution problem, so discrete may appear this time.
Study Time Guide by Topic
| Topic | Difficulty | Study Time | Key Focus |
|---|---|---|---|
| Model identification | Tricky (conceptual) | 30 min | Walk the decision tree with every problem type |
| Hypothesis testing (Z, t, proportions) | Moderate | 30 min | Formula review; one-tail vs. two-tail |
| ANOVA | Moderate (calculation-heavy) | 20 min | Practice one full problem: SSTR, SSE, F, table |
| Chi-square | Easy (formula substitution) | 10 min | Identification is the only challenge |
| Exponential smoothing | Easy (formula substitution) | 10 min | F₁ = Y₁; compare α values |
| White noise | Easy (conceptual) | 5 min | Three conditions: μ=0, constant σ², no pattern |
| GMM | Moderate | 30 min | μ, σ², π_k, PDF, Bayes classification |
| Covariance & correlation | Easy (formula substitution) | 10–15 min | Direction vs. strength inference |
| Regression | Easy (formula substitution) | 10–15 min | Table method, solve 2 equations, predict |
| MLE | Moderate | 30 min | Figuring out P(X) and differentiating |
| Double exponential smoothing | Moderate | — | Part of time series review |
Study Strategy
- Hypothesis testing is the largest and most confusing block. Spend the most time on model identification — which test to use when. If you pick the wrong test, everything else is wrong.
- ANOVA and chi-square are new additions. Make sure you can identify and compute both.
- Time series, GMM, covariance/regression are formula-driven. Go through the slides, substitute values, practice one problem each.
- Total revision time for all post-midterm topics: about 2–3 hours.
What to Expect in the Exam
- Tables (Z, t, F, chi-square) will be provided.
- A formula cheat sheet was mentioned — confirm availability on the course portal.
- Slides for ANOVA, chi-square, and GMM classification (newer content) will be uploaded separately.
- Show all your work. In an open-book setting, writing the formula and showing substitution may be expected. In previous exams, evaluators focused more on the final answer, but this may change.
Key Formulas at Your Fingertips
| Test | Formula |
|---|---|
| One-sample Z/t | or |
| Two-sample Z/t | |
| Paired t | |
| ANOVA F | |
| Chi-square | |
| Exp. smoothing | |
| Covariance | |
| Correlation | |
| Regression | |
| GMM PDF | |
| GMM classification |
Key Industry Applications
The methods covered in this lecture power statistical decision-making across industries. Here is where each technique is used in production:
- A/B testing (Netflix, Amazon, Google): The model identification decision tree is the backbone of experimentation platforms. Data scientists walk the same tree — means or proportions, one sample or two, large sample → Z-test — to determine whether a new recommendation algorithm, UI change, or pricing strategy improves results. Millions of experiments run on this logic daily.
- Pharmaceutical clinical trials (Pfizer, Moderna): Paired t-tests measure within-subject changes — antibody levels before and after vaccination, blood pressure before and after medication. The paired design controls for individual variability and is the gold standard for demonstrating treatment efficacy to regulators like the FDA.
- Agricultural field trials (Bayer/Monsanto): ANOVA compares crop yields across multiple fertilizer formulations, seed varieties, or irrigation methods. A single ANOVA replaces dozens of pairwise t-tests, preserving the 5% error rate. The results determine which products go to market.
- CDC epidemiological studies: Chi-square tests of independence screen for associations between lifestyle factors and health outcomes — smoking status vs. hypertension, diet vs. diabetes, exercise frequency vs. heart disease. A significant chi-square triggers deeper investigation and potential public health interventions.
- Amazon inventory forecasting: Exponential smoothing with tuned α values powers demand forecasting. Fast-moving electronics get α ≈ 0.8 (responsive to trends). Stable grocery items get α ≈ 0.3 (smooths out noise). The α values are optimized continuously from historical forecast errors.
- Bose noise-canceling headphones: White noise characterization in signal processing enables effective active noise cancellation. The ambient sound is modeled as a stochastic process; identifying the white noise component allows the circuitry to generate precise anti-noise signals.
- Spotify audio feature clustering: GMMs model song attributes (tempo, energy, danceability) as mixtures of Gaussian components. Each component represents a genre or sub-genre. New songs get soft genre assignments that feed into recommendation and playlist generation algorithms.
- Bloomberg Terminal portfolio analytics: Covariance and correlation matrices are computed for thousands of assets in real time. Modern Portfolio Theory uses these matrices to construct diversified portfolios — the core insight being that assets with low correlation reduce overall portfolio risk without sacrificing expected return.
- Zillow Zestimate: Multiple regression on square footage, bedrooms, bathrooms, location, and year built predicts property values for over 100 million homes. Each coefficient represents the marginal contribution of a feature to the predicted price — the same normal equations you solve by hand for n = 5 data points, scaled to n = 100,000,000.
ISM Lecture 17 notes · Hypothesis Testing Review, ANOVA, Chi-Square, Time Series, and GMM
Sections Breakdown
Decision tree for choosing the correct hypothesis test based on problem language and keywords.
Testing a single population mean when n < 30 and population standard deviation is unknown.
Comparing before-and-after measurements on the same subjects using difference scores D = Y − X.
Comparing means across three or more groups using the F-statistic and between-vs-within variation decomposition.
Testing association between two categorical variables using observed and expected frequency counts.
Time series forecasting blending latest observation with previous forecast via smoothing constant α.
Identifying whether a time series has detectable structure or is pure unpredictable random noise.
Modeling data as weighted sum of Gaussian distributions with soft classification via Bayes theorem.
Measuring direction and strength of linear relationships between two variables.
Fitting a best-fit straight line using normal equations derived from minimizing squared errors.
Exam Revision Notes
Below is the distilled, exam-ready core of this lecture. Every entry is built from the full textbook notes above. Use this section for rapid review — but if something doesn't make sense, go back to the full explanation in the main content.
Model Identification Framework
Must-know: Walk the decision tree: means vs proportions, then one/two/many, then large/small sample. Picking the wrong model invalidates everything that follows.
⚠️ Top pitfall: Running multiple t-tests instead of one ANOVA for three or more groups inflates Type I error to ~0.14 instead of 0.05.
Self-check: A problem says three fertilizers were tested on separate plots and crop yields were recorded. Which test do you use?
Connects to: One-Sample t-Test, Paired t-Test, ANOVA, Chi-Square Test
One-Sample t-Test
Must-know: Use when n < 30 and σ is unknown. t = (X̄ − μ₀) / (s / √n), df = n − 1. Look up the t-table critical value, not the Z-table.
⚠️ Top pitfall: Using the Z-table (critical value 1.645) instead of the t-table (critical value ≈1.833 for df = 9, α = 0.05) gives false confidence for small samples.
Self-check: You test 10 cars. Sample mean = 18,686, claimed mean = 18,580, s = 167.74. What is the t-statistic?
Connects to: Paired t-Test, Model Identification Framework
Paired t-Test
Must-know: Same subjects measured twice. Compute D = Y − X for each pair, then run a one-sample t-test on the differences. H₀: μ_D = 0 (no effect).
⚠️ Top pitfall: Using a two-sample t-test on paired data loses the within-person correlation and drastically reduces statistical power.
Self-check: 9 trainees had before/after scores measured. Is this a paired or two-sample problem?
Connects to: One-Sample t-Test, Model Identification Framework
One-Way ANOVA
Must-know: Compare 3+ group means with a single test. F = MSTR/MSE = (SSTR/(k−1)) / (SSE/(N−k)). Reject if F_calculated > F_table. Always right-tailed.
⚠️ Top pitfall: Using the wrong df in the F-table. Numerator df = k − 1, denominator df = N − k. Both are required for lookup.
Self-check: Three teaching methods, k = 3, N = 10. What are numerator and denominator degrees of freedom?
Connects to: Model Identification Framework, Chi-Square Test
Chi-Square Test of Independence
Must-know: Tests independence of two categorical variables. E_ij = (R_i × C_j) / N, χ² = Σ(O−E)²/E, df = (r−1)(c−1). H₀ is always independence.
⚠️ Top pitfall: Forgetting df = (r−1)(c−1). A 3×2 table has df = 2, not df = 3×2 = 6.
Self-check: A 3×2 contingency table has N = 180. What is the degrees of freedom?
Connects to: ANOVA, Model Identification Framework
Simple Exponential Smoothing
Must-know: Forecast blends latest observation with previous forecast. F_{t+1} = α·Y_t + (1−α)·F_t. Higher α = more responsive to recent data. Initialize F₁ = Y₁.
⚠️ Top pitfall: Forgetting F₁ = Y₁ for initialization. Setting the first forecast to zero or an arbitrary value biases all early forecasts.
Self-check: For α = 0.8, what weight does the latest observation get in the forecast? What about α = 0.3?
Connects to: White Noise, Linear Regression
White Noise and Autocorrelation
Must-know: White noise = mean zero + constant variance + no autocorrelation. If a series is white noise, it cannot be forecast — there is no signal to extract.
⚠️ Top pitfall: Judging white noise by eye alone. A series can look random but have subtle autocorrelation. Use the ±2/√T confidence band for formal assessment.
Self-check: A time series 3, 2, 1, 0, −1, −2, −1, 0, 1, 2, 3 has mean near zero. Is it white noise?
Connects to: Simple Exponential Smoothing, Linear Regression
Gaussian Mixture Models
Must-know: Models data as weighted sum of K Gaussians. π_k = n_k / N. Classify new points via Bayes theorem: P(GC_k|X) = π_k · N(X | μ_k, σ_k²) / P(X).
⚠️ Top pitfall: Forgetting to normalize when classifying. P(GC₁ | X) + P(GC₂ | X) must equal 1 — divide by the total probability P(X).
Self-check: A GMM has two clusters with 5 points each. What are the mixing coefficients π₁ and π₂?
Connects to: Covariance and Correlation, Linear Regression
Covariance and Correlation
Must-know: Covariance gives the direction of linear relationship (sign only). Correlation = Cov/(σ_X · σ_Y) standardizes to [−1, +1], giving both direction and strength. |r| ≥ 0.7 is strong.
⚠️ Top pitfall: Interpreting covariance magnitude as strength. Cov = 100 does not mean strong — only correlation is unitless and comparable across datasets.
Self-check: Cov(X,Y) = 1.254 and r = 0.84. What does each number tell you about the relationship?
Connects to: Linear Regression, Gaussian Mixture Models
Linear Regression
Must-know: Fit the best line via normal equations. Use the table method: compute ΣX, ΣY, ΣX², ΣXY, then solve the 2×2 system for W₀ (intercept) and W₁ (slope).
⚠️ Top pitfall: Extrapolating far beyond the data range. If X ranges from 1 to 5, predicting Y at X = 100 assumes the linear relationship continues — it probably does not.
Self-check: Given ΣX = 15, ΣY = 20, ΣX² = 55, ΣXY = 66, n = 5. Write and solve the two normal equations for W₀ and W₁.
Connects to: Covariance and Correlation, Simple Exponential Smoothing
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.