# Statistics Formula Sheet: [Your course or exam]

> A one-file formula sheet for a full introductory and intermediate statistics course: descriptive statistics,
> probability, distributions, standard errors, confidence intervals, the common tests, ANOVA, correlation and
> regression, logistic and Poisson links, effect sizes, power and Bayes' theorem. Every formula comes with a
> plain-language meaning, a "use when" rule and the most common slip, and a numeric check table whose numbers were
> verified in R and Python. It is for students preparing for exams, thesis writers who need a quick reference, and
> analysts checking software output by hand. It speeds up learning because you test yourself on it (cover the
> formula, recall it, check) instead of rereading it. The worked examples use fictional data; replace them with your
> own.
> Source basis: standard textbook formulas written in our own notation, checked against the NIST/SEMATECH
> e-Handbook of Statistical Methods and the original method papers.

<!--
Guidance: How to use this template
- Print or pin this sheet, but do not just read it: cover the formula column, say the formula from memory, then check.
- Work through the "Worked numeric check" section with a calculator once, then reproduce one row per day.
- Add your course's own notation in "Notation" if your lecturer uses different symbols (for example s vs sigma-hat).
- When an exam allows a formula sheet, copy only the formulas you still miss in the self-test: the act of selecting is itself practice.
- Log every formula slip in your error log with the "Common slip" line that matches it.
- Related templates: academic/stats-learning-roadmap, academic/stats-error-log, academic/stats-flashcards-spaced-review, academic/stats-worked-problem, academic/stats-test-selector, academic/stats-distributions-sheet, academic/stats-effect-sizes, academic/stats-power-sample-size, academic/stats-confidence-intervals, academic/stats-hypothesis-testing, academic/study-guide
-->

## Document control

<!-- Guidance: Record the course and the software you will check numbers with, so that differences in defaults (for example Welch vs pooled t) are traceable. -->

| Field | Value |
|---|---|
| Course or project | [STAT 201 Inferential Statistics, Lakemoor University (fictional)] |
| Learner or analyst | [Your name] |
| Data set | Fictional check data typed in the code below (exam scores, study hours, library counts) |
| Software and versions | R 4.5.1 (base `stats`); Python 3.14 with numpy 2.5.4, scipy 1.18.1, statsmodels 0.15.0 |
| Date | YYYY-MM-DD |
| Version | [0.1] |

## How to use this sheet

<!-- Guidance: Read this once. The sheet is a retrieval tool, not a reading text: the value comes from recalling, not from looking. -->

A formula sheet is most useful when you have already built the idea behind each formula. Each entry below follows
the same order: what the quantity means in one sentence, the formula, when to use it, and the slip that students make
most often. Read the meaning, close your eyes, and try to write the formula. Then check. If you got it wrong, write the
slip into your error log (see academic/stats-error-log) and add a flashcard (see academic/stats-flashcards-spaced-review).

Three habits make the sheet pay off quickly. First, always ask "what is the standard error here?" because almost every
interval and test is built as estimate plus or minus a critical value times a standard error, or as (estimate minus
null value) divided by a standard error. Second, check the degrees of freedom before you look up a critical value.
Third, after any computation, sanity-check the sign and the size: a correlation outside [-1, 1], a variance below zero
or a p-value above 1 means an arithmetic slip, not a discovery.

Based on the NIST/SEMATECH e-Handbook of Statistical Methods and the original method papers listed under Sources;
formulas are standard results written in our own notation. The self-testing use of the sheet follows the GAISE
College Report (ASA 2016) recommendation to use assessments to improve and evaluate student learning.

## Notation

<!-- Guidance: Fix the notation once. If your course uses other symbols, add a column rather than changing the sheet. -->

| Symbol | Meaning | Symbol | Meaning |
|---|---|---|---|
| $n$ | sample size | $N$ | population size or total count |
| $\bar{x}$ | sample mean | $\mu$ | population mean |
| $s$ | sample standard deviation | $\sigma$ | population standard deviation |
| $\hat{p}$ | sample proportion | $p$ | population proportion |
| SE | standard error of an estimate | df | degrees of freedom |
| $\alpha$ | significance level (0.05 here) | $1-\beta$ | power |
| $z_{q}$ | standard normal quantile with area $q$ below | $t_{q,\,df}$ | t quantile with area $q$ below |
| $H_0$, $H_1$ | null and alternative hypotheses | $k$ | number of groups |
| $O$, $E$ | observed and expected counts | $r$ | Pearson correlation |
| $b_0$, $b_1$ | regression intercept and slope | $R^2$ | proportion of variance explained |

## 1. Descriptive statistics

<!-- Guidance: These are the building blocks of every later formula. Make sure you know which use n and which use n - 1. -->

The **mean** is the balance point of the data; the **median** is the middle value after sorting. The **variance** is
the average squared distance from the mean, using $n-1$ so that the sample variance is an unbiased estimate of the
population variance. The **standard deviation** is its square root and is in the units of the data.

$$
\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i \qquad
s^2 = \frac{1}{n-1}\sum_{i=1}^{n} (x_i-\bar{x})^2 \qquad
s = \sqrt{s^2}
$$

$$
z_i = \frac{x_i - \bar{x}}{s} \qquad \text{IQR} = Q_3 - Q_1 \qquad \text{outlier fences: } Q_1 - 1.5\,\text{IQR},\ Q_3 + 1.5\,\text{IQR}
$$

- **Use when:** mean and SD for roughly symmetric data; median and IQR for skewed data or data with outliers.
- **Common slip:** dividing by $n$ instead of $n-1$ for a sample SD; reporting the SD when the question asks for the
  standard error (SE is the SD of the *estimate*, not of the data).
- **Common slip:** quartiles differ by software. R `quantile()` defaults to type 7, which is also numpy's default
  `linear` method; textbook hand methods often give slightly different quartiles. State the method if it matters.

## 2. Probability and Bayes' theorem

<!-- Guidance: Draw a tree or a two-way table for every conditional probability question before you use a formula. -->

Probabilities of "or" events add (minus the overlap), probabilities of "and" events multiply (using the conditional
probability unless the events are independent). Conditional probability restricts attention to the cases where the
condition holds.

$$
P(A \cup B) = P(A) + P(B) - P(A \cap B) \qquad P(A \cap B) = P(A)\,P(B \mid A)
$$

$$
P(A \mid B) = \frac{P(A \cap B)}{P(B)} \qquad \text{independence: } P(A \cap B) = P(A)\,P(B)
$$

**Bayes' theorem** turns a probability of the evidence given a hypothesis into a probability of the hypothesis given
the evidence:

$$
P(H \mid E) = \frac{P(E \mid H)\,P(H)}{P(E \mid H)\,P(H) + P(E \mid \neg H)\,P(\neg H)}
$$

- **Use when:** screening tests, diagnostic questions, "given that" wording, updating a belief with new evidence.
- **Common slip:** confusing $P(E \mid H)$ with $P(H \mid E)$ (the prosecutor's fallacy). A test that is 95% sensitive
  does not mean a positive result is 95% likely to be a true case: that depends on the base rate.
- **Common slip:** treating mutually exclusive events as independent. If $A$ and $B$ cannot both happen and both have
  positive probability, they are strongly dependent.

Counting: $n! $ orderings of $n$ items; $\binom{n}{k} = \dfrac{n!}{k!\,(n-k)!}$ ways to choose $k$ of $n$ when order
does not matter.

## 3. Distributions

<!-- Guidance: Know mean and variance of each, and one situation where it arises. The full catalogue lives in academic/stats-distributions-sheet. -->

The **binomial** counts successes in $n$ independent trials with the same success probability $p$. The **Poisson**
counts events in a fixed interval when they occur independently at a constant rate $\lambda$. The **normal** is the
bell curve that sampling distributions of means approach.

$$
P(X=k) = \binom{n}{k} p^k (1-p)^{n-k}, \quad E(X)=np, \quad \operatorname{Var}(X)=np(1-p)
$$

$$
P(X=k) = \frac{e^{-\lambda}\lambda^k}{k!}, \quad E(X)=\operatorname{Var}(X)=\lambda
$$

$$
f(x) = \frac{1}{\sigma\sqrt{2\pi}}\exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right), \quad Z = \frac{X-\mu}{\sigma} \sim N(0,1)
$$

- **Use when:** binomial for a fixed number of yes/no trials; Poisson for counts per time or space unit (loans per
  hour at Harbour City Library (fictional)); normal for continuous measurements and for large-sample statistics.
- **Common slip:** using the binomial when trials are not independent or $p$ changes; using the Poisson when the
  variance is much larger than the mean (overdispersion, see academic/stats-count-regression).
- **Rules of thumb:** 68%, 95% and 99.7% of a normal distribution lie within 1, 2 and 3 SDs of the mean. The exact
  two-sided 95% critical value is $z_{0.975} = 1.960$.

## 4. Sampling distributions and standard errors

<!-- Guidance: This is the most important page of the sheet. Every interval and test below reuses one of these SEs. -->

A statistic computed from a random sample varies from sample to sample. Its standard deviation across repeated
samples is the **standard error**. By the central limit theorem, the sampling distribution of a mean is close to
normal for moderate $n$ even when the data are not, unless they are very skewed or have extreme outliers.

| Estimate | Standard error | Notes |
|---|---|---|
| Mean $\bar{x}$ | $s/\sqrt{n}$ | uses sample SD $s$ |
| Proportion $\hat{p}$ | $\sqrt{\hat{p}(1-\hat{p})/n}$ | use $p_0$ in place of $\hat{p}$ for a test |
| Difference of means (Welch) | $\sqrt{s_1^2/n_1 + s_2^2/n_2}$ | default for two independent groups |
| Difference of means (pooled) | $s_p\sqrt{1/n_1 + 1/n_2}$ | assumes equal variances |
| Mean of paired differences | $s_d/\sqrt{n}$ | $n$ = number of pairs |
| Difference of proportions (CI) | $\sqrt{\hat{p}_1(1-\hat{p}_1)/n_1 + \hat{p}_2(1-\hat{p}_2)/n_2}$ | unpooled |
| Regression slope $b_1$ | $s_e/\sqrt{S_{xx}}$ | $s_e$ = residual SE |

$$
s_p = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}}
$$

- **Use when:** any time you build a CI or a test statistic.
- **Common slip:** the SE shrinks with $\sqrt{n}$, not with $n$: four times the sample size halves the SE.
- **Common slip:** treating paired data as two independent groups throws away the pairing and usually inflates the SE.

## 5. Confidence intervals

<!-- Guidance: All of these are estimate plus or minus critical value times SE, except the Wilson interval for a proportion (recommended for small n) and the Fisher z interval for r, which are not symmetric around the estimate. See academic/stats-confidence-intervals for meaning and misconceptions. -->

A 95% confidence interval comes from a procedure that captures the true parameter in 95% of repeated samples. It
gives the range of parameter values that are compatible with the data at that level.

$$
\bar{x} \pm t_{0.975,\,n-1}\,\frac{s}{\sqrt{n}} \qquad (\bar{x}_1-\bar{x}_2) \pm t_{0.975,\,\nu}\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}
$$

$$
\text{Wald: } \hat{p} \pm z_{0.975}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \qquad
\text{Wilson: } \frac{\hat{p} + \frac{z^2}{2n} \pm z\sqrt{\frac{\hat{p}(1-\hat{p})}{n} + \frac{z^2}{4n^2}}}{1+\frac{z^2}{n}}
$$

$$
\text{Correlation (Fisher } z\text{): } \tanh\!\left(\operatorname{artanh}(r) \pm \frac{z_{0.975}}{\sqrt{n-3}}\right)
$$

- **Use when:** always report an interval with an estimate; a test alone hides the size and precision.
- **Common slip:** "there is a 95% probability that $\mu$ is in this interval" (for a frequentist CI the parameter is
  fixed; the 95% describes the procedure). A Bayesian credible interval does carry that meaning.
- **Common slip:** using $z$ instead of $t$ with small samples; the Wald interval for proportions near 0 or 1 or small
  $n$ (use Wilson).

## 6. Hypothesis tests

<!-- Guidance: Every test statistic has the same shape: (estimate - null value) / SE. Learn that shape, then the SE for each case. Check the method choice with academic/stats-test-selector. -->

A test asks how surprising the observed statistic would be if the null hypothesis were true. The p-value is the
probability, computed under $H_0$, of a statistic at least as extreme as the one observed.

**One-sample z and t:**

$$
z = \frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}} \qquad t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}},\quad df = n-1
$$

**Two independent groups: Welch (default) and pooled:**

$$
t_W = \frac{\bar{x}_1-\bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}} \qquad
\nu = \frac{\left(s_1^2/n_1 + s_2^2/n_2\right)^2}{\dfrac{(s_1^2/n_1)^2}{n_1-1} + \dfrac{(s_2^2/n_2)^2}{n_2-1}}
$$

$$
t_{\text{pooled}} = \frac{\bar{x}_1-\bar{x}_2}{s_p\sqrt{1/n_1+1/n_2}},\quad df = n_1+n_2-2
$$

**Paired:** compute differences $d_i$ first, then a one-sample t on them.

$$
t = \frac{\bar{d}}{s_d/\sqrt{n}},\quad df = n-1
$$

**Proportions:**

$$
z = \frac{\hat{p}-p_0}{\sqrt{p_0(1-p_0)/n}} \qquad
z = \frac{\hat{p}_1-\hat{p}_2}{\sqrt{\bar{p}(1-\bar{p})\left(\frac{1}{n_1}+\frac{1}{n_2}\right)}},\quad \bar{p} = \frac{x_1+x_2}{n_1+n_2}
$$

**Chi-square (goodness of fit and independence):**

$$
\chi^2 = \sum \frac{(O-E)^2}{E} \qquad E_{ij} = \frac{(\text{row}_i \text{ total})(\text{column}_j \text{ total})}{N},\quad df = (r-1)(c-1)
$$

**F for two variances:** $F = s_1^2/s_2^2$ with $df = (n_1-1,\ n_2-1)$.

- **Use when:** t for means with unknown $\sigma$ (nearly always); z for proportions with large counts; chi-square for
  counts in categories; F for comparing variances or in ANOVA and regression.
- **Common slip:** R `t.test()` defaults to Welch, while `scipy.stats.ttest_ind()` defaults to pooled
  (`equal_var=True`). Set `equal_var=False` in Python to match R and this sheet.
- **Common slip:** chi-square on percentages instead of counts; expected counts below 5 in many cells (use Fisher's
  exact test); R `chisq.test()` applies the Yates continuity correction to 2 x 2 tables by default, scipy's
  `chi2_contingency()` does too, so both differ from the hand formula unless you set `correct = FALSE` / `correction=False`.
- **Common slip:** the F test for variances is very sensitive to non-normality; prefer Levene or Brown-Forsythe tests
  to check equal variances, or just use Welch.

## 7. ANOVA table

<!-- Guidance: Fill the table from left to right: SS, df, MS = SS/df, F = MS between / MS within. See academic/stats-one-way-anova. -->

One-way ANOVA splits the total variation into variation between group means and variation within groups. If the
group means are equal, both mean squares estimate the same error variance and their ratio is near 1.

$$
SS_B = \sum_{j=1}^{k} n_j(\bar{x}_j-\bar{x})^2 \qquad SS_W = \sum_{j=1}^{k}\sum_{i=1}^{n_j}(x_{ij}-\bar{x}_j)^2 \qquad SS_T = SS_B + SS_W
$$

| Source | SS | df | MS | F |
|---|---|---|---|---|
| Between groups | $SS_B$ | $k-1$ | $MS_B = SS_B/(k-1)$ | $MS_B/MS_W$ |
| Within groups (error) | $SS_W$ | $N-k$ | $MS_W = SS_W/(N-k)$ | |
| Total | $SS_T$ | $N-1$ | | |

$$
\eta^2 = \frac{SS_B}{SS_T} \qquad \omega^2 = \frac{SS_B - (k-1)MS_W}{SS_T + MS_W}
$$

- **Use when:** three or more independent group means; follow with Tukey HSD (equal variances) or Games-Howell.
- **Common slip:** running all pairwise t-tests instead of ANOVA plus a controlled post hoc procedure (inflates the
  family-wise Type I error); forgetting that a significant F says "at least one mean differs", not which.

## 8. Correlation and regression

<!-- Guidance: Compute S_xx, S_yy and S_xy first; every formula below is a ratio of these. See academic/stats-correlation and academic/stats-linear-regression. -->

Correlation measures the strength of a straight-line association on a scale from -1 to 1. Simple linear regression
fits the line that minimises the sum of squared vertical distances (residuals).

$$
S_{xx} = \sum (x_i-\bar{x})^2 \quad S_{yy} = \sum (y_i-\bar{y})^2 \quad S_{xy} = \sum (x_i-\bar{x})(y_i-\bar{y})
$$

$$
r = \frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}} \qquad b_1 = \frac{S_{xy}}{S_{xx}} = r\,\frac{s_y}{s_x} \qquad b_0 = \bar{y} - b_1\bar{x}
$$

$$
s_e = \sqrt{\frac{SSE}{n-2}} \qquad SE(b_1) = \frac{s_e}{\sqrt{S_{xx}}} \qquad t = \frac{b_1}{SE(b_1)},\ df=n-2 \qquad R^2 = 1-\frac{SSE}{S_{yy}}
$$

Test for a correlation: $t = r\sqrt{(n-2)/(1-r^2)}$ with $df = n-2$ (identical to the slope t-test in simple
regression). Adjusted $R^2 = 1 - (1-R^2)\dfrac{n-1}{n-p-1}$ with $p$ predictors.

- **Use when:** $r$ for describing a linear association; regression for predicting $y$ from $x$ and estimating the
  change in $y$ per unit of $x$.
- **Common slip:** in simple regression $R^2 = r^2$, but this does not hold for multiple regression with one
  predictor's $r$. Correlation is not causation, and a correlation near 0 does not rule out a curved relation.

## 9. Logistic and Poisson regression links

<!-- Guidance: In a generalised linear model the coefficients live on the link scale. Always exponentiate before you interpret. See academic/stats-logistic-regression and academic/stats-count-regression. -->

Generalised linear models (Nelder and Wedderburn 1972) connect a linear predictor $\eta = b_0 + b_1x$ to the mean of
the outcome through a link function.

$$
\text{Logistic: } \operatorname{logit}(p) = \ln\frac{p}{1-p} = b_0 + b_1x \qquad p = \frac{1}{1+e^{-(b_0+b_1x)}} \qquad \text{OR} = e^{b_1}
$$

$$
\text{Poisson: } \ln(\mu) = b_0 + b_1x \qquad \mu = e^{b_0+b_1x} \qquad \text{rate ratio} = e^{b_1}, \quad \text{offset: } \ln(\mu) = \ln(t) + b_0 + b_1x
$$

- **Use when:** logistic for a binary outcome (passed or failed); Poisson for counts (loans per day).
- **Common slip:** reading $b_1$ from logistic regression as a change in probability. It is a change in log odds;
  $e^{b_1}$ is an odds ratio, and the change in probability depends on where you start.

## 10. Effect sizes

<!-- Guidance: Report an effect size with every test. Conventions such as d = 0.2/0.5/0.8 (Cohen 1988) are rough guides only. See academic/stats-effect-sizes. -->

An effect size says how big a difference or association is, in units that do not depend on the sample size.

$$
d = \frac{\bar{x}_1-\bar{x}_2}{s_p} \qquad g = d\left(1-\frac{3}{4(n_1+n_2)-9}\right) \qquad d_z = \frac{\bar{d}}{s_d}
$$

$$
\text{Cramér's } V = \sqrt{\frac{\chi^2}{N(\min(r,c)-1)}} \qquad \phi = \sqrt{\chi^2/N}\ (2\times 2) \qquad \text{OR} = \frac{ad}{bc}
$$

$$
r \text{ from } t: \ r = \sqrt{\frac{t^2}{t^2+df}} \qquad \text{partial } \eta^2 = \frac{SS_{\text{effect}}}{SS_{\text{effect}}+SS_{\text{error}}}
$$

- **Use when:** $d$ or $g$ for two means (prefer $g$ for small samples); $d_z$ for paired designs; $V$ or $\phi$ for
  contingency tables; $\eta^2$ or $\omega^2$ for ANOVA ($\omega^2$ is less biased); OR for 2 x 2 tables and logistic.
- **Common slip:** comparing $d_z$ (paired) with $d$ (independent) as if they were on the same scale; calling an
  effect "small" only because of Cohen's labels without considering the context.

## 11. Power and sample size approximations

<!-- Guidance: Use these for a quick estimate, then confirm with software. The full worksheet is academic/stats-power-sample-size. -->

Power is the probability of rejecting $H_0$ when a specified effect is real. It rises with the effect size, the sample
size and $\alpha$, and falls with the variability.

$$
n_{\text{per group}} \approx \frac{2\,(z_{1-\alpha/2} + z_{1-\beta})^2}{d^2} \qquad
n \approx \frac{z_{1-\alpha/2}^2\,p(1-p)}{E^2}\ \text{(proportion with margin } E\text{)}
$$

- **Use when:** planning a study, checking whether a thesis sample is large enough for the smallest effect you care
  about.
- **Common slip:** the normal approximation slightly underestimates $n$ for t-tests (it gives 62.8 per group for
  $d = 0.5$, power 0.80; the exact t-based answer is 63.8, so 64 per group). Always round up. "Observed power" computed
  after the study from the observed effect adds nothing to the p-value.

## Choosing a formula

<!-- Guidance: Use this flow as a retrieval cue: before computing, say which branch you are on and why. The full decision tree is academic/stats-test-selector. -->

The diagram below is a short version of the decision you make before reaching for any formula on this sheet: what
type is the outcome, how many groups, and are the observations paired?

```mermaid
flowchart TD
  A["What is the outcome?"] --> B["Numeric (mean)"]
  A --> C["Categorical (count or proportion)"]
  A --> D["Relationship between two numeric variables"]
  B --> E["One group vs a value"] --> E1["One-sample t"]
  B --> F["Two groups"]
  F --> F1["Independent: Welch t"]
  F --> F2["Paired: paired t on differences"]
  B --> G["Three or more groups"] --> G1["One-way ANOVA F"]
  C --> H["One proportion"] --> H1["z test or exact binomial, Wilson CI"]
  C --> I["Two proportions"] --> I1["Two-proportion z"]
  C --> J["Table of counts"] --> J1["Chi-square, Cramer's V"]
  D --> K["Strength"] --> K1["Pearson r"]
  D --> L["Prediction"] --> L1["Regression slope and R-squared"]
```

Why t and not z for small samples: the t critical value is wider when df is small and approaches 1.960 as df grows.

```vega-lite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Two-sided 95% critical values of t by degrees of freedom, with the z value 1.960 as a reference line.",
  "width": 380,
  "height": 220,
  "data": {"values": [
    {"df": 2, "crit": 4.303}, {"df": 5, "crit": 2.571}, {"df": 10, "crit": 2.228},
    {"df": 20, "crit": 2.086}, {"df": 30, "crit": 2.042}, {"df": 60, "crit": 2.000},
    {"df": 120, "crit": 1.980}
  ]},
  "layer": [
    {"mark": {"type": "line", "point": true},
     "encoding": {
       "x": {"field": "df", "type": "quantitative", "scale": {"type": "log"}, "title": "Degrees of freedom (log scale)"},
       "y": {"field": "crit", "type": "quantitative", "scale": {"domain": [1.8, 4.5]}, "title": "t critical value (0.975)"}}},
    {"mark": {"type": "rule", "strokeDash": [4, 4]}, "encoding": {"y": {"datum": 1.96}}}
  ]
}
```

## Worked numeric check

<!-- Guidance: Recompute each row by hand or with a calculator, then run the code to confirm. If your answer differs, find which input (n vs n - 1, Welch vs pooled, Yates correction) caused it. -->

The numbers below come from four small fictional data sets typed into the code. Every value in the table was produced
by both R 4.5.1 and Python 3.14 and the two agree to the shown precision (where the defaults differ, the table says
which option was used).

- **Exam scores** at Lakemoor University (fictional), quiz section $a$ = 72, 85, 78, 90, 66, 81, 88, 75, 83, 79 and
  no-quiz section $b$ = 70, 68, 75, 80, 62, 73, 77, 65, 71, 69.
- **Workshop** scores for 8 students, before = 61, 70, 55, 68, 74, 59, 66, 72 and after = 66, 74, 58, 70, 80, 63, 65, 77.
- **Study hours** $x$ = 2, 4, 5, 3, 6, 8, 7, 9, 5, 10 and exam score $y$ = 60, 68, 64, 66, 74, 76, 82, 80, 70, 86.
- **Library format by age** at Harbour City Library (fictional): under 30, 18 print and 22 e-book; 30 and over, 30
  print and 10 e-book. Three tutorial sections for ANOVA: 70, 74, 68, 72, 76 / 78, 82, 80, 76, 84 / 71, 69, 75, 73, 72.

| Quantity | Formula used | Inputs | Result |
|---|---|---|---|
| Mean, SD of $a$ | Section 1 | $n=10$ | $\bar{x}=79.7$, $s=7.364$ |
| Median, IQR of $a$ | type 7 quartiles | | 80.0, 8.75 |
| 95% CI for mean of $a$ | $\bar{x} \pm t\,s/\sqrt{n}$ | SE = 2.329, $t_{0.975,9}$ = 2.262 | [74.43, 84.97] |
| One-sample t vs 75 | Section 6 | | $t(9)=2.018$, $p=.074$ |
| Welch t, $a$ vs $b$ | Section 6 | SE = 2.898, $\nu$ = 16.59 | $t(16.59)=3.002$, $p=.008$, 95% CI [2.57, 14.83] |
| Pooled t, $a$ vs $b$ | Section 6 | $s_p=6.481$ | $t(18)=3.002$, $p=.008$ (.0077) |
| Cohen's d, Hedges' g | Section 10 | | $d=1.342$, $g=1.286$ |
| F for variances | $s_a^2/s_b^2$ | 54.23 / 29.78 | $F(9,9)=1.82$, $p=.385$ |
| Paired t (after minus before) | Section 6 | $\bar{d}=3.5$, $s_d=2.204$ | $t(7)=4.492$, $p=.003$, 95% CI [1.66, 5.34], $d_z=1.588$ |
| One-proportion z, 32 of 40 vs 0.90 | Section 6 | SE = 0.0474 | $z=-2.108$, $p=.035$; exact binomial $p=.057$ |
| Two-proportion z, 45/60 vs 36/60 | Section 6 | $\bar{p}=0.675$ | $z=1.754$, $p=.079$ |
| Chi-square 2 x 2, no correction | Section 6 | E = 24, 16, 24, 16 | $\chi^2(1)=7.50$, $p=.006$; with Yates 6.30, $p=.012$ |
| Cramér's V (here $\phi$), OR | Section 10 | | $V=0.306$, OR = 0.273 |
| One-way ANOVA | Section 7 | $SS_B=213.3$, $SS_W=100.0$ | $F(2,12)=12.80$, $p=.001$, $\eta^2=0.681$, $\omega^2=0.611$ |
| Correlation | Section 8 | $S_{xx}=60.9$, $S_{xy}=182.6$, $S_{yy}=640.4$ | $r=0.925$, $t(8)=6.866$, $p<.001$, 95% CI [0.71, 0.98] |
| Regression | Section 8 | | $b_1=2.998$, $b_0=54.91$, $SE(b_1)=0.437$, $s_e=3.408$, $R^2=0.855$ |
| Logistic, $b_0=-2$, $b_1=0.5$ | Section 9 | $x=4$, $x=6$ | $p=0.500$, $p=0.731$, OR = 1.649 |
| Poisson, $b_0=1.2$, $b_1=0.3$ | Section 9 | $x=2$ | $\mu=6.05$, rate ratio 1.350 |
| Power, $d=0.5$, power 0.80 | Section 11 | | approx. 62.8, exact 63.8, so 64 per group |
| Proportion, margin 0.05 | Section 11 | $p=0.5$ | 384.1, so 385 |
| Bayes, prevalence 2%, sensitivity 95%, specificity 90% | Section 2 | | $P(\text{case} \mid +) = 0.162$ |

```r
a <- c(72, 85, 78, 90, 66, 81, 88, 75, 83, 79)
b <- c(70, 68, 75, 80, 62, 73, 77, 65, 71, 69)
o1 <- t.test(a, mu = 75); c(o1$statistic, o1$p.value); o1$conf.int   # one-sample t and 95% CI for the mean of a
tt <- t.test(a, b); c(tt$statistic, tt$parameter, tt$p.value)            # Welch (R default)
tp <- t.test(a, b, var.equal = TRUE); c(tp$statistic, tp$parameter, tp$p.value)
pre <- c(61, 70, 55, 68, 74, 59, 66, 72); post <- c(66, 74, 58, 70, 80, 63, 65, 77)
tr <- t.test(post, pre, paired = TRUE); c(tr$statistic, tr$p.value); tr$conf.int
tab <- matrix(c(18, 30, 22, 10), 2)
chisq.test(tab, correct = FALSE)                # hand formula, no Yates correction
g <- factor(rep(1:3, each = 5)); v <- c(70,74,68,72,76, 78,82,80,76,84, 71,69,75,73,72)
summary(aov(v ~ g))
x <- c(2, 4, 5, 3, 6, 8, 7, 9, 5, 10); y <- c(60, 68, 64, 66, 74, 76, 82, 80, 70, 86)
cor.test(x, y); summary(lm(y ~ x))
power.t.test(delta = 0.5, sd = 1, power = 0.8)
```

```text
         t            
2.01820236 0.07433743
[1] 74.43188 84.96812
           t           df
 3.001586672 16.593858603  0.008192356
           t           df
 3.001586672 18.000000000  0.007658939
          t
4.491822635 0.002825896
[1] 1.6575 5.3425
X-squared = 7.5, df = 1, p-value = 0.00617
            Df Sum Sq Mean Sq F value  Pr(>F)
g            2  213.3  106.67    12.8 0.00106 **
Residuals   12  100.0    8.33
t = 6.8664, df = 8, p-value = 0.0001288
95 percent confidence interval:
 0.7060288 0.9823557
      cor
0.9246268
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  54.9097     2.7926  19.662 4.66e-08 ***
x             2.9984     0.4367   6.866 0.000129 ***
Residual standard error: 3.408 on 8 degrees of freedom
Multiple R-squared:  0.8549,	Adjusted R-squared:  0.8368
              n = 63.76576
```

```python
import numpy as np
from scipy import stats
import statsmodels.api as sm
from statsmodels.stats.power import TTestIndPower

a = np.array([72, 85, 78, 90, 66, 81, 88, 75, 83, 79])
b = np.array([70, 68, 75, 80, 62, 73, 77, 65, 71, 69])
w = stats.ttest_ind(a, b, equal_var=False)       # Welch: set equal_var=False to match R
print(w.statistic, w.df, w.pvalue, w.confidence_interval())
sp = np.sqrt((9 * a.var(ddof=1) + 9 * b.var(ddof=1)) / 18)
d = (a.mean() - b.mean()) / sp
print("d", d, "g", d * (1 - 3 / (4 * 20 - 9)))
z = (32 / 40 - 0.9) / np.sqrt(0.9 * 0.1 / 40)
print("z", z, "p", 2 * stats.norm.sf(abs(z)), "exact", stats.binomtest(32, 40, 0.9).pvalue)
tab = np.array([[18, 22], [30, 10]])
c = stats.chi2_contingency(tab, correction=False)
print("chi2", c.statistic, c.pvalue, "V", np.sqrt(c.statistic / 80))
x = np.array([2, 4, 5, 3, 6, 8, 7, 9, 5, 10]); y = np.array([60, 68, 64, 66, 74, 76, 82, 80, 70, 86])
m = sm.OLS(y, sm.add_constant(x)).fit()
print(m.params, m.bse, m.rsquared)
print("n exact", TTestIndPower().solve_power(effect_size=0.5, alpha=0.05, power=0.8))
print("PPV", 0.02 * 0.95 / (0.02 * 0.95 + 0.98 * 0.10))
```

```text
3.001586672066503 16.59385860302276 0.008192356439165922 ConfidenceInterval(low=np.float64(2.5733477091487904), high=np.float64(14.826652290851214))
d 1.3423503678196138 g 1.285631338193433
z -2.108185106778919 p 0.035014981019662564 exact 0.05668282561479828
chi2 7.5 0.006169899320544161 V 0.30618621784789724
[54.90968801  2.99835796] [2.79264343 0.43667048] 0.8549346723978959
n exact 63.765610588911635
PPV 0.16239316239316237
```

Note on Hedges' g: the correction factor $1 - 3/(4(n_1+n_2)-9)$ equals $1 - 3/(4\,df - 1)$ with $df = n_1+n_2-2$, so
both forms give $g = 1.286$ here.

## Worked examples with fading

<!-- Guidance: Study Example A step by step, complete the [ ] gaps in Example B without looking at A, then solve Exercise C from scratch and check the Answer key. -->

**Example A (fully worked): Welch t by hand.** Quiz section $a$: $\bar{x}_1 = 79.7$, $s_1^2 = 54.23$, $n_1 = 10$.
No-quiz section $b$: $\bar{x}_2 = 71.0$, $s_2^2 = 29.78$, $n_2 = 10$.

1. Variance of each mean: $54.23/10 = 5.423$ and $29.78/10 = 2.978$.
2. SE of the difference: $\sqrt{5.423 + 2.978} = \sqrt{8.401} = 2.898$.
3. Statistic: $t = (79.7 - 71.0)/2.898 = 3.002$.
4. Welch df: $\nu = 8.401^2 / (5.423^2/9 + 2.978^2/9) = 70.58/4.253 = 16.59$.
5. Critical value $t_{0.975,\,16.59} = 2.114$, so the 95% CI is $8.7 \pm 2.114 \times 2.898 = [2.57, 14.83]$.
6. Report: the quiz section scored higher, *t*(16.59) = 3.00, *p* = .008, mean difference 8.7 points, 95% CI
   [2.57, 14.83], *g* = 1.29.

**Example B (half solved): slope and R² by hand.** Study hours and exam score: $S_{xx} = 60.9$, $S_{xy} = 182.6$,
$S_{yy} = 640.4$, $\bar{x} = 5.9$, $\bar{y} = 72.6$, $n = 10$, $SSE = 92.90$.

1. Slope $b_1 = S_{xy}/S_{xx} = 182.6/60.9 =$ [ ].
2. Intercept $b_0 = \bar{y} - b_1\bar{x} = 72.6 - $ [ ] $\times 5.9 =$ [ ].
3. $R^2 = 1 - SSE/S_{yy} = 1 - 92.90/640.4 =$ [ ].
4. $s_e = \sqrt{SSE/(n-2)} = \sqrt{92.90/8} = 3.408$, so $SE(b_1) = 3.408/\sqrt{60.9} =$ [ ].
5. Interpretation: each additional study hour is associated with about [ ] more exam points.

**Exercise C (unsolved).** At Brightwell Bakery (fictional), 40 loaves were weighed and 32 passed the weight check.
The bakery claims a 90% pass rate. Compute $\hat{p}$, the SE under $H_0$, the z statistic and the two-sided p-value,
and say why the exact binomial p-value differs.

## Common slips and misconceptions

<!-- Guidance: Read this list before an exam. Each slip below appears in the error log taxonomy of academic/stats-error-log. -->

The slips in the sections above cluster into a few patterns that are worth naming, because naming a pattern helps you
spot it in a new problem:

| Wrong move | Correct move |
|---|---|
| Using the SD where the SE is needed | SE = SD of the estimate, for a mean $s/\sqrt{n}$ |
| Dividing by $n$ for a sample variance | divide by $n-1$ |
| Using $z$ with $n = 8$ and unknown $\sigma$ | use $t$ with $df = n-1$ |
| Treating paired data as independent | compute differences, then a one-sample t |
| Assuming R and Python give the same default | Welch in R, pooled in scipy; Yates correction on 2 x 2 tables in both |
| Reading a logistic $b_1$ as a probability change | exponentiate for an odds ratio |
| $p = .03$ means a 3% chance that $H_0$ is true | it is the probability of data this extreme if $H_0$ were true |
| A 95% CI contains 95% of the data | it is about the parameter, not individual values |
| Non-significant means "no effect" | look at the CI: it may include large effects |
| Squaring the multiple-regression $r$ of one predictor to get $R^2$ | $R^2 = r^2$ only in simple regression |

## Self-test questions

<!-- Guidance: Answer on paper with the sheet covered, then check the Answer key. Re-test missed items after 1, 3 and 7 days. -->

1. Write the standard error of a difference between two independent means without assuming equal variances.
2. A sample of $n = 25$ has $s = 10$. What is the SE of the mean, and how big must $n$ be to halve it?
3. Write Bayes' theorem for $P(H \mid E)$ and explain in one sentence why the base rate matters.
4. In a 3 x 4 contingency table, what are the degrees of freedom for the chi-square test of independence?
5. A logistic regression gives $b_1 = 0.5$. What is the odds ratio for a one-unit increase in $x$?
6. Why does `scipy.stats.ttest_ind(a, b)` give a different p-value from R's `t.test(a, b)` on the same data?

## My notes and next steps

<!-- Guidance: Keep a running list of the formulas you still miss. Move each one into your flashcards and error log. -->

| Formula I keep missing | Why I miss it | Card added (Y/N) | Re-test date |
|---|---|---|---|
| *Example:* Welch df | I forget to square the numerator | Y | YYYY-MM-DD |
| [Formula] | [Reason] | [ ] | YYYY-MM-DD |

Confidence with this sheet (1-5): [ ]. Open questions for the tutor: [Your questions]. Link your misses to
academic/stats-error-log.

## Sources and further reading

<!-- Guidance: Formulas are standard facts; the sources below are where to read the theory. -->

- NIST/SEMATECH e-Handbook of Statistical Methods, https://www.itl.nist.gov/div898/handbook/ (accessed 2026-10-25).
  Public domain.
- GAISE College Report ASA Revision Committee (2016). *Guidelines for Assessment and Instruction in Statistics
  Education (GAISE) College Report 2016*. American Statistical Association.
- Welch, B. L. (1947). The generalization of "Student's" problem when several different population variances are
  involved. *Biometrika*, 34(1–2), 28–35.
- Pearson, K. (1900). On the criterion that a given system of deviations from the probable in the case of a correlated
  system of variables is such that it can be reasonably supposed to have arisen from random sampling. *Philosophical
  Magazine*, Series 5, 50(302), 157–175.
- Fisher, R. A. (1925). *Statistical Methods for Research Workers*. Oliver and Boyd.
- Wilson, E. B. (1927). Probable inference, the law of succession, and statistical inference. *Journal of the American
  Statistical Association*, 22(158), 209–212.
- Nelder, J. A., and Wedderburn, R. W. M. (1972). Generalized linear models. *Journal of the Royal Statistical
  Society, Series A*, 135(3), 370–384.
- Cohen, J. (1988). *Statistical Power Analysis for the Behavioral Sciences* (2nd ed.). Lawrence Erlbaum Associates.
- Hedges, L. V. (1981). Distribution theory for Glass's estimator of effect size and related estimators. *Journal of
  Educational Statistics*, 6(2), 107–128.
- Further reading (by name only): de Smith, M. J. (2024). *Statistical Analysis Handbook*, 2024 edition. StatsRef,
  https://www.statsref.com/; Diez, Çetinkaya-Rundel and Barr, *OpenIntro Statistics*.

## Answer key

<!-- Guidance: Check your answers only after attempting them. A wrong answer is useful: log it with its error type. -->

**Example B:** $b_1 = 2.998$; $b_0 = 72.6 - 2.998 \times 5.9 = 54.91$; $R^2 = 0.855$; $SE(b_1) = 0.437$; about 3.0
points per hour; R `confint(lm(y ~ x))` gives a 95% CI for the slope of [1.99, 4.01].

**Exercise C:** $\hat{p} = 32/40 = 0.80$. SE under $H_0$: $\sqrt{0.9 \times 0.1/40} = 0.0474$. $z = (0.80-0.90)/0.0474
= -2.108$, two-sided $p = .035$. The exact binomial test gives $p = .057$ because it uses the discrete binomial
distribution directly; with only $n(1-p_0) = 4$ expected failures (well below the usual 10) the normal approximation is poor (R `prop.test(32, 40, p = 0.9)` warns
that the chi-squared approximation may be incorrect). Prefer the exact test or a Wilson interval here, and note that the two methods lead
to different decisions at $\alpha = 0.05$, a reason to report the estimate and interval rather than only "significant".

**Self-test:**

1. $SE = \sqrt{s_1^2/n_1 + s_2^2/n_2}$.
2. $SE = 10/\sqrt{25} = 2$. To halve it you need four times the sample size, $n = 100$.
3. $P(H \mid E) = P(E \mid H)P(H) / [P(E \mid H)P(H) + P(E \mid \neg H)P(\neg H)]$. When $H$ is rare, false positives
   from the large group of non-cases can outnumber true positives (PPV 0.162 in the check table).
4. $df = (3-1)(4-1) = 6$.
5. $\text{OR} = e^{0.5} = 1.649$: the odds are multiplied by about 1.65 per unit of $x$.
6. scipy's default is the pooled-variance t-test (`equal_var=True`); R's default is Welch. Use `equal_var=False`.

## Revision history

<!-- Guidance: Record each time you add formulas or change notation. -->

| Version | Date | Author | Change |
|---|---|---|---|
| 0.1 | YYYY-MM-DD | [Name] | First version from template |
| [0.2] | YYYY-MM-DD | [Name] | [Added formulas from week 8] |
