Inferential Statistics推断统计
IB Mathematics: Applications and Interpretation, 2021 sub-topics SL 4.10 and SL 4.11 (SL and HL) and AHL 4.15, 4.16 and 4.18 (HL only). Spearman's rank correlation, hypothesis testing with chi-squared and t-tests, the central limit theorem, confidence intervals, critical regions and type I and II errors.
IB 数学:应用与解释(Applications and Interpretation),2021 子主题 SL 4.10 与 SL 4.11(SL 与 HL 共同)以及 AHL 4.15、4.16、4.18(仅 HL)。覆盖斯皮尔曼等级相关(Spearman's rank correlation)、卡方检验与 t 检验(hypothesis testing)、中心极限定理(central limit theorem)、置信区间(confidence interval)、拒绝域以及第一、二类错误。
Unit Cram Cheat-Sheet单元速记小抄
Core (SL 4.10, 4.11; SL and HL):核心内容(SL 4.10、4.11;SL 与 HL 共同):
$$ r_s = \text{Pearson's } r \text{ applied to the ranks} \qquad \left( r_s = 1 - \frac{6\sum d^2}{n(n^2-1)} \text{ when there are no ties} \right) $$ $$ \chi^2_{calc} = \sum \frac{(f_o - f_e)^2}{f_e} \qquad f_e = \frac{\text{row total} \times \text{column total}}{\text{grand total}} $$ $$ \text{Independence: } \nu = (r-1)(c-1) \qquad \text{Goodness of fit: } \nu = k - 1 - (\text{number of estimated parameters}) $$ $$ \text{Decision: } p\text{-value} < \alpha \Rightarrow \text{reject } H_0; \quad p\text{-value} \ge \alpha \Rightarrow \text{do not reject } H_0 $$HL only (AHL 4.15, 4.16, 4.18):仅 HL(AHL 4.15、4.16、4.18):
$$ \bar{X} \sim N\!\left(\mu, \frac{\sigma^2}{n}\right) \text{ (approximately, for large } n\text{)} \qquad \bar{x} \pm z^{*}\frac{\sigma}{\sqrt{n}} \qquad \bar{x} \pm t^{*}\frac{s_{n-1}}{\sqrt{n}} $$ $$ P(\text{type I}) = P(\text{reject } H_0 \mid H_0 \text{ true}) \qquad P(\text{type II}) = P(\text{do not reject } H_0 \mid H_1 \text{ true}) $$Decision tree: two categorical variables in a table → chi-squared test for independence; one variable against a claimed distribution → goodness of fit; two independent means from normal populations → two-sample t-test; monotonic association in ranked or skewed data → Spearman.
关键词决策树:表格中两个分类变量 → 卡方独立性检验(chi-squared test for independence);一个变量与某个声称的分布比较 → 拟合优度检验(goodness of fit);来自正态总体的两个独立样本均值 → 双样本 t 检验(t-test);有序或偏态数据中的单调关系 → 斯皮尔曼(Spearman)。
Spearman's Rank Correlation Coefficient斯皮尔曼等级相关系数 SL 4.10
- Rank two sets of data and give tied values the average of the ranks they occupy.
- Calculate Spearman's rank correlation coefficient $r_s$ with technology, and by hand when there are no ties.
- Interpret $r_s$ as a measure of monotonic association, with $-1 \le r_s \le 1$.
- Compare $r_s$ with Pearson's $r$ and explain when each one is appropriate.
- Explain why $r_s$ is less affected by an outlier than Pearson's $r$.
- 对两组数据排序(
rank),相同数值取它们所占名次的平均值。 - 用技术工具计算(
calculate)斯皮尔曼等级相关系数 $r_s$;没有并列时也能手算。 - 解释(
interpret)$r_s$ 衡量的是单调关系(monotonic association),且 $-1 \le r_s \le 1$。 - 比较(
compare)$r_s$ 与皮尔逊 $r$,并说明各自适用的情形。 - 解释(
explain)为什么 $r_s$ 受离群值的影响比皮尔逊 $r$ 小。
What $r_s$ measures$r_s$ 衡量什么
Definition. Spearman's rank correlation coefficient $r_s$ is Pearson's product-moment correlation coefficient calculated on the ranks of the data instead of the raw values. Rank each variable separately (rank 1 for the smallest value, or rank 1 for the largest, as long as both variables use the same direction), then find Pearson's $r$ for the pairs of ranks.
定义。斯皮尔曼等级相关系数 $r_s$ 就是对数据的名次(而不是原始数值)计算的皮尔逊积矩相关系数(Pearson's product-moment correlation coefficient)。两个变量分别排名(最小值记为第 1 名,或最大值记为第 1 名,只要两个变量方向一致即可),再对成对的名次计算皮尔逊 $r$。
Why it works. Ranks keep only the order of the data. If $y$ always increases when $x$ increases, the two rank lists are identical and $r_s = 1$, even when the relationship is a curve. So $r_s$ measures how close the relationship is to monotonic (always increasing or always decreasing), while Pearson's $r$ measures how close it is to linear. $r_s = 1$ means a perfectly increasing monotonic relationship; $r_s = -1$ a perfectly decreasing one; $r_s$ near $0$ means no monotonic trend.
原理。名次只保留数据的顺序。若 $x$ 增大时 $y$ 总是增大,两列名次完全一致,于是 $r_s = 1$,即使两者是曲线关系。因此 $r_s$ 衡量关系有多接近单调(monotonic,一直增或一直减),而皮尔逊 $r$ 衡量关系有多接近线性。$r_s = 1$ 表示完全单调递增;$r_s = -1$ 表示完全单调递减;$r_s$ 接近 $0$ 表示没有单调趋势。
Tied ranks并列名次
When values are equal, give each of them the average of the ranks they would occupy. For example, if three equal values would take ranks $1$, $2$ and $3$, each gets rank $\frac{1+2+3}{3} = 2$, and the next value gets rank $4$. With tied ranks, find $r_s$ by entering the ranks into the GDC and calculating Pearson's $r$; the $\sum d^2$ shortcut is then only an approximation.
数值相等时,每个都取它们本应占据的名次的平均值(average of the ranks)。例如三个相等的数本应占第 $1$、$2$、$3$ 名,则每个都记为 $\frac{1+2+3}{3} = 2$,下一个数记为第 $4$ 名。有并列名次时,把名次输入 GDC 计算皮尔逊 $r$ 来得到 $r_s$;此时 $\sum d^2$ 简化公式只是近似。
Worked Example: Revision hours and test scores (no ties)例题:复习时间与考试成绩(无并列)
Problem: Six students record hours of revision $x$ and test score $y$: $(2, 45)$, $(5, 60)$, $(1, 50)$, $(8, 85)$, $(4, 52)$, $(6, 70)$. Find $r_s$ and interpret it.
Step 1: rank each variable (rank 1 = smallest). Ranks of $x$: $2, 4, 1, 6, 3, 5$. Ranks of $y$: $1, 4, 2, 6, 3, 5$.
Step 2: differences. $d = 1, 0, -1, 0, 0, 0$, so $\sum d^2 = 2$.
$$ r_s = 1 - \frac{6 \times 2}{6(6^2 - 1)} = 1 - \frac{12}{210} = 0.943 \text{ (3 s.f.)} $$GDC: enter the two rank lists and run linear regression (or the correlation function): $r = 0.943$, which agrees. For comparison, Pearson's $r$ on the raw data is $0.931$.
Interpretation: $r_s = 0.943$ shows a strong positive monotonic association: students who revised more tended to score higher. Why this works: the shortcut formula is exactly Pearson's $r$ for ranks when every rank is a distinct whole number.
题目:六名学生记录复习时间 $x$(小时)和考试成绩 $y$:$(2, 45)$、$(5, 60)$、$(1, 50)$、$(8, 85)$、$(4, 52)$、$(6, 70)$。求 $r_s$ 并解释。
第 1 步:分别排名(最小值为第 1 名)。$x$ 的名次:$2, 4, 1, 6, 3, 5$。$y$ 的名次:$1, 4, 2, 6, 3, 5$。
第 2 步:名次差。$d = 1, 0, -1, 0, 0, 0$,所以 $\sum d^2 = 2$。
$$ r_s = 1 - \frac{6 \times 2}{6(6^2 - 1)} = 1 - \frac{12}{210} = 0.943 \text{ (3 s.f.)} $$GDC:把两列名次输入,运行线性回归(或相关系数功能):$r = 0.943$,结果一致。作为对比,原始数据的皮尔逊 $r$ 为 $0.931$。
解释:$r_s = 0.943$ 表示很强的正单调关系:复习越多的学生成绩往往越高。原理:当每个名次都是互不相同的整数时,简化公式恰好等于名次的皮尔逊 $r$。
Worked Example: Two judges with tied scores例题:有并列分数的两位评委
Problem: Two judges score seven dancers. Judge A: $7, 5, 8, 5, 9, 6, 5$. Judge B: $6, 4, 8, 5, 9, 7, 3$. Find $r_s$.
Step 1: rank Judge A. The three scores of $5$ would occupy ranks $1, 2, 3$, so each gets $2$. Then $6 \to 4$, $7 \to 5$, $8 \to 6$, $9 \to 7$. Ranks: $5, 2, 6, 2, 7, 4, 2$.
Step 2: rank Judge B (no ties): $4, 2, 6, 3, 7, 5, 1$.
Step 3: Pearson's $r$ on the ranks (GDC): $r_s = 0.927$ (3 s.f.).
Check: the shortcut would give $1 - \frac{6 \times 4}{7 \times 48} = 0.929$, close but not exact, because of the tie. Use the GDC value.
Interpretation: strong positive agreement between the judges' orderings. Why this works: averaging tied ranks keeps the total of the ranks equal to $1 + 2 + \dots + 7 = 28$, so no value gains or loses rank unfairly.
题目:两位评委给七名舞者打分。评委 A:$7, 5, 8, 5, 9, 6, 5$。评委 B:$6, 4, 8, 5, 9, 7, 3$。求 $r_s$。
第 1 步:给评委 A 排名。三个 $5$ 分本应占第 $1, 2, 3$ 名,所以每个记为 $2$。然后 $6 \to 4$,$7 \to 5$,$8 \to 6$,$9 \to 7$。名次:$5, 2, 6, 2, 7, 4, 2$。
第 2 步:给评委 B 排名(无并列):$4, 2, 6, 3, 7, 5, 1$。
第 3 步:对名次求皮尔逊 $r$(GDC):$r_s = 0.927$(3 s.f.)。
验算:简化公式会给出 $1 - \frac{6 \times 4}{7 \times 48} = 0.929$,接近但不精确,原因是存在并列。应采用 GDC 的结果。
解释:两位评委的排序高度一致(强正相关)。原理:取并列名次的平均值,使名次总和仍为 $1 + 2 + \dots + 7 = 28$,没有哪个数值被不公平地抬高或压低名次。
Spearman or Pearson?用斯皮尔曼还是皮尔逊?
Take $x = 1, 2, 3, 4, 5, 6$ and $y = 2^x$, that is $y = 2, 4, 8, 16, 32, 64$. The relationship is perfectly increasing, so $r_s = 1$, but it is curved, so Pearson's $r = 0.906$. Use Pearson's $r$ when the scatter diagram looks linear and the data are measurements; use $r_s$ when the trend is monotonic but curved, when the data are already ranks or ordinal (judges' placings, preferences), or when an outlier would distort $r$. An outlier can be any distance from the other values, but its rank can never exceed $n$, so its effect on $r_s$ is limited and $r_s$ is more resistant.
取 $x = 1, 2, 3, 4, 5, 6$,$y = 2^x$,即 $y = 2, 4, 8, 16, 32, 64$。这个关系完全递增,所以 $r_s = 1$;但它是曲线,所以皮尔逊 $r = 0.906$。散点图呈线性、数据是测量值时用皮尔逊 $r$;趋势单调但弯曲、数据本身就是名次或有序数据(评委名次、偏好),或离群值会扭曲 $r$ 时,用 $r_s$。离群值可以离其他数据任意远,但它的名次永远不会超过 $n$,所以它对 $r_s$ 的影响有限,$r_s$ 更稳健(resistant)。
$r_s = 1$ says only that the order of $y$ matches the order of $x$ exactly. It does not say the points lie on a straight line, and neither coefficient shows that $x$ causes $y$.
$r_s = 1$ 只说明 $y$ 的顺序与 $x$ 的顺序完全一致,并不说明点落在一条直线上;而且两种相关系数都不能说明 $x$ 导致 $y$(相关不等于因果)。
Show the two rank lists before giving $r_s$: they are the working that a GDC value cannot show. Rank both variables in the same direction, average tied ranks, and give $r_s$ to 3 significant figures. When asked to "interpret", name the direction, the strength and the word monotonic in context (for example "strong positive monotonic association between revision time and score"); when asked to compare with Pearson's $r$, refer to linear versus monotonic.
给出 $r_s$ 之前先写出两列名次:这是 GDC 数值无法体现的过程。两个变量按同一方向排名,并列取平均名次,$r_s$ 保留 3 位有效数字。题目要求"解释"(interpret)时,结合情境说出方向、强弱和"单调"一词(如"复习时间与成绩之间存在强的正单调关系");要求与皮尔逊 $r$ 比较时,要落到"线性"与"单调"的区别上。
Rank the values $12, 15, 15, 18, 15$ (rank 1 = smallest).给数值 $12, 15, 15, 18, 15$ 排名(最小值为第 1 名)。
$12$ is rank $1$. The three values of $15$ would occupy ranks $2, 3, 4$, so each gets $\frac{2+3+4}{3} = 3$. $18$ is rank $5$. Ranks in the original order: $1, 3, 3, 5, 3$.
$12$ 为第 $1$ 名。三个 $15$ 本应占第 $2, 3, 4$ 名,所以每个记为 $\frac{2+3+4}{3} = 3$。$18$ 为第 $5$ 名。按原顺序的名次:$1, 3, 3, 5, 3$。
Five pairs have ranks $(3, 2)$, $(1, 1)$, $(4, 5)$, $(2, 3)$, $(5, 4)$. Calculate $r_s$.五对数据的名次为 $(3, 2)$、$(1, 1)$、$(4, 5)$、$(2, 3)$、$(5, 4)$。计算 $r_s$。
No ties, so the shortcut is exact. $d = 1, 0, -1, -1, 1$ and $\sum d^2 = 4$. $r_s = 1 - \frac{6 \times 4}{5(25 - 1)} = 1 - \frac{24}{120} = 0.8$: a strong positive monotonic association.
没有并列,简化公式是精确的。$d = 1, 0, -1, -1, 1$,$\sum d^2 = 4$。$r_s = 1 - \frac{6 \times 4}{5(25 - 1)} = 1 - \frac{24}{120} = 0.8$:较强的正单调关系。
A scatter diagram of drug dose against response rises steeply and then levels off, with every point higher than the one before. Which coefficient describes it better, and why?药物剂量与反应的散点图先陡升后趋平,每个点都比前一个点高。哪个系数描述得更好?为什么?
Spearman's $r_s$. The relationship is increasing but not linear, so $r_s = 1$ captures the perfect monotonic trend, while Pearson's $r$ would be less than $1$ because the points do not lie on a straight line.
斯皮尔曼 $r_s$。关系递增但非线性,$r_s = 1$ 反映出完全的单调趋势;而皮尔逊 $r$ 会小于 $1$,因为点不在一条直线上。
Hypothesis Testing and the Chi-Squared Test for Independence假设检验与卡方独立性检验 SL 4.11
- State a null hypothesis $H_0$ and an alternative hypothesis $H_1$ in context.
- Define the significance level and the p-value, and use them to reach a decision.
- Calculate expected frequencies for a contingency table and the degrees of freedom $(r-1)(c-1)$.
- Carry out a chi-squared test for independence with technology, and check the expected-frequency condition.
- Combine rows or columns when an expected frequency is below $5$, and recalculate the degrees of freedom.
- Write a conclusion in context that never claims $H_0$ has been proved.
- 结合情境写出(
state)原假设 $H_0$ 与备择假设 $H_1$。 - 定义(
define)显著性水平与 p 值,并据此作出判断。 - 计算(
calculate)列联表的期望频数和自由度 $(r-1)(c-1)$。 - 用技术工具进行卡方独立性检验,并检查期望频数条件。
- 当某个期望频数小于 $5$ 时合并行或列,并重新计算自由度。
- 结合情境写出结论,绝不声称已证明 $H_0$。
The language of a hypothesis test假设检验的基本语言
Null hypothesis $H_0$: the "nothing is going on" statement that the test assumes is true, for example "age group and preferred news source are independent" or "the mean scores are equal". Alternative hypothesis $H_1$: what you are looking for evidence of, for example "age group and preferred news source are not independent".
原假设 $H_0$(null hypothesis):检验时假定成立的"没有效应"的陈述,例如"年龄组与首选新闻来源相互独立"或"两组平均分相等"。备择假设 $H_1$(alternative hypothesis):你想寻找证据支持的陈述,例如"年龄组与首选新闻来源不独立"。
Significance level $\alpha$: the threshold chosen before the test, usually $5\%$, $1\%$ or $10\%$. For a continuous test statistic it is the probability of rejecting $H_0$ when $H_0$ is in fact true. p-value: the probability, assuming $H_0$ is true, of obtaining a test statistic at least as extreme as the one observed. A small p-value means the data would be unusual if $H_0$ were true.
显著性水平 $\alpha$(significance level):检验前选定的阈值,通常为 $5\%$、$1\%$ 或 $10\%$。对连续型检验统计量,它是 $H_0$ 实际成立时却拒绝 $H_0$ 的概率。p 值(p-value):在假定 $H_0$ 成立的前提下,得到至少与观测值一样极端的检验统计量的概率。p 值小,说明如果 $H_0$ 成立,这样的数据会很少见。
Decision rule: if p-value $< \alpha$, reject $H_0$: there is sufficient evidence for $H_1$. If p-value $\ge \alpha$, do not reject $H_0$: there is insufficient evidence for $H_1$. The critical-value method reaches the same decision: compare the test statistic with a critical value read from the distribution. A test whose $H_1$ names a direction ($\mu_1 > \mu_2$) is one-tailed; a test whose $H_1$ only says "different" ($\mu_1 \ne \mu_2$) is two-tailed. The chi-squared tests in this unit are always one-tailed in the upper tail.
判断规则:若 p 值 $< \alpha$,拒绝 $H_0$:有足够证据支持 $H_1$。若 p 值 $\ge \alpha$,不拒绝 $H_0$:没有足够证据支持 $H_1$。临界值法得出同样的判断:把检验统计量与从分布中查得的临界值(critical value)比较。$H_1$ 指明方向($\mu_1 > \mu_2$)的是单尾检验(one-tailed);$H_1$ 只说"不同"($\mu_1 \ne \mu_2$)的是双尾检验(two-tailed)。本单元的卡方检验总是上尾的单尾检验。
Never write "accept $H_0$" or "$H_0$ is true". Not rejecting $H_0$ means only that the data are not strong enough evidence against it. And the p-value is not the probability that $H_0$ is true: it is calculated assuming $H_0$ is true.
绝不要写"接受 $H_0$"(accept)或"$H_0$ 成立"。不拒绝 $H_0$ 只表示数据还不足以构成反对它的证据。p 值也不是 $H_0$ 为真的概率:它本身就是在假定 $H_0$ 成立的前提下算出来的。
The chi-squared test for independence卡方独立性检验
Set-up. Two categorical variables are recorded for each member of a sample and the observed frequencies $f_o$ are arranged in a contingency table with $r$ rows and $c$ columns. $H_0$: the two variables are independent; $H_1$: they are not independent.
设定。对样本中每个个体记录两个分类变量,把观测频数 $f_o$ 排成 $r$ 行 $c$ 列的列联表(contingency table)。$H_0$:两个变量相互独立;$H_1$:两个变量不独立。
Expected frequencies. If the variables are independent, $P(\text{row } i \text{ and column } j) = P(\text{row } i) \times P(\text{column } j)$, so the expected frequency of a cell is
期望频数(expected frequency)。若两个变量独立,则 $P(\text{row } i \text{ and column } j) = P(\text{row } i) \times P(\text{column } j)$,所以每个格子的期望频数为
Degrees of freedom. Once the row and column totals are fixed, only $(r-1)(c-1)$ cells can be filled freely; the rest are forced by the totals. That number is the degrees of freedom $\nu$. Condition: $\chi^2_{calc}$ follows the chi-squared distribution only approximately, and the usual rule is that every expected frequency must be at least $5$ for the approximation to be reliable. If some $f_e < 5$, combine a row or column with a neighbouring one that makes sense in context, then recompute $\nu$ from the new table.
自由度(degrees of freedom)。行合计与列合计固定后,只有 $(r-1)(c-1)$ 个格子能自由填写,其余格子由合计决定。这个数就是自由度 $\nu$。条件:$\chi^2_{calc}$ 只是近似服从卡方分布,通常的规则是每个期望频数都至少为 $5$,近似才可靠。若某些 $f_e < 5$,就把该行或列与情境上合理的相邻行或列合并,再按新表重新计算 $\nu$。
Worked Example: Age group and news source例题:年龄组与新闻来源
Problem: $300$ adults are asked for their main news source. Test at the $5\%$ significance level whether news source is independent of age group.
| Observed | Social media | TV | Newspaper | Total |
|---|---|---|---|---|
| 18 to 29 | 40 | 25 | 15 | 80 |
| 30 to 49 | 45 | 40 | 15 | 100 |
| 50 and over | 25 | 55 | 40 | 120 |
| Total | 110 | 120 | 70 | 300 |
Hypotheses: $H_0$: news source is independent of age group. $H_1$: news source is not independent of age group.
Expected frequencies, for example 18 to 29 and social media: $f_e = \frac{80 \times 110}{300} = 29.33$. All nine: $29.33, 32.00, 18.67$; $36.67, 40.00, 23.33$; $44.00, 48.00, 28.00$. Every $f_e \ge 5$, so the test is valid.
Degrees of freedom: $\nu = (3-1)(3-1) = 4$.
GDC (observed matrix, chi-squared test): $\chi^2_{calc} = 25.4$, p-value $= 4.24 \times 10^{-5}$. The critical value for $\nu = 4$ at $5\%$ is $9.49$ (Figure 2).
Decision: $4.24 \times 10^{-5} < 0.05$ (by critical value: $25.4 > 9.49$), so reject $H_0$.
Conclusion: there is sufficient evidence at the $5\%$ level that news source is not independent of age group. The largest single contribution, $\frac{(25 - 44)^2}{44} = 8.20$, comes from fewer adults aged 50 and over using social media than independence predicts. Why this works: $\chi^2$ adds up the squared gaps between what was seen and what independence predicts, scaled by the prediction.
题目:询问 $300$ 名成年人的主要新闻来源。在 $5\%$ 显著性水平下检验新闻来源是否与年龄组独立。
| 观测频数 | 社交媒体 | 电视 | 报纸 | 合计 |
|---|---|---|---|---|
| 18 至 29 岁 | 40 | 25 | 15 | 80 |
| 30 至 49 岁 | 45 | 40 | 15 | 100 |
| 50 岁及以上 | 25 | 55 | 40 | 120 |
| 合计 | 110 | 120 | 70 | 300 |
假设:$H_0$:新闻来源与年龄组独立。$H_1$:新闻来源与年龄组不独立。
期望频数,例如 18 至 29 岁、社交媒体:$f_e = \frac{80 \times 110}{300} = 29.33$。全部九个:$29.33, 32.00, 18.67$;$36.67, 40.00, 23.33$;$44.00, 48.00, 28.00$。每个 $f_e \ge 5$,检验有效。
自由度:$\nu = (3-1)(3-1) = 4$。
GDC(输入观测矩阵,做卡方检验):$\chi^2_{calc} = 25.4$,p 值 $= 4.24 \times 10^{-5}$。$\nu = 4$、$5\%$ 水平的临界值为 $9.49$(图 2)。
判断:$4.24 \times 10^{-5} < 0.05$(用临界值:$25.4 > 9.49$),所以拒绝 $H_0$。
结论:在 $5\%$ 水平下有足够证据表明新闻来源与年龄组不独立。最大的单项贡献 $\frac{(25 - 44)^2}{44} = 8.20$ 来自 50 岁及以上使用社交媒体的人数少于独立时的预期。原理:$\chi^2$ 把观测值与独立假设下预测值之差的平方(按预测值缩放)加总起来。
Worked Example: Combining columns with small expected frequencies例题:合并期望频数过小的列
Problem: $70$ students name their favourite sport. Test at the $5\%$ level whether favourite sport is independent of year group.
| Observed | Football | Basketball | Tennis | Rugby | Total |
|---|---|---|---|---|---|
| Year 12 | 12 | 10 | 8 | 2 | 32 |
| Year 13 | 8 | 14 | 12 | 4 | 38 |
| Total | 20 | 24 | 20 | 6 | 70 |
Check the condition: rugby has $f_e = \frac{32 \times 6}{70} = 2.74$ and $\frac{38 \times 6}{70} = 3.26$, both below $5$. Combine tennis and rugby into one column "tennis or rugby" with observed $10$ and $16$ (total $26$).
New expected frequencies: Year 12: $9.14, 10.97, 11.89$; Year 13: $10.86, 13.03, 14.11$. All are at least $5$.
Hypotheses: $H_0$: favourite sport is independent of year group; $H_1$: favourite sport is not independent of year group. Degrees of freedom of the new $2 \times 3$ table: $\nu = (2-1)(3-1) = 2$.
GDC: $\chi^2_{calc} = 2.35$, p-value $= 0.308$. Since $0.308 > 0.05$ (by critical value: $2.35 < 5.99$), do not reject $H_0$.
Conclusion: there is insufficient evidence at the $5\%$ level that favourite sport depends on year group. Why this works: merging categories raises the small expected counts, so the chi-squared approximation is trustworthy, at the cost of fewer degrees of freedom.
题目:$70$ 名学生说出最喜欢的运动。在 $5\%$ 水平下检验最喜欢的运动是否与年级独立。
| 观测频数 | 足球 | 篮球 | 网球 | 橄榄球 | 合计 |
|---|---|---|---|---|---|
| 12 年级 | 12 | 10 | 8 | 2 | 32 |
| 13 年级 | 8 | 14 | 12 | 4 | 38 |
| 合计 | 20 | 24 | 20 | 6 | 70 |
检查条件:橄榄球的 $f_e = \frac{32 \times 6}{70} = 2.74$ 和 $\frac{38 \times 6}{70} = 3.26$,都小于 $5$。把网球与橄榄球合并为"网球或橄榄球"一列,观测频数为 $10$ 和 $16$(合计 $26$)。
新的期望频数:12 年级:$9.14, 10.97, 11.89$;13 年级:$10.86, 13.03, 14.11$。全部至少为 $5$。
假设:$H_0$:最喜欢的运动与年级独立;$H_1$:最喜欢的运动与年级不独立。新的 $2 \times 3$ 表的自由度:$\nu = (2-1)(3-1) = 2$。
GDC:$\chi^2_{calc} = 2.35$,p 值 $= 0.308$。由于 $0.308 > 0.05$(用临界值:$2.35 < 5.99$),不拒绝 $H_0$。
结论:在 $5\%$ 水平下没有足够证据表明最喜欢的运动与年级有关。原理:合并类别能提高过小的期望频数,使卡方近似可靠,代价是自由度减少。
Write both hypotheses in words and in context ("... is independent of ..."), not just as symbols. Show one expected frequency calculation even when the GDC gives the whole matrix, and state $\nu$. Quote the p-value (or $\chi^2_{calc}$ and the critical value), compare it with $\alpha$ in a sentence, and finish with a conclusion in context: "there is sufficient (insufficient) evidence at the $5\%$ level that ...". On the GDC, the expected matrix is stored after the test: check it for values below $5$.
两个假设都要用文字结合情境写出("……与……独立"),不要只写符号。即使 GDC 给出了整个期望矩阵,也要写出一个期望频数的计算过程,并写明 $\nu$。写出 p 值(或 $\chi^2_{calc}$ 与临界值),用一句话与 $\alpha$ 比较,最后结合情境下结论:"在 $5\%$ 水平下有(没有)足够证据表明……"。GDC 做完检验后会存储期望矩阵:检查其中是否有小于 $5$ 的值。
In a contingency table a cell has row total $45$, column total $60$ and grand total $150$. Find its expected frequency.列联表中某格的行合计为 $45$,列合计为 $60$,总计为 $150$。求它的期望频数。
$f_e = \frac{45 \times 60}{150} = 18$.
$f_e = \frac{45 \times 60}{150} = 18$。
A test for independence uses a table with $4$ rows and $3$ columns, and every expected frequency is at least $5$. State the degrees of freedom and the $5\%$ critical value.某独立性检验使用 $4$ 行 $3$ 列的表,所有期望频数都至少为 $5$。写出自由度和 $5\%$ 临界值。
$\nu = (4-1)(3-1) = 6$. The $5\%$ critical value is $12.6$ (GDC inverse chi-squared: $12.59$). Reject $H_0$ if $\chi^2_{calc} > 12.6$.
$\nu = (4-1)(3-1) = 6$。$5\%$ 临界值为 $12.6$(GDC 卡方逆函数:$12.59$)。若 $\chi^2_{calc} > 12.6$ 则拒绝 $H_0$。
A test gives p-value $= 0.031$. State the decision at the $5\%$ and at the $1\%$ significance levels.某检验得到 p 值 $= 0.031$。分别写出 $5\%$ 与 $1\%$ 显著性水平下的判断。
At $5\%$: $0.031 < 0.05$, so reject $H_0$. At $1\%$: $0.031 > 0.01$, so do not reject $H_0$; there is insufficient evidence at that level. The same data can lead to different decisions, which is why $\alpha$ is fixed before the test.
$5\%$ 水平:$0.031 < 0.05$,拒绝 $H_0$。$1\%$ 水平:$0.031 > 0.01$,不拒绝 $H_0$,在该水平下证据不足。同样的数据可能得出不同判断,所以 $\alpha$ 必须在检验前确定。
A student writes: "p-value $= 0.42$, so we accept $H_0$: the variables are independent." Correct the conclusion.某学生写道:"p 值 $= 0.42$,所以接受 $H_0$:两个变量独立。"请改正这个结论。
"Since $0.42 > 0.05$, do not reject $H_0$. There is insufficient evidence at the $5\%$ level that the variables are not independent." The data fail to show dependence; they do not prove independence.
"由于 $0.42 > 0.05$,不拒绝 $H_0$。在 $5\%$ 水平下没有足够证据表明两个变量不独立。"数据没能显示相关性,但这并不证明独立。
Chi-Squared Goodness of Fit卡方拟合优度检验 SL 4.11
- State hypotheses for a goodness of fit test in context.
- Calculate expected frequencies from a uniform distribution, given proportions or a binomial model.
- Determine the degrees of freedom $k - 1 - m$, where $m$ is the number of parameters estimated from the data.
- Combine classes with expected frequency below $5$ before counting $k$.
- Carry out the test with technology and write a conclusion in context.
- 结合情境写出(
state)拟合优度检验的假设。 - 根据均匀分布、给定比例或二项模型计算(
calculate)期望频数。 - 确定(
determine)自由度 $k - 1 - m$,其中 $m$ 是用数据估计的参数个数。 - 在数 $k$ 之前,先合并期望频数小于 $5$ 的组。
- 用技术工具完成检验,并结合情境写出结论。
How the test works检验的原理
Definition. A goodness of fit test compares the observed frequencies of one variable with the frequencies a model predicts. $H_0$: the data come from the stated distribution (for example "the die is fair" or "the number germinating follows a binomial distribution"). $H_1$: the data do not come from that distribution.
定义。拟合优度检验(goodness of fit)把一个变量的观测频数与模型预测的频数相比较。$H_0$:数据来自所声称的分布(如"骰子是均匀的"或"发芽数服从二项分布")。$H_1$:数据不来自该分布。
Mechanism. With $n$ observations and model probabilities $p_i$, the expected frequency of class $i$ is $f_e = n p_i$, and the statistic is the same $\chi^2_{calc} = \sum \frac{(f_o - f_e)^2}{f_e}$ as before. The degrees of freedom start at $k - 1$ for $k$ classes, because the frequencies must add to $n$. Each parameter estimated from the data (a binomial $p$, a normal mean or standard deviation) forces the expected values to match the data once more, so it removes one more degree of freedom.
机制。共有 $n$ 个观测、模型概率为 $p_i$ 时,第 $i$ 组的期望频数为 $f_e = n p_i$,统计量仍是 $\chi^2_{calc} = \sum \frac{(f_o - f_e)^2}{f_e}$。$k$ 个组的自由度从 $k - 1$ 开始,因为各频数之和必须为 $n$。每用数据估计一个参数(二项分布的 $p$、正态分布的均值或标准差),期望值就被迫再与数据吻合一次,于是再减少一个自由度。
Worked Example: Is the die fair?例题:骰子是否均匀?
Problem: A die is rolled $120$ times. The scores $1$ to $6$ occur $15, 25, 18, 22, 14, 26$ times. Test at the $5\%$ level whether the die is fair.
Hypotheses: $H_0$: the die is fair (each score has probability $\frac{1}{6}$). $H_1$: the die is not fair.
Expected: $f_e = 120 \times \frac{1}{6} = 20$ for every score, all at least $5$.
$$ \chi^2_{calc} = \frac{25 + 25 + 4 + 4 + 36 + 36}{20} = \frac{130}{20} = 6.5 $$Degrees of freedom: $k = 6$, nothing estimated, so $\nu = 6 - 1 = 5$.
GDC (goodness of fit test, observed and expected lists, $\nu = 5$): p-value $= 0.261$. Since $0.261 > 0.05$ (by critical value: $6.5 < 11.07$), do not reject $H_0$.
Conclusion: there is insufficient evidence at the $5\%$ level that the die is biased. Why this works: under $H_0$ the gaps between observed and expected counts are only chance variation, and a $\chi^2$ of $6.5$ with $5$ degrees of freedom is an ordinary amount of chance variation.
题目:把一枚骰子掷 $120$ 次,点数 $1$ 至 $6$ 分别出现 $15, 25, 18, 22, 14, 26$ 次。在 $5\%$ 水平下检验骰子是否均匀。
假设:$H_0$:骰子是均匀的(每个点数概率为 $\frac{1}{6}$)。$H_1$:骰子不均匀。
期望频数:每个点数 $f_e = 120 \times \frac{1}{6} = 20$,都至少为 $5$。
$$ \chi^2_{calc} = \frac{25 + 25 + 4 + 4 + 36 + 36}{20} = \frac{130}{20} = 6.5 $$自由度:$k = 6$,没有估计参数,所以 $\nu = 6 - 1 = 5$。
GDC(拟合优度检验,输入观测与期望列表,$\nu = 5$):p 值 $= 0.261$。由于 $0.261 > 0.05$(用临界值:$6.5 < 11.07$),不拒绝 $H_0$。
结论:在 $5\%$ 水平下没有足够证据表明骰子有偏。原理:在 $H_0$ 下,观测与期望之差只是随机波动;自由度为 $5$ 时,$6.5$ 的 $\chi^2$ 属于很普通的随机波动。
Worked Example: A binomial model with an estimated parameter例题:含估计参数的二项模型
Problem: In each of $100$ pots, $4$ seeds are planted. The number of seeds that germinate per pot is recorded: $0$ seeds: $3$ pots; $1$: $12$; $2$: $28$; $3$: $35$; $4$: $22$. Test at the $5\%$ level whether a binomial model fits.
Hypotheses: $H_0$: the number germinating per pot follows a binomial distribution $B(4, p)$. $H_1$: it does not follow a binomial distribution.
Estimate $p$ from the data: total germinated $= 0(3) + 1(12) + 2(28) + 3(35) + 4(22) = 261$ out of $400$ seeds, so $\hat{p} = \frac{261}{400} = 0.6525$.
Expected: $f_e = 100 \times P(X = x)$ with $X \sim B(4, 0.6525)$: $1.46, 10.95, 30.85, 38.62, 18.13$ for $x = 0, 1, 2, 3, 4$.
Combine: $1.46 < 5$, so merge $x = 0$ and $x = 1$: observed $15$, expected $12.41$. Now $k = 4$ classes.
Degrees of freedom: one parameter ($p$) was estimated, so $\nu = 4 - 1 - 1 = 2$.
GDC (observed $15, 28, 35, 22$; expected $12.41, 30.85, 38.62, 18.13$; $\nu = 2$): $\chi^2_{calc} = 1.97$, p-value $= 0.374$. Since $0.374 > 0.05$, do not reject $H_0$.
Conclusion: there is insufficient evidence at the $5\%$ level that the binomial model is unsuitable, so $B(4, 0.6525)$ is a reasonable model. Why this works: the model was fitted to the data through $\hat{p}$, so it fits more closely than chance alone would allow; removing a degree of freedom compensates. (Wrongly using $\nu = 3$ would give p-value $0.579$.)
题目:在 $100$ 个花盆中各种 $4$ 粒种子,记录每盆的发芽数:$0$ 粒:$3$ 盆;$1$:$12$;$2$:$28$;$3$:$35$;$4$:$22$。在 $5\%$ 水平下检验二项模型是否吻合。
假设:$H_0$:每盆发芽数服从二项分布 $B(4, p)$。$H_1$:不服从二项分布。
用数据估计 $p$:发芽总数 $= 0(3) + 1(12) + 2(28) + 3(35) + 4(22) = 261$,共 $400$ 粒种子,所以 $\hat{p} = \frac{261}{400} = 0.6525$。
期望频数:$f_e = 100 \times P(X = x)$,$X \sim B(4, 0.6525)$:$x = 0, 1, 2, 3, 4$ 时分别为 $1.46, 10.95, 30.85, 38.62, 18.13$。
合并:$1.46 < 5$,所以把 $x = 0$ 与 $x = 1$ 合并:观测 $15$,期望 $12.41$。现在 $k = 4$ 组。
自由度:估计了一个参数($p$),所以 $\nu = 4 - 1 - 1 = 2$。
GDC(观测 $15, 28, 35, 22$;期望 $12.41, 30.85, 38.62, 18.13$;$\nu = 2$):$\chi^2_{calc} = 1.97$,p 值 $= 0.374$。由于 $0.374 > 0.05$,不拒绝 $H_0$。
结论:在 $5\%$ 水平下没有足够证据表明二项模型不合适,所以 $B(4, 0.6525)$ 是合理的模型。原理:模型通过 $\hat{p}$ 已经拟合过数据,因此比纯随机情况吻合得更好;减去一个自由度正是对此的补偿。(若错用 $\nu = 3$,会得到 p 值 $0.579$。)
The GDC's goodness of fit test asks you for $\nu$; it does not know that you estimated $p$ or $\mu$ from the same data. Count classes after combining, subtract $1$, then subtract one more for each estimated parameter (a normal model with both $\mu$ and $\sigma$ estimated loses $2$).
GDC 的拟合优度检验要你输入 $\nu$;它并不知道你用同一组数据估计了 $p$ 或 $\mu$。合并后再数组数,减 $1$,每估计一个参数再减一(同时估计 $\mu$ 和 $\sigma$ 的正态模型要减 $2$)。
Name the distribution in $H_0$ with its parameters when they are given ("the scores follow the proportions $0.5$, $0.3$, $0.2$"). Show how one expected frequency was found, show any combining of classes, and justify $\nu$ in one line ("$4$ classes, $1$ parameter estimated, so $\nu = 2$"). Expected frequencies need not be whole numbers: keep them unrounded in the GDC lists.
在 $H_0$ 中写出分布名称;参数已给出时也写上("各类别比例为 $0.5$、$0.3$、$0.2$")。写出一个期望频数的求法、所有合并组的过程,并用一行说明 $\nu$("$4$ 组,估计了 $1$ 个参数,所以 $\nu = 2$")。期望频数不必是整数:在 GDC 列表中保留未四舍五入的值。
A seed supplier claims colours occur in proportions red $0.5$, yellow $0.3$, white $0.2$. In $100$ flowers there are $52$ red, $30$ yellow and $18$ white. Test the claim at the $5\%$ level.种子商声称花色比例为红 $0.5$、黄 $0.3$、白 $0.2$。$100$ 朵花中红 $52$、黄 $30$、白 $18$。在 $5\%$ 水平下检验这一说法。
$H_0$: the colours follow the proportions $0.5$, $0.3$, $0.2$; $H_1$: they do not. Expected $50, 30, 20$. $\chi^2_{calc} = \frac{4}{50} + 0 + \frac{4}{20} = 0.28$, $\nu = 3 - 1 = 2$, p-value $= 0.869 > 0.05$. Do not reject $H_0$: insufficient evidence that the supplier's proportions are wrong.
$H_0$:花色服从比例 $0.5$、$0.3$、$0.2$;$H_1$:不服从。期望 $50, 30, 20$。$\chi^2_{calc} = \frac{4}{50} + 0 + \frac{4}{20} = 0.28$,$\nu = 3 - 1 = 2$,p 值 $= 0.869 > 0.05$。不拒绝 $H_0$:没有足够证据表明种子商的比例有误。
A normal model is fitted to grouped data using the sample mean and standard deviation. After combining, there are $8$ classes. Find $\nu$.用样本均值和标准差对分组数据拟合正态模型。合并后共有 $8$ 组。求 $\nu$。
Two parameters were estimated, so $\nu = 8 - 1 - 2 = 5$.
估计了两个参数,所以 $\nu = 8 - 1 - 2 = 5$。
Why must classes with an expected frequency below $5$ be combined, and why is it the expected, not the observed, frequency that matters?为什么期望频数小于 $5$ 的组必须合并?为什么看的是期望频数而不是观测频数?
$\chi^2_{calc}$ only follows a chi-squared distribution approximately, and the approximation breaks down when expected counts are small: dividing by a tiny $f_e$ can make one cell dominate the total. The condition is about the model's predictions, so it uses $f_e$; a small observed count is fine.
$\chi^2_{calc}$ 只是近似服从卡方分布,期望频数小时近似失效:除以很小的 $f_e$ 会让单个格子主导总和。这个条件关乎模型的预测,所以看 $f_e$;观测频数小没有问题。
The t-Test for Comparing Two Means比较两个均值的 t 检验 SL 4.11
- State hypotheses about two population means $\mu_1$ and $\mu_2$, choosing a one-tailed or two-tailed $H_1$ from the wording of the question.
- State the assumptions of the two-sample t-test: independent random samples from normally distributed populations, and equal population variances for the pooled test.
- Calculate the test statistic and p-value with technology from raw data or from summary statistics.
- Explain how a one-tailed p-value relates to the two-tailed p-value.
- Write a conclusion about the population means in context.
- 根据题目措辞选择单尾或双尾 $H_1$,写出(
state)关于两个总体均值 $\mu_1$、$\mu_2$ 的假设。 - 写出双样本 t 检验的前提:来自正态总体的独立随机样本;合并方差检验还要求总体方差相等。
- 用技术工具从原始数据或汇总统计量计算(
calculate)检验统计量和 p 值。 - 解释(
explain)单尾 p 值与双尾 p 值之间的关系。 - 结合情境写出关于总体均值的结论。
The two-sample t-test双样本 t 检验
Definition. The two-sample t-test uses the means of two independent samples to test whether two population means differ. $H_0: \mu_1 = \mu_2$. The alternative is $H_1: \mu_1 \ne \mu_2$ (two-tailed) when the question asks whether the means are different, and $H_1: \mu_1 > \mu_2$ or $H_1: \mu_1 < \mu_2$ (one-tailed) when it asks whether one is larger. The direction comes from the question, never from looking at which sample mean happens to be larger.
定义。双样本 t 检验(t-test)用两个独立样本的均值检验两个总体均值是否不同。$H_0: \mu_1 = \mu_2$。题目问均值"是否不同"时,备择假设为 $H_1: \mu_1 \ne \mu_2$(双尾);问某一个"是否更大"时,为 $H_1: \mu_1 > \mu_2$ 或 $H_1: \mu_1 < \mu_2$(单尾)。方向由题目决定,绝不能看哪个样本均值碰巧更大来定。
Assumptions. The two samples are independent random samples, and both populations are normally distributed. The pooled version also assumes the two populations have equal variances and combines both samples into one estimate $s_p$ of the common standard deviation. On the GDC this is the "Pooled: Yes" option; if a question tells you not to assume equal variances, choose "Pooled: No", which gives a slightly different $t$ and p-value. The worked examples here assume equal variances.
前提条件。两个样本是独立的随机样本,且两个总体都服从正态分布。合并方差(pooled)版本还假定两个总体方差相等,并把两个样本合在一起,得到公共标准差的估计 $s_p$。在 GDC 上这对应"Pooled: Yes";若题目说明不假定方差相等,则选"Pooled: No",得到的 $t$ 与 p 值会略有不同。这里的例题都假定方差相等。
Why $t$ and not $z$: the population standard deviation is unknown and is estimated from small samples, which adds uncertainty. The t-distribution has heavier tails than the normal distribution to allow for this, and it approaches the normal distribution as the degrees of freedom grow.
为什么用 $t$ 而不是 $z$:总体标准差未知,需要用小样本估计,这带来额外的不确定性。t 分布(t-distribution)的尾部比正态分布更厚,正是为此留出余地;自由度越大,它越接近正态分布。
Worked Example: Two teaching methods (two-tailed)例题:两种教学方法(双尾)
Problem: Test scores of students taught by method A: $68, 74, 71, 80, 77, 72$. Method B: $65, 70, 62, 73, 68, 66, 64$. Assume both populations are normal with equal variances. Test at the $5\%$ level whether the mean scores differ.
Hypotheses: $H_0: \mu_A = \mu_B$; $H_1: \mu_A \ne \mu_B$, where $\mu_A$ and $\mu_B$ are the population mean scores. Two-tailed, because the question asks whether they differ.
Summary statistics: $\bar{x}_A = \frac{442}{6} = 73.67$, $s_A = 4.32$ ($s_A^2 = 18.67$); $\bar{x}_B = \frac{468}{7} = 66.86$, $s_B = 3.76$ ($s_B^2 = 14.14$).
By formula (to see what the GDC does):
$$ s_p^2 = \frac{5(18.67) + 6(14.14)}{11} = 16.20, \quad s_p = 4.025, \quad t = \frac{73.667 - 66.857}{4.025\sqrt{\frac{1}{6} + \frac{1}{7}}} = 3.04, \quad \nu = 11 $$GDC (2-sample t-test, Pooled: Yes, $\mu_1 \ne \mu_2$): $t = 3.04$, p-value $= 0.0112$.
Decision: $0.0112 < 0.05$, so reject $H_0$.
Conclusion: there is sufficient evidence at the $5\%$ level that the mean scores for the two methods are different. Why this works: $t$ measures the gap between the sample means in units of its standard error; a gap of about three standard errors is unlikely if the population means are equal. (With Pooled: No the GDC gives $t = 3.01$, p-value $= 0.0131$: same conclusion.)
题目:用方法 A 教学的学生成绩:$68, 74, 71, 80, 77, 72$。方法 B:$65, 70, 62, 73, 68, 66, 64$。假定两个总体都服从正态分布且方差相等。在 $5\%$ 水平下检验平均成绩是否不同。
假设:$H_0: \mu_A = \mu_B$;$H_1: \mu_A \ne \mu_B$,其中 $\mu_A$、$\mu_B$ 为总体平均成绩。题目问"是否不同",所以是双尾。
汇总统计量:$\bar{x}_A = \frac{442}{6} = 73.67$,$s_A = 4.32$($s_A^2 = 18.67$);$\bar{x}_B = \frac{468}{7} = 66.86$,$s_B = 3.76$($s_B^2 = 14.14$)。
用公式计算(看清 GDC 在做什么):
$$ s_p^2 = \frac{5(18.67) + 6(14.14)}{11} = 16.20, \quad s_p = 4.025, \quad t = \frac{73.667 - 66.857}{4.025\sqrt{\frac{1}{6} + \frac{1}{7}}} = 3.04, \quad \nu = 11 $$GDC(双样本 t 检验,Pooled: Yes,$\mu_1 \ne \mu_2$):$t = 3.04$,p 值 $= 0.0112$。
判断:$0.0112 < 0.05$,所以拒绝 $H_0$。
结论:在 $5\%$ 水平下有足够证据表明两种方法的平均成绩不同。原理:$t$ 以标准误为单位衡量两个样本均值的差距;若总体均值相等,出现约三个标准误的差距是不太可能的。(选 Pooled: No 时 GDC 给出 $t = 3.01$,p 值 $= 0.0131$:结论相同。)
Worked Example: A fertiliser claim from summary statistics (one-tailed)例题:由汇总统计量检验肥料说法(单尾)
Problem: A grower claims a new fertiliser increases mean plant height. Treated plants: $n_1 = 12$, $\bar{x}_1 = 24.8$ cm, $s_1 = 3.1$ cm. Untreated: $n_2 = 10$, $\bar{x}_2 = 22.6$ cm, $s_2 = 2.9$ cm. Assume normal populations with equal variances. Test the claim at the $5\%$ level.
Hypotheses: $H_0: \mu_1 = \mu_2$; $H_1: \mu_1 > \mu_2$ (one-tailed, because the claim is an increase).
GDC (2-sample t-test from statistics, Pooled: Yes, $\mu_1 > \mu_2$): $t = 1.71$, $\nu = 20$, p-value $= 0.0517$.
Decision: $0.0517 > 0.05$, so do not reject $H_0$.
Conclusion: there is insufficient evidence at the $5\%$ level that the fertiliser increases mean height. Note how close this is: at the $10\%$ level the decision would be to reject $H_0$, and the two-tailed p-value would be $2 \times 0.0517 = 0.103$. Why this works: in a one-tailed test only one tail counts as "at least as extreme", so when the sample difference is in the claimed direction the one-tailed p-value is half the two-tailed one.
题目:种植者声称新肥料能提高植株平均高度。施肥组:$n_1 = 12$,$\bar{x}_1 = 24.8$ cm,$s_1 = 3.1$ cm。未施肥组:$n_2 = 10$,$\bar{x}_2 = 22.6$ cm,$s_2 = 2.9$ cm。假定两总体服从正态分布且方差相等。在 $5\%$ 水平下检验这一说法。
假设:$H_0: \mu_1 = \mu_2$;$H_1: \mu_1 > \mu_2$(单尾,因为说法是"提高")。
GDC(由统计量做双样本 t 检验,Pooled: Yes,$\mu_1 > \mu_2$):$t = 1.71$,$\nu = 20$,p 值 $= 0.0517$。
判断:$0.0517 > 0.05$,所以不拒绝 $H_0$。
结论:在 $5\%$ 水平下没有足够证据表明该肥料能提高平均高度。注意结果非常接近:在 $10\%$ 水平下会拒绝 $H_0$;而双尾 p 值为 $2 \times 0.0517 = 0.103$。原理:单尾检验中只有一侧尾部算作"至少一样极端",所以当样本差异与所声称的方向一致时,单尾 p 值是双尾 p 值的一半。
Hypotheses are about populations: write $H_0: \mu_1 = \mu_2$, never $H_0: \bar{x}_1 = \bar{x}_2$. The sample means are known numbers; the test asks what they suggest about the unknown population means.
假设针对的是总体:写 $H_0: \mu_1 = \mu_2$,绝不写 $H_0: \bar{x}_1 = \bar{x}_2$。样本均值是已知的数;检验要回答的是它们对未知的总体均值说明了什么。
Define $\mu_1$ and $\mu_2$ in words (which population each is), and make the GDC's alternative ($\ne$, $>$, $<$) match your $H_1$ and the order in which you entered the samples. Use the unbiased standard deviations $s_{n-1}$ (the GDC's $s_x$). State the p-value to 3 significant figures, compare it with the significance level, and conclude about the population means in context.
用文字定义 $\mu_1$ 与 $\mu_2$(分别是哪个总体),并让 GDC 中的备择方向($\ne$、$>$、$<$)与你的 $H_1$ 以及输入样本的顺序一致。使用无偏标准差 $s_{n-1}$(GDC 中的 $s_x$)。p 值保留 3 位有效数字,与显著性水平比较,再结合情境对总体均值下结论。
A company claims its new battery lasts longer on average than the old one. Write the hypotheses and say whether the test is one-tailed or two-tailed.某公司声称新电池的平均续航比旧电池长。写出假设,并说明是单尾还是双尾检验。
Let $\mu_N$ and $\mu_O$ be the population mean lifetimes of new and old batteries. $H_0: \mu_N = \mu_O$; $H_1: \mu_N > \mu_O$. One-tailed, because the claim names a direction.
设 $\mu_N$、$\mu_O$ 分别为新、旧电池的总体平均续航。$H_0: \mu_N = \mu_O$;$H_1: \mu_N > \mu_O$。单尾,因为说法指明了方向。
Sample 1: $n = 8$, $\bar{x} = 15.2$, $s = 2.0$. Sample 2: $n = 9$, $\bar{x} = 14.1$, $s = 2.2$. Assuming normal populations with equal variances, test at the $5\%$ level whether the population means differ.样本 1:$n = 8$,$\bar{x} = 15.2$,$s = 2.0$。样本 2:$n = 9$,$\bar{x} = 14.1$,$s = 2.2$。假定总体服从正态分布且方差相等,在 $5\%$ 水平下检验总体均值是否不同。
$H_0: \mu_1 = \mu_2$; $H_1: \mu_1 \ne \mu_2$. GDC (pooled): $t = 1.07$, $\nu = 15$, p-value $= 0.300$. Since $0.300 > 0.05$, do not reject $H_0$: insufficient evidence that the population means differ.
$H_0: \mu_1 = \mu_2$;$H_1: \mu_1 \ne \mu_2$。GDC(合并方差):$t = 1.07$,$\nu = 15$,p 值 $= 0.300$。由于 $0.300 > 0.05$,不拒绝 $H_0$:没有足够证据表明总体均值不同。
A two-tailed t-test gives p-value $= 0.08$ and $\bar{x}_1 > \bar{x}_2$. Had the question asked whether $\mu_1 > \mu_2$, what would the p-value and decision at $5\%$ be?某双尾 t 检验得 p 值 $= 0.08$,且 $\bar{x}_1 > \bar{x}_2$。若题目问的是 $\mu_1 > \mu_2$ 是否成立,p 值和 $5\%$ 水平下的判断是什么?
The difference is in the claimed direction, so the one-tailed p-value is $\frac{0.08}{2} = 0.04 < 0.05$: reject $H_0$ and conclude there is sufficient evidence that $\mu_1 > \mu_2$. This is why the tail must be decided from the question before the test, not chosen afterwards to get a result.
差异与所声称的方向一致,所以单尾 p 值为 $\frac{0.08}{2} = 0.04 < 0.05$:拒绝 $H_0$,有足够证据表明 $\mu_1 > \mu_2$。正因如此,单尾或双尾必须在检验前由题目决定,而不能事后为了得到结果再选。
Central Limit Theorem and Confidence Intervals for the Mean中心极限定理与均值的置信区间 AHL 4.15 / 4.16 HL
- State the mean and variance of the sample mean $\bar{X}$: $E(\bar{X}) = \mu$ and $\mathrm{Var}(\bar{X}) = \frac{\sigma^2}{n}$.
- State the central limit theorem and when it is needed (a population that is not normal, with a large sample).
- Calculate probabilities about $\bar{X}$ using the normal distribution.
- Calculate a confidence interval for $\mu$ using $z$ when $\sigma$ is known and $t$ when $\sigma$ is unknown.
- Interpret a confidence interval correctly, and explain how its width depends on $n$ and the confidence level.
- 写出(
state)样本均值 $\bar{X}$ 的均值与方差:$E(\bar{X}) = \mu$,$\mathrm{Var}(\bar{X}) = \frac{\sigma^2}{n}$。 - 写出中心极限定理,并说明何时需要它(总体不服从正态分布、样本量较大)。
- 用正态分布计算(
calculate)关于 $\bar{X}$ 的概率。 - $\sigma$ 已知时用 $z$、$\sigma$ 未知时用 $t$,计算 $\mu$ 的置信区间。
- 正确解释(
interpret)置信区间,并说明其宽度如何随 $n$ 与置信水平变化。
The distribution of the sample mean样本均值的分布
Take a random sample $X_1, X_2, \dots, X_n$ from a population with mean $\mu$ and variance $\sigma^2$, and let $\bar{X} = \frac{X_1 + X_2 + \dots + X_n}{n}$. Different samples give different values of $\bar{X}$, so $\bar{X}$ is a random variable with its own distribution, the sampling distribution of the sample mean. Using the rules for linear combinations of independent random variables, $E(\bar{X}) = \mu$ and $\mathrm{Var}(\bar{X}) = \frac{n\sigma^2}{n^2} = \frac{\sigma^2}{n}$. Its standard deviation $\frac{\sigma}{\sqrt{n}}$ is called the standard error: sample means vary less than single observations, and less still as $n$ grows.
从均值为 $\mu$、方差为 $\sigma^2$ 的总体中抽取随机样本 $X_1, X_2, \dots, X_n$,令 $\bar{X} = \frac{X_1 + X_2 + \dots + X_n}{n}$。不同样本给出不同的 $\bar{X}$,所以 $\bar{X}$ 本身是一个随机变量,有自己的分布,即样本均值的抽样分布(sampling distribution)。由独立随机变量线性组合的法则,$E(\bar{X}) = \mu$,$\mathrm{Var}(\bar{X}) = \frac{n\sigma^2}{n^2} = \frac{\sigma^2}{n}$。它的标准差 $\frac{\sigma}{\sqrt{n}}$ 叫作标准误(standard error):样本均值的波动比单个观测值小,且 $n$ 越大越小。
The central limit theorem (CLT). For a population of any shape with mean $\mu$ and finite variance $\sigma^2$, the distribution of $\bar{X}$ is approximately normal when $n$ is large, and the approximation improves as $n$ increases. A common working rule is $n \ge 30$. When the population itself is normal you do not need the CLT: $\bar{X}$ is then exactly normal for any $n$. The CLT also applies to the sum: $X_1 + \dots + X_n$ is approximately $N(n\mu, n\sigma^2)$ for large $n$.
中心极限定理(central limit theorem,CLT)。对任意形状、均值为 $\mu$、方差 $\sigma^2$ 有限的总体,当 $n$ 较大时 $\bar{X}$ 的分布近似为正态,且 $n$ 越大近似越好。常用的经验标准是 $n \ge 30$。若总体本身服从正态分布,就不需要 CLT:此时对任意 $n$,$\bar{X}$ 都恰好服从正态分布。CLT 同样适用于总和:$n$ 较大时 $X_1 + \dots + X_n$ 近似服从 $N(n\mu, n\sigma^2)$。
Worked Example: Waiting times that are not normal例题:不服从正态分布的等候时间
Problem: Waiting times at a clinic have mean $12$ minutes and standard deviation $5$ minutes, with a strongly right-skewed distribution. A random sample of $40$ waiting times is taken. Find the probability that the sample mean exceeds $13$ minutes.
Step 1: justify the model. The population is not normal, but $n = 40$ is large, so by the central limit theorem $\bar{X}$ is approximately $N\!\left(12, \frac{5^2}{40}\right)$.
Step 2: standard error. $\frac{5}{\sqrt{40}} = 0.791$.
$$ P(\bar{X} > 13) = P\!\left(Z > \frac{13 - 12}{5/\sqrt{40}}\right) = P(Z > 1.265) = 0.103 $$GDC: normal cdf with lower bound $13$, upper bound a large number, mean $12$, standard deviation $\frac{5}{\sqrt{40}}$: $0.103$ (3 s.f.).
Why this works: a single wait above $13$ minutes is common, but the average of $40$ waits is pulled towards $12$, so it exceeds $13$ only about $10\%$ of the time.
题目:某诊所等候时间的均值为 $12$ 分钟,标准差为 $5$ 分钟,分布明显右偏。随机抽取 $40$ 个等候时间。求样本均值超过 $13$ 分钟的概率。
第 1 步:说明模型依据。总体不服从正态分布,但 $n = 40$ 较大,所以由中心极限定理,$\bar{X}$ 近似服从 $N\!\left(12, \frac{5^2}{40}\right)$。
第 2 步:标准误。$\frac{5}{\sqrt{40}} = 0.791$。
$$ P(\bar{X} > 13) = P\!\left(Z > \frac{13 - 12}{5/\sqrt{40}}\right) = P(Z > 1.265) = 0.103 $$GDC:正态累积分布,下限 $13$,上限取很大的数,均值 $12$,标准差 $\frac{5}{\sqrt{40}}$:$0.103$(3 s.f.)。
原理:单次等候超过 $13$ 分钟很常见,但 $40$ 次的平均值会被拉向 $12$,所以只有大约 $10\%$ 的时候超过 $13$。
Confidence intervals for the mean均值的置信区间
Definition. A confidence interval is a range of plausible values for the population mean $\mu$, built from one sample as estimate $\pm$ margin of error. A $95\%$ confidence interval comes from a method that captures $\mu$ in $95\%$ of repeated samples. When $\sigma$ is known (and the population is normal, or $n$ is large), use the normal distribution; when the variance is unknown and the population is normal, replace $\sigma$ by $s_{n-1}$ and use the t-distribution with $\nu = n - 1$.
定义。置信区间(confidence interval)是由一个样本构造的、总体均值 $\mu$ 的合理取值范围,形式为"估计值 $\pm$ 误差范围"。$95\%$ 置信区间来自这样一种方法:在重复抽样中,有 $95\%$ 的区间能包含 $\mu$。$\sigma$ 已知(且总体服从正态分布,或 $n$ 很大)时用正态分布;方差未知(variance unknown)且总体服从正态分布时,用 $s_{n-1}$ 代替 $\sigma$,并使用自由度 $\nu = n - 1$ 的 t 分布。
Worked Example: A 95% interval with known standard deviation例题:标准差已知时的 95% 区间
Problem: The masses of apples from an orchard are normally distributed with standard deviation $4.2$ g. A random sample of $25$ apples has mean $71.3$ g. Find a $95\%$ confidence interval for the population mean mass.
Standard error: $\frac{4.2}{\sqrt{25}} = 0.84$. Margin: $1.960 \times 0.84 = 1.646$.
$$ 71.3 \pm 1.646 \;\Rightarrow\; (69.7,\ 72.9) \text{ g (3 s.f.)} $$GDC: z-interval with $\sigma = 4.2$, $\bar{x} = 71.3$, $n = 25$, level $0.95$ gives $(69.65, 72.95)$.
Interpretation: we are $95\%$ confident that the population mean mass lies between $69.7$ g and $72.9$ g. Why this works: $\bar{X}$ lies within $1.960$ standard errors of $\mu$ with probability $0.95$, so the interval built around $\bar{x}$ reaches $\mu$ in $95\%$ of samples.
题目:某果园苹果的质量服从正态分布,标准差为 $4.2$ g。随机抽取 $25$ 个苹果,平均质量为 $71.3$ g。求总体平均质量的 $95\%$ 置信区间。
标准误:$\frac{4.2}{\sqrt{25}} = 0.84$。误差范围:$1.960 \times 0.84 = 1.646$。
$$ 71.3 \pm 1.646 \;\Rightarrow\; (69.7,\ 72.9) \text{ g (3 s.f.)} $$GDC:z 区间,$\sigma = 4.2$,$\bar{x} = 71.3$,$n = 25$,置信水平 $0.95$,得 $(69.65, 72.95)$。
解释:我们有 $95\%$ 的把握认为总体平均质量在 $69.7$ g 与 $72.9$ g 之间。原理:$\bar{X}$ 以 $0.95$ 的概率落在 $\mu$ 的 $1.960$ 个标准误以内,所以以 $\bar{x}$ 为中心构造的区间在 $95\%$ 的样本中能覆盖 $\mu$。
Worked Example: A t-interval when the variance is unknown例题:方差未知时的 t 区间
Problem: The battery lives (hours) of $10$ phones of one model are $12.1, 11.6, 12.8, 12.3, 11.9, 12.5, 12.0, 12.7, 11.8, 12.4$. Assuming battery life is normally distributed, find a $95\%$ confidence interval for the mean battery life. The maker claims a mean of $13$ hours: comment.
Summary: $\bar{x} = \frac{122.1}{10} = 12.21$, $s_{n-1} = 0.3957$. The population standard deviation is unknown, so use $t$ with $\nu = 10 - 1 = 9$: $t^{*} = 2.262$.
$$ 12.21 \pm 2.262 \times \frac{0.3957}{\sqrt{10}} = 12.21 \pm 0.283 \;\Rightarrow\; (11.9,\ 12.5) \text{ hours (3 s.f.)} $$GDC: t-interval from the data list, level $0.95$: $(11.93, 12.49)$.
Comment: $13$ hours lies outside the interval (above it), so the sample does not support the maker's claim of a $13$-hour mean. Why $t$: estimating $\sigma$ from only $10$ values adds uncertainty, and $t^{*} = 2.262$ is wider than $z^{*} = 1.960$ to allow for it.
题目:某型号 $10$ 部手机的电池续航(小时)为 $12.1, 11.6, 12.8, 12.3, 11.9, 12.5, 12.0, 12.7, 11.8, 12.4$。假定续航服从正态分布,求平均续航的 $95\%$ 置信区间。厂商声称平均续航为 $13$ 小时:请评论。
汇总:$\bar{x} = \frac{122.1}{10} = 12.21$,$s_{n-1} = 0.3957$。总体标准差未知,所以用自由度 $\nu = 10 - 1 = 9$ 的 $t$:$t^{*} = 2.262$。
$$ 12.21 \pm 2.262 \times \frac{0.3957}{\sqrt{10}} = 12.21 \pm 0.283 \;\Rightarrow\; (11.9,\ 12.5) \text{ hours (3 s.f.)} $$GDC:由数据列表求 t 区间,置信水平 $0.95$:$(11.93, 12.49)$。
评论:$13$ 小时在区间之外(高于区间),所以样本不支持厂商"平均 $13$ 小时"的说法。为什么用 $t$:只用 $10$ 个数据估计 $\sigma$ 带来额外的不确定性,$t^{*} = 2.262$ 比 $z^{*} = 1.960$ 宽,正是为此留出余地。
Once the interval is calculated, $\mu$ is either in it or not. The $95\%$ describes the method: in the long run, $95\%$ of intervals built this way contain $\mu$. Also, a wider interval comes from a higher confidence level or a smaller $n$; to halve the width you need four times the sample size, because the width is proportional to $\frac{1}{\sqrt{n}}$.
区间一旦算出,$\mu$ 要么在其中,要么不在。$95\%$ 描述的是方法:长期来看,用这种方法构造的区间有 $95\%$ 包含 $\mu$。另外,置信水平越高或 $n$ 越小,区间越宽;宽度与 $\frac{1}{\sqrt{n}}$ 成正比,所以要让宽度减半,样本量需要变为四倍。
Say which interval you are using and why ("$\sigma$ known, so a z-interval"; "$\sigma$ unknown and the population is normal, so a t-interval with $\nu = 9$"). When you use the CLT, name it and give the reason ($n$ is large, the population is not normal). Give the interval with units, to 3 significant figures unless told otherwise, and interpret it in context with the word "confident", not "probability".
写明用的是哪种区间及原因("$\sigma$ 已知,所以用 z 区间";"$\sigma$ 未知且总体服从正态分布,所以用 $\nu = 9$ 的 t 区间")。使用 CLT 时要点名并给出理由($n$ 较大,总体不服从正态分布)。区间要带单位,除非另有要求保留 3 位有效数字,并结合情境用"有把握"(confident)而不是"概率"来解释。
A population has $\sigma = 12$. Find the standard error of the mean for samples of size $36$.某总体 $\sigma = 12$。求样本量为 $36$ 时均值的标准误。
$\frac{\sigma}{\sqrt{n}} = \frac{12}{\sqrt{36}} = 2$.
$\frac{\sigma}{\sqrt{n}} = \frac{12}{\sqrt{36}} = 2$。
$X \sim N(500, 4^2)$. A sample of $9$ is taken. Find $P(\bar{X} < 498)$. Is the CLT needed?$X \sim N(500, 4^2)$。抽取容量为 $9$ 的样本。求 $P(\bar{X} < 498)$。需要用 CLT 吗?
No: the population is normal, so $\bar{X} \sim N\!\left(500, \frac{16}{9}\right)$ exactly, with standard error $\frac{4}{3}$. $P(\bar{X} < 498) = P(Z < -1.5) = 0.0668$.
不需要:总体服从正态分布,所以 $\bar{X} \sim N\!\left(500, \frac{16}{9}\right)$ 恰好成立,标准误为 $\frac{4}{3}$。$P(\bar{X} < 498) = P(Z < -1.5) = 0.0668$。
$\sigma = 3$, $n = 36$, $\bar{x} = 18.4$. Find a $99\%$ confidence interval for $\mu$.$\sigma = 3$,$n = 36$,$\bar{x} = 18.4$。求 $\mu$ 的 $99\%$ 置信区间。
Standard error $\frac{3}{6} = 0.5$; margin $2.576 \times 0.5 = 1.288$. Interval $18.4 \pm 1.288 = (17.1, 19.7)$ to 3 s.f.
标准误 $\frac{3}{6} = 0.5$;误差范围 $2.576 \times 0.5 = 1.288$。区间 $18.4 \pm 1.288 = (17.1, 19.7)$(3 s.f.)。
Critical Regions, Tests for a Mean and a Proportion, Type I and II Errors拒绝域、均值与比例的检验、第一类与第二类错误 AHL 4.18 HL
- Define the critical region and critical value of a test, and find them for a normal or binomial test statistic.
- Carry out a test for a population mean using $z$ ($\sigma$ known) or $t$ ($\sigma$ unknown, normal population).
- Carry out a test for a population proportion using the binomial distribution.
- Define type I and type II errors in context.
- Calculate the probability of a type I error and the probability of a type II error for a stated alternative value.
- Explain how changing the significance level affects the two error probabilities.
- 定义(
define)检验的拒绝域与临界值,并对正态或二项检验统计量求出它们。 - 用 $z$($\sigma$ 已知)或 $t$($\sigma$ 未知、总体正态)进行总体均值的检验。
- 用二项分布进行总体比例的检验。
- 结合情境定义第一类错误与第二类错误。
- 计算(
calculate)第一类错误的概率,以及在给定备择值下第二类错误的概率。 - 解释(
explain)改变显著性水平如何影响两类错误的概率。
Critical regions and critical values拒绝域与临界值
Definition. The critical region is the set of values of the test statistic for which $H_0$ is rejected; the critical value is its boundary. It is fixed before the data are seen, from $H_1$ and the significance level: for a continuous statistic the critical region has probability exactly $\alpha$ under $H_0$; for a discrete (binomial) statistic it is the largest region whose probability under $H_0$ does not exceed $\alpha$, and that probability is the actual significance level. A one-tailed $H_1$ puts the whole region in one tail; a two-tailed $H_1$ splits it, $\frac{\alpha}{2}$ in each tail.
定义。拒绝域(critical region)是使 $H_0$ 被拒绝的检验统计量取值集合;临界值(critical value)是它的边界。拒绝域在看到数据之前就由 $H_1$ 和显著性水平确定:对连续型统计量,拒绝域在 $H_0$ 下的概率恰为 $\alpha$;对离散型(二项)统计量,取在 $H_0$ 下概率不超过 $\alpha$ 的最大区域,这个概率就是实际显著性水平(actual significance level)。单尾 $H_1$ 把整个拒绝域放在一侧尾部;双尾 $H_1$ 把它分成两半,每侧 $\frac{\alpha}{2}$。
Tests for a population mean and a population proportion总体均值与总体比例的检验
Test for a population mean. $H_0: \mu = \mu_0$. If $\sigma$ is known and the population is normal (or $n$ is large, by the CLT), use $Z = \frac{\bar{X} - \mu_0}{\sigma/\sqrt{n}}$, which is $N(0, 1)$ under $H_0$. If $\sigma$ is unknown and the population is normal, use the one-sample t-test with $T = \frac{\bar{X} - \mu_0}{s_{n-1}/\sqrt{n}}$ and $\nu = n - 1$. Test for a population proportion. $H_0: p = p_0$. The number of successes in $n$ independent trials is $X \sim B(n, p_0)$ under $H_0$, so the p-value and the critical region come straight from binomial probabilities.
总体均值的检验。$H_0: \mu = \mu_0$。若 $\sigma$ 已知且总体服从正态分布(或由 CLT,$n$ 较大),用 $Z = \frac{\bar{X} - \mu_0}{\sigma/\sqrt{n}}$,它在 $H_0$ 下服从 $N(0, 1)$。若 $\sigma$ 未知且总体服从正态分布,用单样本 t 检验,$T = \frac{\bar{X} - \mu_0}{s_{n-1}/\sqrt{n}}$,$\nu = n - 1$。总体比例的检验。$H_0: p = p_0$。在 $H_0$ 下,$n$ 次独立试验中的成功次数 $X \sim B(n, p_0)$,所以 p 值和拒绝域直接由二项概率得出。
Type I and type II errors第一类错误与第二类错误
A type I error is rejecting $H_0$ when $H_0$ is true. A type II error is not rejecting $H_0$ when $H_0$ is false. The probability of a type I error is the probability that the test statistic falls in the critical region when $H_0$ is true: $\alpha$ for a continuous statistic, the actual significance level for a binomial one. The probability of a type II error, often written $\beta$, can only be found for a stated value of the parameter under $H_1$: it is the probability that the statistic falls outside the critical region when the parameter has that value. $1 - \beta$ is the power of the test.
第一类错误(type I error)是 $H_0$ 为真时拒绝了 $H_0$。第二类错误(type II error)是 $H_0$ 为假时没有拒绝 $H_0$。第一类错误的概率是 $H_0$ 为真时检验统计量落入拒绝域的概率:连续型统计量为 $\alpha$,二项统计量为实际显著性水平。第二类错误的概率常记为 $\beta$,只有给定 $H_1$ 下参数的某个具体值时才能计算:它是参数取该值时统计量落在拒绝域之外的概率。$1 - \beta$ 称为检验的功效(power)。
Worked Example: Critical region for a mean, and a type II error例题:均值的拒绝域与第二类错误
Problem: Scores on a reasoning test are normally distributed with mean $50$ and standard deviation $6$. A tutor believes a new course raises the mean score, with $\sigma$ unchanged. A random sample of $16$ students who took the course has mean $52.9$. (a) Find the critical region for a test at the $5\%$ level. (b) Carry out the test. (c) Find the probability of a type II error if the true mean is $54$.
Hypotheses: $H_0: \mu = 50$; $H_1: \mu > 50$, where $\mu$ is the population mean score after the course. Under $H_0$, $\bar{X} \sim N\!\left(50, \frac{6^2}{16}\right)$, standard error $1.5$.
(a) Upper $5\%$ point of $N(0, 1)$: $1.645$. Critical value $50 + 1.645 \times 1.5 = 52.47$ (more precisely $52.467$), so the critical region is $\bar{x} \ge 52.47$ (GDC: inverse normal, area $0.95$, mean $50$, standard deviation $1.5$, gives $52.47$).
(b) $52.9 \ge 52.47$, so $\bar{x}$ lies in the critical region: reject $H_0$. (Check: $z = \frac{52.9 - 50}{1.5} = 1.93$, p-value $= 0.0266 < 0.05$.) There is sufficient evidence at the $5\%$ level that the course raises the mean score.
(c) A type II error happens if $\bar{X} < 52.47$ although $\mu = 54$:
$$ P(\bar{X} < 52.467 \mid \mu = 54) = P\!\left(Z < \frac{52.467 - 54}{1.5}\right) = P(Z < -1.022) = 0.153 $$Figure 3 shows both regions. Why this works: the critical region is fixed by $H_0$; the type II probability is the area of the other curve that falls outside it.
题目:某推理测试的分数服从正态分布,均值 $50$,标准差 $6$。一位导师认为新课程能提高平均分,且 $\sigma$ 不变。随机抽取上过课程的 $16$ 名学生,平均分为 $52.9$。(a) 求 $5\%$ 水平检验的拒绝域。(b) 进行检验。(c) 若真实均值为 $54$,求第二类错误的概率。
假设:$H_0: \mu = 50$;$H_1: \mu > 50$,其中 $\mu$ 为上课后的总体平均分。在 $H_0$ 下 $\bar{X} \sim N\!\left(50, \frac{6^2}{16}\right)$,标准误为 $1.5$。
(a) $N(0, 1)$ 的上侧 $5\%$ 分位点:$1.645$。临界值 $50 + 1.645 \times 1.5 = 52.47$(更精确为 $52.467$),所以拒绝域为 $\bar{x} \ge 52.47$(GDC:逆正态,面积 $0.95$,均值 $50$,标准差 $1.5$,得 $52.47$)。
(b) $52.9 \ge 52.47$,所以 $\bar{x}$ 落在拒绝域内:拒绝 $H_0$。(验算:$z = \frac{52.9 - 50}{1.5} = 1.93$,p 值 $= 0.0266 < 0.05$。)在 $5\%$ 水平下有足够证据表明该课程提高了平均分。
(c) 若 $\mu = 54$ 而 $\bar{X} < 52.47$,就犯了第二类错误:
$$ P(\bar{X} < 52.467 \mid \mu = 54) = P\!\left(Z < \frac{52.467 - 54}{1.5}\right) = P(Z < -1.022) = 0.153 $$图 3 画出了这两个区域。原理:拒绝域由 $H_0$ 确定;第二类错误的概率就是另一条曲线落在拒绝域之外的面积。
Worked Example: Test for a proportion with the binomial distribution例题:用二项分布检验比例
Problem: In the past, $30\%$ of a café's customers ordered the vegetarian dish. After a menu change the owner believes this proportion has increased. In a random sample of $20$ customers, $X$ order it. (a) Find the critical region at the $5\%$ level and the probability of a type I error. (b) $11$ customers order the dish: state the conclusion. (c) Find the probability of a type II error if the true proportion is $0.5$.
Hypotheses: $H_0: p = 0.3$; $H_1: p > 0.3$, where $p$ is the proportion of all customers who order the vegetarian dish. Under $H_0$, $X \sim B(20, 0.3)$.
(a) GDC binomial cdf: $P(X \ge 9) = 1 - P(X \le 8) = 0.113 > 0.05$, but $P(X \ge 10) = 1 - P(X \le 9) = 0.0480 \le 0.05$. Critical region: $X \ge 10$. The probability of a type I error is the actual significance level, $0.0480$.
(b) $11$ lies in the critical region (p-value $P(X \ge 11) = 0.0171$), so reject $H_0$: there is sufficient evidence at the $5\%$ level that the proportion ordering the vegetarian dish has increased.
(c) A type II error is $X \le 9$ when $p = 0.5$: $P(X \le 9) = 0.412$ with $X \sim B(20, 0.5)$.
Why this works: $X$ is discrete, so no region has probability exactly $0.05$; choosing the largest region with probability at most $0.05$ keeps the type I error probability within the stated level.
题目:过去某咖啡馆 $30\%$ 的顾客点素食菜。改菜单后,店主认为这一比例上升了。随机抽取 $20$ 名顾客,其中 $X$ 人点了素食。(a) 求 $5\%$ 水平的拒绝域以及第一类错误的概率。(b) 有 $11$ 名顾客点了素食:写出结论。(c) 若真实比例为 $0.5$,求第二类错误的概率。
假设:$H_0: p = 0.3$;$H_1: p > 0.3$,其中 $p$ 为全体顾客中点素食的比例。在 $H_0$ 下 $X \sim B(20, 0.3)$。
(a) GDC 二项累积分布:$P(X \ge 9) = 1 - P(X \le 8) = 0.113 > 0.05$,而 $P(X \ge 10) = 1 - P(X \le 9) = 0.0480 \le 0.05$。拒绝域:$X \ge 10$。第一类错误的概率就是实际显著性水平 $0.0480$。
(b) $11$ 落在拒绝域内(p 值 $P(X \ge 11) = 0.0171$),所以拒绝 $H_0$:在 $5\%$ 水平下有足够证据表明点素食的比例上升了。
(c) 当 $p = 0.5$ 时,第二类错误即 $X \le 9$:$X \sim B(20, 0.5)$,$P(X \le 9) = 0.412$。
原理:$X$ 是离散的,没有哪个区域的概率恰好是 $0.05$;取概率不超过 $0.05$ 的最大区域,能让第一类错误的概率不超过所定水平。
For a binomial test the probability of a type I error is the actual significance level ($0.0480$ above), not $0.05$. And $\beta$ is not $1 - \alpha$: it depends on the true parameter value and must be computed from the distribution under that value. Lowering $\alpha$ moves the critical value outward, which makes a type I error less likely but a type II error more likely, for the same $n$.
二项检验中第一类错误的概率是实际显著性水平(上例为 $0.0480$),而不是 $0.05$。$\beta$ 也不是 $1 - \alpha$:它取决于参数的真实值,必须用该值下的分布来计算。在 $n$ 不变时,降低 $\alpha$ 会把临界值向外推,使第一类错误更不容易发生,但第二类错误更容易发生。
Write a critical region as an inequality in the test statistic ($\bar{x} \ge 52.47$, $X \ge 10$), and for a binomial test show the two cumulative probabilities either side of $\alpha$ that justify the boundary. Define each error in the words of the context ("concluding the course raises the mean when it does not"). For a type II probability, state the alternative value you are using and which distribution the statistic follows under it.
把拒绝域写成关于检验统计量的不等式($\bar{x} \ge 52.47$,$X \ge 10$);二项检验要写出 $\alpha$ 两侧的两个累积概率,以说明边界的由来。结合情境的语言定义每类错误("课程其实没有提高均值,却得出提高了的结论")。求第二类错误概率时,写明所用的备择值以及统计量在该值下服从的分布。
For the café test above, describe a type I error and a type II error in context.对上面咖啡馆的检验,结合情境描述第一类错误和第二类错误。
Type I: concluding that the proportion ordering the vegetarian dish has increased when it is still $0.3$. Type II: failing to conclude that it has increased when it really has.
第一类错误:比例其实仍为 $0.3$,却得出点素食比例上升的结论。第二类错误:比例确实上升了,却没有得出上升的结论。
With critical region $X \ge 10$ for $X \sim B(20, p)$, find the probability of a type II error when $p = 0.4$.拒绝域为 $X \ge 10$,$X \sim B(20, p)$。求 $p = 0.4$ 时第二类错误的概率。
$P(X \le 9)$ with $X \sim B(20, 0.4)$ is $0.755$. It is larger than when $p = 0.5$ ($0.412$): an alternative closer to $H_0$ is harder to detect.
$X \sim B(20, 0.4)$ 时 $P(X \le 9)$ 为 $0.755$。它比 $p = 0.5$ 时($0.412$)更大:越接近 $H_0$ 的备择值越难被检测出来。
Packs are labelled $500$ g. A sample of $8$ packs has masses $498, 503, 495, 500, 492, 497, 494, 499$ g. Assuming normal masses with unknown $\sigma$, test at the $5\%$ level whether the mean mass is less than $500$ g.包装标注 $500$ g。抽取 $8$ 包,质量为 $498, 503, 495, 500, 492, 497, 494, 499$ g。假定质量服从正态分布且 $\sigma$ 未知,在 $5\%$ 水平下检验平均质量是否小于 $500$ g。
$H_0: \mu = 500$; $H_1: \mu < 500$. $\bar{x} = 497.25$, $s_{n-1} = 3.536$. One-sample t-test, $\nu = 7$: $t = \frac{497.25 - 500}{3.536/\sqrt{8}} = -2.20$, p-value $= 0.0319 < 0.05$. Reject $H_0$: there is sufficient evidence at the $5\%$ level that the mean mass is less than $500$ g.
$H_0: \mu = 500$;$H_1: \mu < 500$。$\bar{x} = 497.25$,$s_{n-1} = 3.536$。单样本 t 检验,$\nu = 7$:$t = \frac{497.25 - 500}{3.536/\sqrt{8}} = -2.20$,p 值 $= 0.0319 < 0.05$。拒绝 $H_0$:在 $5\%$ 水平下有足够证据表明平均质量小于 $500$ g。
Exam Strategy & Common Pitfalls考试策略与常见陷阱
- Tied ranks get the average of the ranks they occupy
- 并列数值取所占名次的平均值
- $f_e = \frac{\text{row total} \times \text{column total}}{\text{grand total}}$ and $\nu = (r-1)(c-1)$
- $f_e = \frac{\text{row total} \times \text{column total}}{\text{grand total}}$ 与 $\nu = (r-1)(c-1)$
- Goodness of fit: $\nu = k - 1 - m$
- 拟合优度:$\nu = k - 1 - m$
- Every expected frequency at least $5$, otherwise combine
- 每个期望频数至少为 $5$,否则合并
- $\bar{X} \sim N\!\left(\mu, \frac{\sigma^2}{n}\right)$ and the interval $\bar{x} \pm z^{*}\frac{\sigma}{\sqrt{n}}$ HL
- $\bar{X} \sim N\!\left(\mu, \frac{\sigma^2}{n}\right)$ 与区间 $\bar{x} \pm z^{*}\frac{\sigma}{\sqrt{n}}$ HL
- Spearman measures monotonic association; Pearson measures linear association
- 斯皮尔曼衡量单调关系;皮尔逊衡量线性关系
- The p-value is calculated assuming $H_0$ is true; it is not the probability that $H_0$ is true
- p 值是在假定 $H_0$ 成立时算出的;它不是 $H_0$ 为真的概率
- Why estimating a parameter costs a degree of freedom
- 为什么估计一个参数要减少一个自由度
- The tail of a test comes from the question, before the data are seen
- 单尾还是双尾由题目决定,在看到数据之前就已确定
- Lowering $\alpha$ makes a type II error more likely for the same $n$ HL
- $n$ 不变时,降低 $\alpha$ 会使第二类错误更容易发生 HL
Common Pitfalls常见陷阱
1. Writing "accept $H_0$" instead of "do not reject $H_0$".
2. Hypotheses only in symbols, or about sample statistics ($\bar{x}$) instead of population parameters ($\mu$).
3. Running a chi-squared test without checking that every expected frequency is at least $5$.
4. Forgetting to subtract the estimated parameters from the goodness of fit degrees of freedom.
5. Using the $\sum d^2$ shortcut for $r_s$ when there are tied ranks.
6. Choosing a one-tailed test after seeing which sample mean is larger.
7. A conclusion with no context: always name the variables or the populations.
1. 写"接受 $H_0$",而不是"不拒绝 $H_0$"。
2. 假设只用符号写,或针对样本统计量($\bar{x}$)而不是总体参数($\mu$)。
3. 做卡方检验时没有检查每个期望频数是否至少为 $5$。
4. 拟合优度检验的自由度忘记减去估计参数的个数。
5. 有并列名次时仍用 $\sum d^2$ 简化公式求 $r_s$。
6. 看到哪个样本均值更大之后才选择单尾检验。
7. 结论不结合情境:一定要说出具体的变量或总体。
8. Using $z$ when $\sigma$ is unknown and $n$ is small: use $t$ with $\nu = n - 1$.
9. Saying "there is a $95\%$ probability that $\mu$ lies in the interval".
10. Giving $0.05$ as the probability of a type I error for a binomial test, instead of the actual significance level.
8. $\sigma$ 未知且 $n$ 较小时仍用 $z$:应使用 $\nu = n - 1$ 的 $t$。
9. 说"$\mu$ 有 $95\%$ 的概率落在区间内"。
10. 二项检验中把第一类错误的概率写成 $0.05$,而不是实际显著性水平。
Paper 1 (compulsory short-response questions) and Paper 2 (compulsory extended-response questions) each last 2 hours, carry 110 marks and are each worth 30%. Paper 3 (55 marks, 20%) has two compulsory extended-response problems. Technology is required on Papers 1, 2 and 3. The internal assessment, a mathematical exploration, is the remaining 20%. In this unit that means learning the GDC routes for each test and interval as well as the reasoning around them.
Paper 1(必答短答题)与 Paper 2(必答长答题)各 2 小时、各 110 分、各占 30%。Paper 3(55 分,占 20%)有两道必答的长答题。Paper 1、2、3 都要求使用技术工具。其余 20% 是内部评估(internal assessment),即数学探究(mathematical exploration)。对本单元而言,这意味着既要熟悉每种检验和区间的 GDC 操作,也要掌握其背后的推理。
SL has Papers 1 and 2 only, each lasting 1 hour 30 minutes and each worth 40%; there is no Paper 3 at SL. The internal assessment, a mathematical exploration, is the remaining 20%. Technology is required on both papers, so learn the GDC routes for Spearman's $r_s$, the chi-squared tests and the t-test, and the written steps around them.
SL 只有 Paper 1 和 Paper 2,各 1 小时 30 分钟,各占 40%;SL 没有 Paper 3。其余 20% 是内部评估(internal assessment),即数学探究(mathematical exploration)。两份试卷都要求使用技术工具,所以要熟悉斯皮尔曼 $r_s$、卡方检验和 t 检验的 GDC 操作,以及围绕它们的书面步骤。
Flashcards闪卡
Unit D5: Practice QuizD5 单元:练习测验
Ten mixed-difficulty items. Your score updates in real time at the top of the page. Items labelled (HL) cover AHL 4.15, 4.16 and 4.18, which are HL only.
10 道难度混合的题目,得分会在页面顶部实时更新。标有(HL)的题属于 AHL 4.15、4.16 与 4.18,仅 HL 学生需要。
Readiness Checklist备考清单
Click each item you've mastered. Items labelled (HL) are AHL 4.15, 4.16 and 4.18 and apply only to HL students.
每掌握一条就点一下。标有(HL)的条目属于 AHL 4.15、4.16 与 4.18,仅 HL 学生需要。
- Rank two variables, giving tied values the average rank能给两个变量排名,并列数值取平均名次 SL 4.10
- Calculate $r_s$ with the GDC, and with $1 - \frac{6\sum d^2}{n(n^2-1)}$ when there are no ties能用 GDC 计算 $r_s$;无并列时也能用 $1 - \frac{6\sum d^2}{n(n^2-1)}$ SL 4.10
- Interpret $r_s$ as monotonic association and compare it with Pearson's $r$能把 $r_s$ 解释为单调关系,并与皮尔逊 $r$ 比较 SL 4.10
- State $H_0$ and $H_1$ in context and choose a one-tailed or two-tailed test from the question能结合情境写出 $H_0$ 与 $H_1$,并根据题目选择单尾或双尾 SL 4.11
- Define the p-value and significance level, and conclude without "accepting" $H_0$能定义 p 值与显著性水平,下结论时不"接受" $H_0$ SL 4.11
- Calculate expected frequencies and degrees of freedom for a contingency table能计算列联表的期望频数与自由度 SL 4.11
- Check the expected-frequency condition and combine classes when needed能检查期望频数条件,必要时合并组 SL 4.11
- Carry out a goodness of fit test, subtracting estimated parameters from $\nu$能做拟合优度检验,并从 $\nu$ 中减去估计参数的个数 SL 4.11
- State the assumptions of the two-sample t-test and carry it out on the GDC能写出双样本 t 检验的前提,并用 GDC 完成检验 SL 4.11
- Use the distribution of $\bar{X}$ and the central limit theorem (HL)能使用 $\bar{X}$ 的分布与中心极限定理(HL) AHL 4.15
- Calculate and interpret z and t confidence intervals for the mean (HL)能计算并解释均值的 z 区间与 t 区间(HL) AHL 4.16
- Find a critical region for a normal or binomial test statistic (HL)能求正态或二项检验统计量的拒绝域(HL) AHL 4.18
- Carry out tests for a population mean and a population proportion (HL)能进行总体均值与总体比例的检验(HL) AHL 4.18
- Define type I and II errors and calculate their probabilities (HL)能定义第一类与第二类错误并计算其概率(HL) AHL 4.18
How to use this guide本指南使用说明
How to use this guide本指南使用说明
Read the Unit Cram Cheat-Sheet at the top, then one worked example per section. Learn the decision rule, the two chi-squared degrees-of-freedom rules, the confidence-interval formulas and the definitions of type I and type II errors. Take the practice quiz.
先读顶部的 Unit Cram Cheat-Sheet(单元速记小抄),再每节看一道例题。记住判断规则、两条卡方自由度规则、置信区间公式以及第一类、第二类错误的定义。做练习测验。
Read the Unit Cram Cheat-Sheet at the top, then one worked example per section. Learn the decision rule, the two chi-squared degrees-of-freedom rules and the assumptions of the t-test. Take the practice quiz.
先读顶部的 Unit Cram Cheat-Sheet(单元速记小抄),再每节看一道例题。记住判断规则、两条卡方自由度规则以及 t 检验的前提条件。做练习测验。
Work every worked example with the GDC open and then by formula, so you can explain what each output means. Practise writing hypotheses and conclusions in full sentences, and practise type II error calculations for both normal and binomial statistics until the set-up is automatic.
每道例题都先开着 GDC 做一遍,再用公式算一遍,做到能解释每个输出的含义。练习用完整的句子写假设与结论,并反复练习正态与二项统计量的第二类错误计算,直到设定步骤成为本能。
Work every worked example with the GDC open and then by formula, so you can explain what each output means. Practise writing hypotheses and conclusions in full sentences, and practise combining classes and counting degrees of freedom until it is automatic.
每道例题都先开着 GDC 做一遍,再用公式算一遍,做到能解释每个输出的含义。练习用完整的句子写假设与结论,并反复练习合并组与计算自由度,直到成为本能。
Sections D5.5 and D5.6 (AHL 4.15, 4.16 and 4.18) are HL only. Sections D5.1 to D5.4 (SL 4.10 and 4.11) are core for both SL and HL students.
D5.5 与 D5.6 节(AHL 4.15、4.16 与 4.18)仅限 HL。D5.1 至 D5.4 节(SL 4.10 与 4.11)是 SL 与 HL 共同的核心内容。
Sections D5.1 to D5.4 cover the SL content of this unit (SL 4.10 and 4.11). Sections D5.5 and D5.6 are HL only and are hidden in the SL view.
D5.1 至 D5.4 节涵盖本单元的 SL 内容(SL 4.10 与 4.11)。D5.5 与 D5.6 节仅限 HL,在 SL 版本中隐藏。