Skip to content

[go-fan] Go Module Review: gonum.org/v1/gonumΒ #72043

Closed as not planned
Closed as not planned

Description

@github-actions

Go Fan Report: gonum.org/v1/gonum

Module: gonum.org/v1/gonum v0.17.0 (already latest release, published 2026-01-10)

Selected via round-robin plus recent-activity priority: the gonum repo was pushed most recently (2026-10-25) among all direct dependencies not reviewed in the last 7 days.

Current Usage in gh-aw

Only 1 file imports gonum, and only one subpackage: pkg/cli/experiments_grader_statistics.go imports gonum.org/v1/gonum/stat/distuv (nothing from stat, mat, optimize, etc.).

Key APIs used:

  • distuv.StudentsT{Mu,Sigma,Nu}.CDF(...) for Welch t-test p-value
  • distuv.UnitNormal.CDF(...) for Mann-Whitney U and two-proportion z-test p-values
  • distuv.Beta{Alpha,Beta}.Prob/.CDF(...) for Bayesian A/B posterior-superiority probability (numerically integrated over a fixed 4096-point grid)

Everything else in the file, including meanValues, sampleVariance, the Mann-Whitney ranking and tie-correction logic, and sumValues, is hand-rolled, not from gonum.

Research Findings

The gonum stat package (not currently imported here) provides Mean, Variance, and notably MeanVariance, which computes the unbiased (Bessel-corrected) sample mean and variance together in a single pass. That is the exact statistic the file hand-rolls today via meanValues plus sampleVariance, but with a redundant pass: welchTTest calls meanValues directly, and sampleVariance recomputes the mean again internally.

gonum does not ship a built-in Mann-Whitney or rank-sum test, so the hand-rolled implementation in this file is a reasonable, justified choice, not a gap.

Recent Updates (v0.16.0 to v0.17.0)
  • distuv: added a non-central t distribution
  • stat: added Wasserstein distance
  • stat/distuv: added a documentation example for computing a confidence interval, notable because MetricComparison in this repo currently reports only p-values and superiority probabilities, no intervals
Best Practices

Gonum documentation favors the single-pass MeanVariance over separate mean and variance calls, and recommends passing nil for unweighted inputs instead of building an all-ones weight slice.

Improvement Opportunities

Quick Wins
  • Replace meanValues(values) plus sampleVariance(values) in welchTTest (pkg/cli/experiments_grader_statistics.go) with a single stat.MeanVariance(values, nil) call per group. This removes a redundant mean computation per group and drops the need for the hand-rolled sampleVariance helper.
  • The meanValues helper used for the Delta field in computeGraderMetricComparisons could be replaced by stat.Mean(values, nil), removing another hand-rolled helper in favor of the already-vendored dependency.
Feature Opportunities
  • Add confidence intervals to MetricComparison, for example a DeltaCI [2]float64 field, using distuv.StudentsT.Quantile and distuv.UnitNormal.Quantile, mirroring the confidence-interval example gonum added to its docs in v0.17.0. This is standard practice for A/B reporting and is currently missing from the grader output.
  • betaBinomialProbability integrates over a fixed 4096-point grid to get a posterior-superiority probability; a credible interval for the same Bayesian path, derived from distuv.Beta quantile or CDF, could be reported alongside it for consistency with the frequentist paths above.
Best Practice Alignment
  • The file currently imports only stat/distuv and never stat, despite stat providing exactly the descriptive-statistics helpers (Mean, MeanVariance) this file reimplements by hand. Importing stat would better align with the intended split in gonum (stat for descriptive statistics, stat/distuv for distributions) and reduce custom code surface.
General Improvements
  • No version upgrade needed; go.mod already pins the latest gonum release (v0.17.0).
  • No other files in the repo import gonum, so there is no cross-file consistency work needed beyond this one file.

Recommendations

  1. Swap meanValues and sampleVariance for stat.MeanVariance in welchTTest (quick win, no behavior change, same unbiased-variance formula).
  2. Consider adding confidence intervals to MetricComparison using existing distuv quantile methods, since the module already imported for this purpose supports it directly.

Next Steps

  • If confidence intervals are added, update any downstream report rendering that consumes MetricComparison to display the new field.
  • Re-review after any change to AnalysisType handling, since that is the main place gonum APIs are invoked.

Generated by Go Fan
Module summary saved to: scratchpad/mods/gonum.md
Run: Β§40289806152

Generated by 🐹 Go Fan Β· claude Β· agent Β· ~97 AIC Β· βŒ– ~1 AIC Β· ⊞ 4.4K Β· β—·

  • expires on Oct 27, 2026, 12:14 AM UTC-08:00

Activity

  1. github-actions commented on Oct 27, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-27T08:14:43.201Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions