Skip to content

fix: return excess kurtosis in stats/base/dists/kumaraswamy/kurtosis - #16186

Open
0PrashantYadav0 wants to merge 1 commit into
stdlib-js:developfrom
0PrashantYadav0:fix/kumaraswamy-kurtosis
Open

0PrashantYadav0 wants to merge 1 commit into
stdlib-js:developfrom
0PrashantYadav0:fix/kumaraswamy-kurtosis

Conversation

@0PrashantYadav0

Copy link
Copy Markdown
Member

Resolves #15461.

Description

What is the purpose of this pull request?

This pull request:

  • fixes stats/base/dists/kumaraswamy/kurtosis to return the excess kurtosis by subtracting 3 in both the JavaScript and C implementations. Previously, the package returned μ₄/σ⁴, so every value was too high by exactly 3 (e.g., kurtosis( 1.0, 1.0 ) returned 1.8 instead of -1.2 for the standard uniform distribution).
  • fixes the README equation, which also omitted the - 3 and had an unbalanced closing parenthesis. The equation SVG will be regenerated by the markdown_equations workflow.
  • updates all documented examples (README, repl.txt, TypeScript declarations, JSDoc, C source) to the corrected values.
  • updates the kurtosis examples in stats/base/dists/kumaraswamy/ctor, whose .kurtosis getter delegates to this package.
  • replaces the TODO: Add fixtures placeholder tests in test.js and test.native.js with Julia fixtures generated by Distributions.jl, following the same pattern as kumaraswamy/mean, variance, and stdev.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

The fixture tolerance is 1043762 ULPs, which is the maximum observed difference against Distributions.jl. The worst case is b ≈ 1.5e-4, where both implementations suffer cancellation in the central moment computation. The median difference is ~260 ULPs. Happy to restrict the fixture domain instead if reviewers prefer a tighter tolerance.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Verification:

  • Kumaraswamy(a, 1) and Kumaraswamy(1, b) are exactly Beta(a, 1) and Beta(1, b). After this change, kumaraswamy/kurtosis( 3.0, 1.0 ) and kumaraswamy/kurtosis( 1.0, 3.0 ) both return ~0.0952, matching beta/kurtosis.
  • Distributions.jl's kurtosis(::Kumaraswamy) also subtracts 3.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of 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)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was prepared with the help of Claude Code. I reviewed the changes and verified the results against Distributions.jl and the Beta distribution identities.


@stdlib-js/reviewers

The implementation computed the kurtosis `μ₄/σ⁴` but never subtracted 3, so every value was off by exactly 3 from the documented excess kurtosis. This commit subtracts 3 in both the JavaScript and C implementations, fixes the README equation, updates the documented examples (including those for `kumaraswamy/ctor`), and replaces the placeholder tests with Julia fixtures.

Closes: stdlib-js#15461
@0PrashantYadav0
0PrashantYadav0 requested a review from a team October 16, 2026 04:41
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Oct 16, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/kumaraswamy/ctor $\\color{green}419/419$
$\\color{green}+100.00\\%$
$\\color{green}31/31$
$\\color{green}+100.00\\%$
$\\color{green}16/16$
$\\color{green}+100.00\\%$
$\\color{green}419/419$
$\\color{green}+100.00\\%$
stats/base/dists/kumaraswamy/kurtosis $\\color{green}211/211$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}211/211$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
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.

[Bug]: kumaraswamy/kurtosis returns non-excess kurtosis (missing −3)

2 participants