PuckQLAsk PuckQL

Methodology

The math inside chat answers

Methodology note ยท revised 4 December 2026

Abstract

When a question needs computation, the language model writes analysis code, and that code runs in an isolated sandbox over data fetched from the NHL's official sources at the time of the question. The model plans and explains; it never supplies a number from memory. To keep the arithmetic consistent across answers, the sandbox exposes a fixed library of statistical functions, which the analysis code uses instead of writing its own. This note documents each function exactly: what it computes, which variant of the method it implements, and where that variant is weak.

1How an answer is computed

An answer passes through three stages. The model first identifies the population and the measures a question needs: which players or teams, which seasons, which situations. Tools then load those records, from season totals to individual play-by-play events and shifts. Finally, model-written code runs over the loaded data in a QuickJS sandbox with no network access, a 20-second time limit and 96 MB of memory, and returns tables and figures, which the model then explains. Each step, query and source is available beneath the answer, so a reader can audit the path from question to number.

The choice of method in a given answer is the model's, guided by the question. What is fixed is the implementation. The rest of this note describes it.

2Descriptive statistics

  • Variance and standard deviation use the sample (๐‘›โˆ’1) denominator by default.
  • Percentiles interpolate linearly between order statistics: for sorted values ๐‘ฅ(0)โ‰คโ€ฆโ‰ค๐‘ฅ(๐‘›โˆ’1) and position โ„Ž=(๐‘/100)(๐‘›โˆ’1), the result is ๐‘ฅ(โŒŠโ„ŽโŒ‹)+(โ„Žโˆ’โŒŠโ„ŽโŒ‹)(๐‘ฅ(โŒˆโ„ŽโŒ‰)โˆ’๐‘ฅ(โŒŠโ„ŽโŒ‹)). This is type 7 in Hyndman and Fan's classification, the default in R and NumPy.
  • Percentile rank is the share of the population strictly below a value.
  • Weighted means skip missing values and non-positive weights, so ice-time-weighted averages are not distorted by players without data.

3Rates

Counting statistics are compared per 60 minutes of ice time:

rate60=๐‘›TOI (s)ร—3600(1)

Totals favour players who play more; rates compare like with like. Rates computed on small ice time are volatile, which is why sections 4 and 5 exist.

4Shrinkage toward a prior

For a proportion such as shooting percentage, with ๐‘  successes in ๐‘› trials, the library provides

shrink⁡(๐‘ ,๐‘›,๐œ‹,๐‘˜)=๐‘ +๐œ‹๐‘˜๐‘›+๐‘˜(2)

This is the posterior mean of a binomial proportion under a Beta⁡(๐œ‹๐‘˜,(1โˆ’๐œ‹)๐‘˜) prior: the prior acts like ๐‘˜ pseudo-trials at rate ฯ€. For rates per unit of exposure the same form is the posterior mean under a conjugate gamma prior, with ๐‘˜ measured in the exposure's units (minutes, games). As an illustration, a shooter with 6 goals on 30 shots, shrunk toward ฯ€ = 10% with ๐‘˜ = 100, has an estimate of (6 + 10)/130 โ‰ˆ 12.3%, not 20%.

The function does not choose ฯ€ or ๐‘˜. The analysis sets them, typically ฯ€ from the population being compared and ๐‘˜ from how quickly the statistic stabilises, and the answer reports both. A ๐‘˜ chosen carelessly can dominate the result, so this is the step of an answer most worth checking.

5Intervals and tests

Proportions: Wilson score interval

centre=๐‘ห†+๐‘ง2/2๐‘›1+๐‘ง2/๐‘›(3)half-width=๐‘ง๐‘ห†(1โˆ’๐‘ห†)/๐‘›+๐‘ง2/4๐‘›21+๐‘ง2/๐‘›

with ๐‘ง=1.96 by default. We use Wilson rather than the textbook Wald interval because Wald coverage collapses for small ๐‘› and for proportions near 0 or 1, which describes most hockey percentages over a few games.

Rates: Poisson interval

๐œ†ห†=๐‘›๐ธ,๐œ†ห†ยฑ๐‘งmax⁡(๐‘›,0.5)๐ธ(4)

for ๐‘› events over exposure ๐ธ, scaled to the reporting unit and truncated at zero. This is a normal approximation; the floor of 0.5 keeps the interval non-degenerate when no events occurred. For counts below about ten it is noticeably less accurate than an exact interval, and answers built on very small counts should be read with that in mind.

Comparing two rates

๐‘ง=๐‘Ÿ1โˆ’๐‘Ÿ2๐‘Ÿโ€•/๐ธ1+๐‘Ÿโ€•/๐ธ2,๐‘Ÿโ€•=๐‘›1+๐‘›2๐ธ1+๐ธ2(5)

a test of equal Poisson rates using the pooled rate under the null hypothesis.

Comparing two means: Welch's t-test

๐‘ก=๐‘ฅโ€•๐‘Žโˆ’๐‘ฅโ€•๐‘๐‘ฃ๐‘Ž+๐‘ฃ๐‘,๐‘ฃ=๐‘ 2/๐‘›(6)df=(๐‘ฃ๐‘Ž+๐‘ฃ๐‘)2๐‘ฃ๐‘Ž2/(๐‘›๐‘Žโˆ’1)+๐‘ฃ๐‘2/(๐‘›๐‘โˆ’1)

Welch's test does not assume equal variances, which is rarely a safe assumption for hockey groups of different sizes. The two-sided p-value comes from the t distribution's CDF, evaluated through the regularised incomplete beta function by continued fraction.

Bootstrap intervals

When no closed form fits, the library resamples the data with replacement 1,000 times, recomputes the statistic, and reports the 2.5th and 97.5th percentiles (the percentile bootstrap). The generator is seeded, so the same data always give the same interval. The percentile method can undercover for skewed statistics on small samples; 1,000 replicates are enough for a 95% interval but not for extreme tails.

6Relationships

Correlation is Pearson's ๐‘Ÿ; regression is ordinary least squares with one predictor, reporting slope, intercept, ๐‘Ÿ, ๐‘Ÿ2 and ๐‘›. Both refuse to run on fewer than three observations. Neither adjusts for confounding, and answers that report them say so when the question is causal.

7Composite rankings

Questions such as "who is the best defensive defenceman" require combining measures on different scales. The library's composite procedure is deliberately simple and deliberately transparent.

  1. For each component ๐‘, compute z-scores within the full population being ranked (all qualifying players, or all 32 teams), not within a pre-selected shortlist: ๐‘ง๐‘–๐‘=(๐‘ฅ๐‘–๐‘โˆ’๐‘ฅโ€•๐‘)/๐‘ ๐‘.
  2. Orient each so that higher is better, by negating components where lower is better.
  3. Score each row as the weighted mean of its oriented z-scores, ๐‘†๐‘–=โˆ‘๐‘๐‘ค๐‘๐‘ง๐‘–๐‘/โˆ‘๐‘๐‘ค๐‘, with weights stated in the answer.
  4. Treat a missing component as average (๐‘ง=0) and list it, rather than dropping the row.
  5. For a sensitivity check, recompute every rank with each component removed in turn, and report each row's range of ranks across those versions.

The fifth step is the one we would defend hardest. Any composite reflects choices of components and weights. Reporting how far a rank moves when one choice is undone tells the reader whether a first place is robust or rests on a single measure.

8Limitations

  • The method is chosen per question. The library guarantees that a Wilson interval is computed correctly, not that a Wilson interval was the right tool. The working shown with each answer is there so this can be checked.
  • No multiple-comparison control. An answer that scans many players for unusual values will find some by chance, and the library does not correct for this.
  • Normal approximations in equations (4) and (5) are weak for small counts.

References

  1. Wilson, E. B. (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association, 22(158), 209โ€“212.
  2. Welch, B. L. (1947). The generalization of "Student's" problem when several different population variances are involved. Biometrika, 34(1โ€“2), 28โ€“35.
  3. Satterthwaite, F. E. (1946). An approximate distribution of estimates of variance components. Biometrics Bulletin, 2(6), 110โ€“114.
  4. Efron, B. (1979). Bootstrap methods: another look at the jackknife. Annals of Statistics, 7(1), 1โ€“26.
  5. Hyndman, R. J., & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361โ€“365.
  6. Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press.
PuckQL Computed from official NHL data. PuckQL is not affiliated with the NHL.
Playoff oddsGamesAsk PuckQLMethodologyGlossaryTermsPrivacy