# Mathematics and statistics

## Writing mathematics

Markdown with LaTeX syntax, rendered with KaTeX. Anything KaTeX supports is allowed; avoid packages it does not (no `\usepackage`, no TikZ).

- Inline: `$\mathcal{L}(\theta)$`.
- Display: a blank line, `$$`, the equation, `$$`, a blank line.
- Number every displayed equation you refer to later using `\tag{1}`; refer to it as "Eq. (1)". Do not number equations you never cite.
- Punctuate equations as part of the sentence.
- Define every symbol at first use, in prose immediately before or after the equation. Keep a notation table in Methods if there are more than a dozen symbols.

Conventions:

| Object | Notation | LaTeX |
| --- | --- | --- |
| Scalar | italic | `$x$` |
| Vector | bold lowercase | `$\mathbf{x}$` |
| Matrix | bold uppercase | `$\mathbf{W}$` |
| Set | calligraphic or blackboard | `$\mathcal{D}$`, `$\mathbb{R}^d$` |
| Expectation, probability | blackboard | `$\mathbb{E}[\cdot]$`, `$\mathbb{P}(\cdot)$` |
| Estimate | hat | `$\hat{\theta}$` |
| Function names | upright | `$\mathrm{softmax}$`, `$\log$`, `$\exp$` |
| Units | upright, thin space | `$5\,\mathrm{ms}$`, `$3.2\,\mathrm{GB}$` |
| Transpose | `$\mathbf{W}^{\top}$` | |

Example:

```markdown
We minimise the regularised empirical risk

$$
\hat{\theta} = \arg\min_{\theta} \; \frac{1}{n}\sum_{i=1}^{n} \ell\big(f_\theta(x_i), y_i\big) + \lambda \lVert \theta \rVert_2^2, \tag{1}
$$

where $\ell$ is the cross-entropy loss, $n$ is the number of training examples, and $\lambda \ge 0$ controls the penalty.
```

## Numbers and units

- SI units with a thin space: `12.5 ms`, `8 GB`, `1.2 × 10⁶`. Use `%` without a space: `74.8%`.
- Three significant figures by default. Match the precision of the measurement; do not report `0.7481923`.
- Percentages: distinguish percentage points from relative change (`+3.6 points` versus `+5.1%`).
- Large numbers: `1.2 M parameters`, `4.1 B tokens`. Define M and B once.
- Always give `n` and what it counts (seeds, examples, subjects).

## Reporting statistics

Every comparison that supports a claim reports:

1. the **estimate** (mean, median, difference) with units;
2. its **uncertainty** and how it was computed (s.d., s.e.m., 95% CI via bootstrap with `B` resamples, credible interval);
3. **`n`** and what a unit is;
4. the **test** if one was used (name, one- or two-sided), the **statistic** with degrees of freedom, and the **exact p-value** (`p = 0.004`; use `p < 0.001` only below that);
5. an **effect size** where the field has a standard one (Cohen's d, odds ratio, relative improvement).

Example: "Sparse routing reduced latency from 41.2 ms to 20.7 ms per token (mean over n = 5 seeds; difference 20.5 ms, 95% CI 19.1 to 21.9; two-sided Welch's t-test, t(7.6) = 28.4, p < 0.001)."

Rules:

- Choose tests before looking at the results and say so in Methods. If exploratory, say so.
- Correct for multiple comparisons (Holm or Benjamini–Hochberg) and state the method.
- Report all seeds run, not the best. If runs were excluded, say which and why, in Provenance.
- Machine-learning results: report mean and s.d. (or 95% CI) over ≥ 3 seeds, on a held-out split that was touched once. State whether hyperparameters were tuned on validation data and how.
- Do not describe a result as significant without a test, and do not describe a non-significant difference as a trend.
- Bayesian analyses: report the prior, the posterior estimate with a credible interval, and the sampler diagnostics.

## Reproducible computation

- Fix and record seeds for every source of randomness (framework, data loader, CUDA where possible). State residual nondeterminism.
- Record library versions in a pinned environment file (`requirements.txt` with hashes, `environment.yml`, `uv.lock`, or a container digest).
- Write the checksum (sha256) of every dataset file and every output that a number in the paper depends on to `logs/checksums.txt`.
- The single run command in Code availability must regenerate every figure and table from raw data.
