From 7af9ebe4801000a4cd2ab5ece2f61b82bace5244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Tue, 3 Nov 2026 23:30:21 +0100 Subject: [PATCH] =?UTF-8?q?docs(stats):=20say=20what=20the=20r=C2=B2=20cla?= =?UTF-8?q?mp=20does=20and=20does=20not=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/stats/linear-fit.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/stats/linear-fit.ts b/src/lib/stats/linear-fit.ts index 870d280c2..700ea3e82 100644 --- a/src/lib/stats/linear-fit.ts +++ b/src/lib/stats/linear-fit.ts @@ -60,7 +60,9 @@ export function fitFromSums(sums: FitSums): LinearFit | null { intercept: meanY - slope * meanX, // r² is at most 1 by Cauchy–Schwarz. With y far from zero and little // spread (two weighings of about 1000, a tenth apart) the centred sums - // lose their last digits and the ratio came out at 1.00000004. + // lose their last digits and the ratio came out at 1.00000004. The clamp + // keeps it in range; inside the range the same lost digits remain, which + // the points and the stored-sums paths share by design. r2: syy === 0 ? null : Math.min(1, (sxy * sxy) / (sxx * syy)), n, meanX,