Repository navigation
docs: fix inconsistent JSDoc annotations - #13959
Merged
Merged
Conversation
The bound top-level PRNG in `lib/main.js` was documented with
`@function chisquare`, deviating from the sampler convention. 32 of 33
distribution samplers (and 37 of 43 namespace members) tag the assigned
generator with `@name`; only the PRNG engines (`minstd`, `minstd-shuffle`,
`mt19937`) use `@function`. `chisquare` is a distribution sampler and its
tag is paired with `@type {PRNG}`, so `@name` is the correct annotation.
The top-level generator in `lib/main.js` was annotated `@type {Function}`,
the sole such case in the namespace. 40 of 43 namespace members annotate
the `factory()`-returned generator with the more specific `@type {PRNG}`.
`rayleigh` already uses `@name rayleigh`; the generic `{Function}` type is
stale drift.
The `lib/validate.js` JSDoc documented `beta` as the "shape parameter", contradicting the package's own `lib/factory.js` and `lib/main.js` (both "scale parameter") and the scale-family sibling convention (invgamma, laplace, logistic, lognormal, weibull, frechet all document their positive scale parameter as "scale parameter"). The Gumbel distribution has only location and scale parameters, so "scale parameter" is correct.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
approved these changes
Aug 6, 2026
random/base samplers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request corrects three drifted JSDoc annotations in
random/basedistribution samplers, normalizing each outlier to the convention shared by the rest of the namespace. No runtime behavior, signatures, or tests change.Namespace summary
random/basedirect children with apackage.json) — 33 distribution samplers plus 10 PRNG engines/utilities (mt19937,minstd,minstd-shuffle,box-muller,improved-ziggurat,randi,randn,randu,reviver,shared).package.jsonshape, README section list/order,manifest.jsonshape, andtest/benchmark/examplesnaming (structural); public signature, return kind, validation prologue, error construction, JSDoc shape, and dependencies (semantic).format),package.jsontop-level keys, README section set and order,benchmark/test/examplesfile sets, factory@returns/option JSDoc types, the@namegenerator tag (37/43), the@type {PRNG}generator annotation (40/43), and the "scale parameter" description convention.lib/validate.jspresence (25/43 = 58% — absence tracks single-parameter distributions, a semantic difference, not drift);package.jsonscripts/stdlibsub-keys; per-package return type (discrete distributions return integers, continuous return numbers — semantic).random/base/chisquareThe top-level generator in
lib/main.jscarried@function chisquarewhile being an assigned PRNG value tagged@type {PRNG}. Distribution samplers document the bound generator with@name(32/33 samplers; 37/43 members);@functionbelongs to the PRNG-engine cluster (minstd,minstd-shuffle,mt19937). Retagged to@name chisquare.random/base/rayleighThe generator in
lib/main.jswas annotated@type {Function}— the only such case in the namespace. 40/43 members annotate thefactory()-returned generator with the more specific@type {PRNG}, andrayleighalready used@name rayleigh. Narrowed the stale generic annotation to@type {PRNG}.random/base/gumbellib/validate.jsdescribedbetaas the "shape parameter", contradicting the package's ownlib/factory.jsandlib/main.js(both "scale parameter") and every scale-family sibling (invgamma,laplace,logistic,lognormal,weibull,frechet). The Gumbel distribution is parameterized by location and scale only. Corrected to "scale parameter".Related Issues
No related issues.
Questions
No.
Other
Corrections were selected by a cross-package majority-vote drift analysis over all 43
random/basemembers and validated by a three-pass review (semantic-review, cross-reference against tests/examples, and structural-review). Each surviving correction is confirmed drift, is mechanical, and is behavior-preserving with no test or example dependency.Deliberately excluded:
@functioncluster (minstd,minstd-shuffle,mt19937) — an intentional engine convention, not drift.lib/validate.jsabsence in single-parameter samplers (bernoulli,chi,chisquare,exponential,geometric,poisson,rayleigh,t) — a semantic difference (single inline check vs. a shared multi-parameter helper).One additional finding is noted but not included here:
random/base/binomiallib/validate.jsinterpolates the wrong variable (pinstead ofn) in its first-argument error message, so an invalidncurrently reportsp's value. It is confirmed drift against the unanimous sibling convention (each check interpolates the argument it validates), but the fix alters a runtime diagnostic string (observable behavior) and is therefore out of scope for this docs-only PR. Flagging for maintainer follow-up.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code running an automated cross-package drift-detection routine. It extracted structural and semantic features across all 43
random/basemembers, computed the per-feature majority convention, and applied the three JSDoc corrections above to the outlier packages. A three-agent validation pass confirmed each correction as unintentional drift with no behavioral or test impact, and each modified line was re-read against its siblings before committing.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01Hcthcf81vj8b3zxDKoJRsT
Generated by Claude Code