~/topics/statistics

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.

the implementations are all rust — rust — and the “test the things that fail invisibly” argument is under testing .