Skip to content
class

Kumaraswamy

extendsDistribution
Kumaraswamy(concentration1: Tensor | float, concentration0: Tensor | float, validate_args: bool | None = None)

Kumaraswamy distribution on [0,1][0, 1].

Two-parameter continuous distribution on the unit interval that mimics the shapes of the lucid.distributions.Beta distribution but has a closed-form CDF and inverse CDF. This makes it a popular choice in variational autoencoders and normalising flows where cheap, exact reparameterised sampling is needed and no special functions are required.

Parameters

concentration1Tensor or float
First shape parameter a>0a > 0.
concentration0Tensor or float
Second shape parameter b>0b > 0.
validate_argsbool= None
If True, validate parameter constraints at construction time.

Notes

Probability density on x∈[0,1]x \in [0, 1]:

p(x;a,b)=a b xa−1(1−xa)b−1p(x; a, b) = a\, b\, x^{a - 1} (1 - x^a)^{b - 1}

Cumulative distribution (closed form):

F(x;a,b)=1−(1−xa)bF(x; a, b) = 1 - (1 - x^a)^b

Inverse CDF (used by rsample):

F−1(u;a,b)=(1−(1−u)1/b)1/aF^{-1}(u; a, b) = (1 - (1 - u)^{1/b})^{1/a}

Moments are expressible in closed form via the Beta function:

E[Xn]=b B(1+n/a, b)\mathbb{E}[X^n] = b\, B(1 + n/a,\, b)

Special cases:

  • a=1a = 1 → Beta(1,b)\mathrm{Beta}(1, b)
  • b=1b = 1 → Beta(a,1)\mathrm{Beta}(a, 1)

Unlike Beta, Kumaraswamy is not a member of the exponential family and lacks an analytic normalising integral for sums. Its main advantage is the lack of any reliance on the gamma function in forward or backward passes.

Examples

>>> import lucid
>>> from lucid.distributions import Kumaraswamy
>>> d = Kumaraswamy(concentration1=2.0, concentration0=5.0)
>>> d.rsample((4,)).shape
(4,)
>>> d.log_prob(lucid.tensor(0.3))  # log(2 * 5 * 0.3 * (1 - 0.3**2)**4)
tensor(0.7214)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(concentration1: Tensor | float, concentration0: Tensor | float, validate_args: bool | None = None)

Initialise a Kumaraswamy distribution.

Parameters

concentration1Tensor | float
First shape parameter a>0a > 0 (controls the left tail).
concentration0Tensor | float
Second shape parameter b>0b > 0 (controls the right tail).
validate_argsbool | None= None
If True, validate parameter constraints at construction time.

Properties

3
prop

mean

→Tensor
mean: Tensor

E[X] = b · B(1 + 1/a, b), through the log-beta.

prop

mode

→Tensor
mode: Tensor

Mode of the Kumaraswamy distribution.

(a−1ab−1)1/a(a,b≥1)\left(\frac{a - 1}{a b - 1}\right)^{1/a} \quad (a, b \geq 1)

with aa = concentration1 and bb = concentration0; nan when either is below 1, as the reference framework answers. The reference evaluates a different expression and answers nan for every b>1b > 1 as well; this is the closed form.

prop

variance

→Tensor
variance: Tensor

Var[X] = E[X²] − E[X]² where E[X²] = b · B(1 + 2/a, b).

Instance methods

6
fn

cdf

→Tensor
cdf(value: Tensor)

Cumulative distribution function of the Kumaraswamy distribution.

F(x;a,b)=1−(1−xa)b,x∈[0,1]F(x; a, b) = 1 - (1 - x^a)^b, \quad x \in [0, 1]

Evaluated as −expm1⁡(blog⁡(1−xa))-\operatorname{expm1}(b \log(1 - x^a)), which keeps the left tail's relative precision.

Returns probabilities in [0,1][0, 1]; 0 below the support and 1 above it.

Examples

>>> Kumaraswamy(1.0, 1.0).cdf(lucid.tensor(0.25))  # Uniform(0, 1)
tensor(0.25)
fn

entropy

→Tensor
entropy()

Entropy via the Beta-distributed auxiliary variable Y = X^a.

If X ~ Kumaraswamy(a, b) then Y = X^a ~ Beta(1, b), giving: E[log X] = (1/a)(ψ(1) − ψ(b+1)) = −(1/a)(γ + ψ(b+1)) E[log(1−X^a)] = ψ(b) − ψ(b+1) = −1/b

H = −log a − log b − (a−1)·E[log X] − (b−1)·E[log(1−X^a)] = −log a − log b + (1 − 1/a)(γ + ψ(b+1)) + (1 − 1/b)

fn

expand

→Self
expand(batch_shape: Sequence[int], _instance: Self | None = None)

Return a new Kumaraswamy with batch dimensions expanded to batch_shape.

fn

icdf

→Tensor
icdf(value: Tensor)

Quantile function of the Kumaraswamy distribution.

Q(p;a,b)=(1−(1−p)1/b)1/aQ(p; a, b) = \left(1 - (1 - p)^{1/b}\right)^{1/a}

Returns quantiles in [0,1][0, 1].

Examples

>>> Kumaraswamy(1.0, 1.0).icdf(lucid.tensor(0.25))
tensor(0.25)
fn

log_prob

→Tensor
log_prob(value: Tensor)

Log-probability density of the Kumaraswamy distribution.

Parameters

valueTensor
Point(s) x∈[0,1]x \in [0, 1] at which to evaluate the density.

Returns

Tensor

Log-density log⁡a+log⁡b+(a−1)log⁡x+(b−1)log⁡(1−xa)\log a + \log b + (a-1)\log x + (b-1)\log(1-x^a).

Notes

The two weighted logarithms are lucid.xlogy and lucid.special.xlog1py, so the ends of the support score the density's limit there: at x=0x = 0 it is +inf for a<1a < 1, -inf for a>1a > 1 and log⁡b\log b for a=1a = 1; x=1x = 1 is the same in bb. The reference framework answers NaN at both ends.

fn

rsample

→Tensor
rsample(sample_shape: tuple[int, ...] = ())

Reparameterised sample via the icdf: x = (1 − (1 − U)^(1/b))^(1/a).