Repository navigation
fix: return the limiting density at x = 0 and x = 1 in stats/base/dists/kumaraswamy/pdf and logpdf - #15606
Open
Abhist17 wants to merge 1 commit into
Open
fix: return the limiting density at x = 0 and x = 1 in stats/base/dists/kumaraswamy/pdf and logpdf#15606Abhist17 wants to merge 1 commit into
x = 0 and x = 1 in stats/base/dists/kumaraswamy/pdf and logpdf#15606Abhist17 wants to merge 1 commit into
Conversation
…e/dists/kumaraswamy/pdf` and `logpdf` Both returned `0` (`-Infinity`) at either end of the support, whatever the shape parameters. Return `+Infinity`, `b` (`a` at `x = 1`) or `0` when the corresponding shape parameter is below, equal to or above one, matching `stats/base/dists/beta/pdf` and `logpdf`. `Kumaraswamy(1, b)` is `Beta(1, b)`, and `Kumaraswamy(1, 1)` is `Uniform(0, 1)`, whose `pdf` returns `1` at `0`.
5 of 7 tasks
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
5 of 7 tasks
Member
|
@Planeshifter Mind taking a look at this PR? |
This branch has not been deployed
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:
stats/base/dists/kumaraswamy/pdfandlogpdfreturn the limiting density at the two ends of the support. Both currently return0(-Infinity) atx = 0andx = 1for all shape parameters.The density is
a b x^(a-1) (1-x^a)^(b-1). Atx = 0its limit is+Infinity,bor0foraless than, equal to or greater than1. Atx = 1it is+Infinity,aor0forbless than, equal to or greater than1. This PR returns those values, and their logarithms inlogpdf, using the same structure asbeta/pdfandbeta/logpdf. Their READMEs describe the support as(0,1)too, but the code already handles the boundaries this way. Julia'spdf( Kumaraswamy( a, b ), x )returns the same values (Inf,2.0,0.0atx = 0fora = 0.5, 1, 2withb = 2).Changes:
pdf/lib/main.js,pdf/lib/factory.js,logpdf/lib/main.js,logpdf/lib/factory.js,logpdf/src/main.c: add boundary branches, andx < 0 || x > 1stays0/-Infinity.logpdf/manifest.jsongains@stdlib/constants/float64/pinf.pdf( 1.0, 0.5, 1.0 ) === 0andpdf( 0.0, 0.5, 1.0 ) === 0, but those densities are0.5and+Infinity. I moved those two points out of the support tests. There are new tests for both boundaries with each shape parameter below, at and above one, in all five test files.Related Issues
This pull request has the following related issues:
ln(sqrt(2/pi))instead ofNaNforx = 0andk = 1instats/base/dists/chi/logpdf#15604+Infinityatx = 0fork < 1instats/base/dists/weibull/pdfandlogpdf#15605Questions
The README equations define the density as
0outside the open interval(0,1), the same asbeta/pdf's README. I've left them alone, to match beta. If you'd rather the boundary convention were written down explicitly, I can add a note to both.Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code. The bug was found by comparing every
stats/base/distsfunction against SciPy on random parameters.@stdlib-js/reviewers