Skip to content

feat(distributions): add Kumaraswamy distribution#330

Open
Sumu004 wants to merge 1 commit into
google-deepmind:mainfrom
Sumu004:feat/add-kumaraswamy-distribution
Open

feat(distributions): add Kumaraswamy distribution#330
Sumu004 wants to merge 1 commit into
google-deepmind:mainfrom
Sumu004:feat/add-kumaraswamy-distribution

Conversation

@Sumu004

@Sumu004 Sumu004 commented Jun 4, 2026

Copy link
Copy Markdown

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:

  • Reparameterized sampling in variational inference (no rejection sampling needed)
  • Normalizing flows where an invertible map on (0,1) is required
  • Drop-in replacement for Beta when differentiable sampling matters

Implemented

Method Formula
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-gammas
variance() b · B(1+2/a, b) − mean²
mode() ((a-1)/(ab-1))^{1/a} for interior; 0/1 at boundaries
entropy() (1−1/b) − log(ab) + (1−1/a)·(γ + ψ(b+1)) (exact)
sample() Closed-form quantile: (1 − (1−u)^{1/b})^{1/a}, u ~ Uniform

Tests

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant