Skip to content

docs: fix example variables and intro domain in @stdlib/stats/base/dists/chisquare/{median,mean}#12301

Open
Planeshifter wants to merge 2 commits into
developfrom
philipp/drift-stats-base-dists-chisquare-2026-05-26
Open

docs: fix example variables and intro domain in @stdlib/stats/base/dists/chisquare/{median,mean}#12301
Planeshifter wants to merge 2 commits into
developfrom
philipp/drift-stats-base-dists-chisquare-2026-05-26

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

Description

This pull request corrects two documentation-consistency drift findings in @stdlib/stats/base/dists/chisquare — variable-name inconsistencies in median examples and a missing k >= 0 domain qualifier in the mean intro — bringing both packages into line with the established sibling-package conventions in the same namespace. No public behavior, function signatures, or test expectations change.

Namespace summary

  • Members analyzed: 14 non-autogenerated packages (cdf, ctor, entropy, kurtosis, logpdf, mean, median, mgf, mode, pdf, quantile, skewness, stdev, variance).
  • Features extracted: file tree, package.json shape and contents, manifest.json shape, README headings and prose, test/benchmark/example file naming, public signatures, validation prologues, error-construction style, JSDoc shape and @example variable conventions, TypeScript declaration shape, REPL-help shape, runtime dependencies.
  • Clean majority (≥75%): universal package.json metadata (versions, authors, license, engines, OS list, contributors, homepage); universal directory layout per package type; universal JSDoc presence (@param, @returns, @example); var v = <pkg>( ... ); convention across single-argument example blocks (7/8 single-arg siblings); where \k >= 0` is the degrees of freedomintro phrasing within theNonNegativeNumber`-domain group (3/4 packages).
  • Features excluded — no clear majority: native binding presence (binding.gyp, lib/native.js, src/, include/, manifest.json, test/test.native.js) splits 10/4 = 71%; factory-function presence (lib/factory.js, test/test.factory.js) splits along semantic lines (functions of an evaluation variable have a factory; pure summary statistics do not); validation predicates split along the genuine mathematical domain of each formula (NonNegativeNumber vs PositiveNumber); test-fixture language differs in stdev (Python) versus the rest (Julia) but fixing it would require regenerating fixtures.

Per outlier package

@stdlib/stats/base/dists/chisquare/median

Fixes variable-name drift in README.md (line 58) and docs/types/index.d.ts (examples 3–4), where the negative-input result was assigned to k instead of v. All seven single-argument sibling packages in this namespace (entropy, kurtosis, mean, mode, skewness, stdev, variance) use var v in the corresponding blocks, as does the package's own lib/main.js JSDoc. Brings conformance to 8/8.

@stdlib/stats/base/dists/chisquare/mean

Corrects the intro formula line from where \k` is the degrees of freedomtowhere `k >= 0` is the degrees of freedom, aligning with the three NonNegativeNumber-domain siblings (mode, stdev, variance) in this namespace and with the Notes block and lib/main.js validation (k < 0returnsNaN`) already present in the same package. The omission of the non-negativity constraint from the intro was an internal consistency drift with no behavioral impact.

Related Issues

None.

Questions

No.

Other

Validation

  • Structural feature extraction: filesystem walk over each package's file tree, package.json keys and contents, manifest.json keys, README heading sequences, and test/benchmark/example file naming.
  • Semantic feature extraction: one Sonnet agent per package read lib/main.js, lib/index.js, and lib/factory.js (where present) and returned a strict JSON bundle covering public signature, validation prologue, error-construction style, JSDoc shape, TypeScript declaration shape, REPL shape, and runtime dependencies.
  • Three-agent drift validation: an Opus semantic-review agent, an Opus cross-reference agent, and a Sonnet structural-review agent each independently inspected the proposed corrections; all three returned confirmed-drift for every item in this PR.
  • Deliberately excluded:
    • stdev/test/fixtures/python/* versus the Julia fixtures used by every other package — fixing this would require regenerating fixture data and updating tests, which falls outside the routine's mechanical scope.
    • entropy and kurtosis package.json description fields (Chi-squared distribution entropy. / Chi-squared distribution kurtosis.) versus the broader-stdlib convention of differential entropy / excess kurtosis — ecosystem-wide presence is 62.5% and 85.3% respectively, both below the 90% gate required to flag absence as drift.
    • Native-binding scaffolding (binding.gyp, lib/native.js, src/, include/, manifest.json, benchmark/c/, examples/c/) in ctor, median, pdf, quantile — 71% sibling presence is below the 75% threshold, and adding native bindings would require actual C implementations rather than a mechanical patch. An open PR (feat: add C implementation for stats/base/dists/chisquare/pdf #11634) is separately adding the C implementation for pdf.
    • lib/factory.js, test/test.factory.js — present only in packages that take an evaluation variable (cdf, logpdf, mgf, pdf, quantile), absent in pure summary statistics; this split is semantic, not drift.
    • Validation predicates (k < 0.0 for NonNegativeNumber-domain packages; k <= 0.0 for PositiveNumber-domain packages) — both forms are mathematically correct for the formulas in question.

Checklist

AI Assistance

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code as part of a cross-package API drift detection routine: structural and semantic features were extracted from every member of the stats/base/dists/chisquare namespace, candidate drift items were identified by majority vote (≥75% threshold), and each surviving correction was independently confirmed by three validation agents (Opus semantic review, Opus cross-reference, Sonnet structural review) before being applied. The changes are pure documentation-consistency edits — no behavior, signatures, or tests change.



Generated by Claude Code

claude added 2 commits May 26, 2026 12:26
…chisquare/median`

Replaced `var y` and `var k` with `var v` in the negative-input and NaN
`@example` blocks so the package matches the convention used by all
seven single-argument sibling distribution packages (`entropy`,
`kurtosis`, `mean`, `mode`, `skewness`, `stdev`, `variance`), where
`var v = <pkg>( ... );` appears uniformly across all four examples in
both the README and the TypeScript declaration file (87.5%
conformance). The package's own `lib/main.js` already uses `var v`
throughout, so the divergence was confined to `README.md` and
`docs/types/index.d.ts`.
…an` intro

The intro section previously read "where \`k\` is the degrees of
freedom"; updated to "where \`k >= 0\` is the degrees of freedom" to
match the convention used by the three other `NonNegativeNumber`-domain
siblings in this namespace (`mode`, `stdev`, `variance` — 3/4 = 75%
conformance). The constraint matches the existing Notes statement
"If provided \`k < 0\`, the function returns \`NaN\`" found later in
the same file.
@Planeshifter Planeshifter marked this pull request as ready for review May 26, 2026 16:32
@Planeshifter Planeshifter requested a review from a team May 26, 2026 16:32
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels May 26, 2026
@Planeshifter
Copy link
Copy Markdown
Member Author

/stdlib merge

@Planeshifter Planeshifter requested a review from kgryte May 26, 2026 16:33
@stdlib-bot stdlib-bot added bot: In Progress Pull request is currently awaiting automation. and removed bot: In Progress Pull request is currently awaiting automation. labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants