← Statpro dev log

2026-10-05

The last-10 window lied in October

sportsdataproduct

Playoffs broke the math

October is when every recent-form number in StatPro changes meaning quietly. MLB and the NBA are into the postseason, so a hitter "last 10" now mixes regular-season and playoff games, and nothing on the chart told you which was which. You can see it now: each playoff game in an L5, L10, or L20 window carries its round (Wild Card, Division Series, and so on) right in the tooltip, while season rates and the context rail stay strictly regular-season.

The labels were the easy half. The hard half was a bug the labels exposed. To show "the rest of the season", the code subtracted the L20 window from the season total. Worked example: 40 hits in 80 games, minus an L20 of 12 in 20, gives 28 in 60. But this October the window was mixed, and inside it only 8 of those hits came on 15 regular-season decisions. The honest remainder is 32 in 65. Subtracting a mixed window from a regular-season total throws away real games on both sides of the fraction.

The fix subtracts the regular-season games inside the window for MLB and NBA, while NFL keeps the plain subtraction because its window is already all regular season:

const inWindow = last20.filter(g => g.seasonType === "regular");
// subtract matching subpopulations, never raw counts
const rest = {
  hits: season.hits - countHits(inWindow),
  games: season.games - inWindow.length,
};

What you can steal

When one number is derived by subtracting another number window, any change in what that window contains leaks into the derived number. Playoff season just makes it visible. The checklist we wrote down for ourselves: does this window mix season types, does the subtraction match subpopulations, and does the label admit the mixture?

this is the build log of statpro · statpro.io · all entries · essays