feat(distributions): add Kumaraswamy distribution#330
Open
Sumu004 wants to merge 1 commit into
Open
Conversation
Adds distrax.Kumaraswamy(concentration0, concentration1) — the
Kumaraswamy distribution on (0, 1) with parameters a > 0 and b > 0.
Unlike the Beta distribution, Kumaraswamy has a closed-form CDF and
inverse CDF, making it well-suited for reparameterized sampling in
variational inference and normalizing flows.
Implements:
- log_prob(x) = log(a) + log(b) + (a-1)log(x) + (b-1)log(1-x^a)
- log_cdf(x) = log(1 - (1-x^a)^b)
- mean() = b · B(1+1/a, b) via log-gammas (numerically stable)
- variance() = b · B(1+2/a, b) − mean²
- mode() = ((a-1)/(ab-1))^(1/a) for a,b≥1; boundary modes at 0/1
- entropy() = (1-1/b) − log(ab) + (1-1/a)·(γ + ψ(b+1))
(exact closed form derived from the digamma identity)
- sample() via the closed-form quantile F^{-1}(u) = (1-(1-u)^{1/b})^{1/a}
Adds distrax.Kumaraswamy to the public __init__.py and 20 tests
covering log_prob, log_cdf, mean, variance, mode, entropy (all
validated against TFP), sampling shape/range/moments, and JIT.
Reference: Kumaraswamy (1980), Journal of Hydrology, 46(1–2), 79–88.
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.
What does this PR do?
Adds
distrax.Kumaraswamy(concentration0, concentration1)— the Kumaraswamy distribution on the open interval (0, 1).The Kumaraswamy distribution (Kumaraswamy 1980) has PDF
f(x; a, b) = ab·x^{a-1}·(1−x^a)^{b-1}and the key property that its CDF and quantile function have closed forms, unlike the Beta distribution. This makes it well-suited for:Implemented
log_prob(x)log(ab) + (a-1)log x + (b-1)log(1-x^a)log_cdf(x)log(1 − (1−x^a)^b)mean()b · B(1+1/a, b)via log-gammasvariance()b · B(1+2/a, b) − mean²mode()((a-1)/(ab-1))^{1/a}for interior; 0/1 at boundariesentropy()(1−1/b) − log(ab) + (1−1/a)·(γ + ψ(b+1))(exact)sample()(1 − (1−u)^{1/b})^{1/a}, u ~ UniformTests
20 tests in
kumaraswamy_test.py— log_prob / log_cdf / mean / variance / mode / entropy all validated against TFP; sampling shape, range, and moments; JIT compatibility.Reference
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1–2), 79–88.