Kumaraswamy
DistributionKumaraswamy(concentration1: Tensor | float, concentration0: Tensor | float, validate_args: bool | None = None)Kumaraswamy distribution on .
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
Notes
Probability density on :
Cumulative distribution (closed form):
Inverse CDF (used by rsample):
Moments are expressible in closed form via the Beta function:
Special cases:
- →
- →
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__init__
→None__init__(concentration1: Tensor | float, concentration0: Tensor | float, validate_args: bool | None = None)Properties
3E[X] = b · B(1 + 1/a, b) expressed via lgamma.
Mode of the Kumaraswamy distribution.
with = concentration1 and = concentration0;
nan when either is below 1, as the reference framework answers.
The reference evaluates a different expression and answers nan
for every as well; this is the closed form.
Var[X] = E[X²] − E[X]² where E[X²] = b · B(1 + 2/a, b).
Instance methods
5Cumulative distribution function of the Kumaraswamy distribution.
Evaluated as , which keeps the left tail's relative precision.
Returns probabilities in ; 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)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)
Quantile function of the Kumaraswamy distribution.
Returns quantiles in .
Examples
>>> Kumaraswamy(1.0, 1.0).icdf(lucid.tensor(0.25))
tensor(0.25)Log-probability density of the Kumaraswamy distribution.
Parameters
valueTensorReturns
TensorLog-density .
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 it is +inf for
, -inf for and for
; is the same in . The
reference framework answers NaN at both ends.
Reparameterised sample via the icdf:
x = (1 − (1 − U)^(1/b))^(1/a).