Skip to content

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

Description

@github-actions

🐹 Go Fan Report: gonum.org/v1/gonum

Module Overview

Gonum is the umbrella numerical-computing suite for Go (linear algebra, statistics, graph algorithms, optimization). gh-aw only depends on the stat/distuv subpackage β€” univariate probability distributions (PDFs/CDFs) used for statistical hypothesis testing.

Current Usage in gh-aw

  • Files: 1 (pkg/cli/experiments_grader_statistics.go)
  • Import Count: 1 (gonum.org/v1/gonum/stat/distuv)
  • Key APIs Used: distuv.StudentsT.CDF (Welch's t-test), distuv.UnitNormal.CDF (Mann-Whitney, two-proportion z-test), distuv.Beta.Prob/.CDF (Bayesian A/B numerical integration)

This file backs gh aw's grader-experiment statistics engine: comparing control vs. variant metric observations across four configurable analysis types (t_test, mann_whitney, proportion_test, bayesian_ab).

Research Findings

Version: gh-aw already pins v0.17.0, which is the latest release (published 2026-01-10) β€” no upgrade needed.

Recent Updates (v0.16.0 β†’ v0.17.0)

distuv.NoncentralT, Umeyama point-pattern alignment in spatial, optimize.MinimumStepSize, mathext.Li2/Hypergeo, Dinic max-flow + eccentricity/diameter in graph/network, Wasserstein distance in stat. None are a direct fit for gh-aw's current grader-statistics feature.

Best Practices

Gonum deliberately ships only distributions and descriptive statistics (stat.Mean, stat.Variance, stat.MeanVariance, stat.StdDev, stat.Covariance/Correlation) β€” it does not provide hypothesis-test helpers (no TTest, MannWhitneyUTest, or ProportionTest exist anywhere in the module, confirmed via repo code search). gh-aw's choice to implement Welch's t-test, Mann-Whitney U, and proportion tests itself β€” while consuming Gonum only for the distribution CDFs β€” is the expected and idiomatic way to use this library.

Full analysis detail

Quick win identified: experiments_grader_statistics.go hand-rolls meanValues() and sampleVariance() (two-pass sample mean/variance over []float64). Gonum's stat package already exports stat.Mean(x, weights) and stat.Variance(x, weights) with the same numerically-stable two-pass algorithm, well-tested in the upstream module already present in the dependency graph. Swapping these two helpers for the library calls removes ~15 lines of duplicated arithmetic with no behavior change (pass nil for unweighted).

Not a fit: the Bayesian A/B posterior comparison (betaBinomialProbability) numerically integrates variantPosterior.Prob(x) * controlPosterior.CDF(x) over 4096 fixed intervals. Gonum's distuv.Beta doesn't expose a closed-form "P(variant > control)" helper for two Beta posteriors, so this custom quadrature is the correct approach β€” no simpler Gonum API exists for it.

Full write-up saved to scratchpad/mods/gonum.md.

Improvement Opportunities

πŸƒ Quick Wins
  • Replace meanValues() / sampleVariance() in experiments_grader_statistics.go with stat.Mean(x, nil) / stat.Variance(x, nil) from gonum.org/v1/gonum/stat.
✨ Feature Opportunities
  • If confidence-interval reporting is added later, distuv's Quantile (inverse CDF) methods could report CIs alongside p-values without a new dependency.
πŸ“ Best Practice Alignment
  • Current usage already matches Gonum's intended design β€” no hypothesis-test logic is missing from the library; nothing to align further here.
πŸ”§ General Improvements
  • None beyond the quick win above β€” the module footprint in gh-aw is small (1 file) and already well-scoped to just the distribution math it's needed for.

Recommendations

  1. Replace the two hand-rolled mean/variance helpers with gonum.org/v1/gonum/stat.Mean/stat.Variance β€” small, low-risk cleanup.
  2. No version bump needed; v0.17.0 is current.
  3. No action needed on best-practice alignment or feature adoption at this time.

Next Steps

  • Optional follow-up PR: swap meanValues/sampleVariance for stat.Mean/stat.Variance in pkg/cli/experiments_grader_statistics.go.

Generated by Go Fan
Module summary saved to: scratchpad/mods/gonum.md

Generated by 🐹 Go Fan Β· claude Β· agent Β· 239.4 AIC Β· βŒ– 8.04 AIC Β· ⊞ 6.4K Β· β—·

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

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-07T08:08:45.260Z.

    Closed by Workflow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions