statistics
everything written here about getting the numbers right in code — online variance without storing samples, the collinearity trap that ate my coefficients, and the leakage guards that stop a backtest lying to you
i did a double degree in physics and chemistry before i wrote software for a living, which mostly means i know how easy it is to compute a number that is wrong in a way nothing warns you about.
what does this blog cover about statistics?
numerical correctness, and the specific ways it fails quietly.
welford’s algorithm, because the textbook variance formula — sum of squares
minus the square of the sum — loses catastrophic precision on large streams, and
because storing the samples to avoid that is not an option when the stream is
gigabytes of logs. ordinary least squares implemented by hand, and the
collinearity trap: a singular matrix that produced confident nonsense until a
guard turned it into an honest None.
and the discipline end: leakage guards for a research backtest — content-addressed model provenance, strict temporal splits, family-wise error control. the point of that post is that a backtest will happily p-hack itself into a beautiful result if you let it, and none of the failure modes announce themselves.
the common thread with the rest of this blog: these are all bugs that return a number instead of an error.
- don't let your backtest lie to you: leakage guards for a solo research codebase — content-addressed model provenance, strict temporal splits, and family-wise error control — the discipline that stops a research backtest from p-hacking itself
- hand-rolling ols regression in rust, and the collinearity trap that ate my coefficients — multiple linear regression from scratch — normal equations, cramer's rule, and the identifiability bug a singular-matrix guard turned into an honest None
- welford's algorithm and why i never store the samples — computing a rolling z-score over gigabytes of logs in constant memory — online variance, and three detectors combined by max
related
the implementations are all rust — rust — and the “test the things that fail invisibly” argument is under testing .