Abstract Distributions¤
distreqx.distributions.AbstractDistribution
¤
Base class for all distreqx distributions.
log_prob(value: PyTree[Array]) -> PyTree[Array]
¤
Calculates the log probability of an event.
Arguments:
value: An event.
Returns:
- The log probability \(\log P(x)\) for \(x\) equal to
value.
prob(value: PyTree[Array]) -> PyTree[Array]
¤
Calculates the probability of an event.
Arguments:
value: An event.
Returns:
- The probability \(P(x)\) for \(x\) equal to
value.
icdf(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the inverse cumulative distribution function at value.
For a given probability \(u\), returns the value \(x\) such that \(P(X \le x) = u\).
Arguments:
value: A probability value in \([0, 1]\).
Returns:
- The ICDF evaluated at
value, i.e. \(x\) such that \(F(x) = u\).
cdf(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the cumulative distribution function at value.
Arguments:
value: An event.
Returns:
- The CDF evaluated at
value, i.e. \(P(X \le x)\) with \(x\) equal tovalue.
survival_function(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the survival function at value.
Note that by default we use a numerically not necessarily stable definition of the survival function in terms of the CDF. More stable definitions should be implemented in subclasses for distributions for which they exist.
Arguments:
value: An event.
Returns:
- The survival function evaluated at
value, i.e. \(P(X > x)\) with \(x\) equal tovalue.
log_survival_function(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the log of the survival function at value.
Note that by default we use a numerically not necessarily stable definition of the log of the survival function in terms of the CDF. More stable definitions should be implemented in subclasses for distributions for which they exist.
Arguments:
value: An event.
Returns:
- The log of the survival function evaluated at
value, i.e. \(\log P(X > x)\) with \(x\) equal tovalue.
kl_divergence(other_dist, **kwargs) -> PyTree[Array]
¤
Calculates the KL divergence to another distribution.
Arguments:
other_dist: A compatible distreqx Distribution.kwargs: Additional kwargs.
Returns:
- The divergence \(D_{\mathrm{KL}}(P \parallel Q)\), where \(P\) is this
distribution and \(Q\) is
other_dist.
cross_entropy(other_dist, **kwargs) -> Array
¤
Calculates the cross entropy to another distribution.
Arguments:
other_dist: A compatible distreqx Distribution.kwargs: Additional kwargs.
Returns:
- The cross entropy \(H(P, Q)\), where \(P\) is this distribution and \(Q\) is
other_dist.
distreqx.distributions.AbstractSampleLogProbDistribution(distreqx.distributions.AbstractDistribution)
¤
Abstract distribution + concrete sample_and_log_prob.
distreqx.distributions.AbstractProbDistribution(distreqx.distributions.AbstractDistribution)
¤
Abstract distribution + concrete prob.
prob(value: PyTree[Array]) -> PyTree[Array]
¤
Calculates the probability of an event.
Arguments:
value: An event.
Returns:
- The probability \(P(x)\) for \(x\) equal to
value.
distreqx.distributions.AbstractCDFDistribution(distreqx.distributions.AbstractDistribution)
¤
Abstract distribution + concrete cdf.
cdf(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the cumulative distribution function at value.
Arguments:
value: An event.
Returns:
- The CDF evaluated at
value, i.e. \(P(X \le x)\) with \(x\) equal tovalue.
distreqx.distributions.AbstractSTDDistribution(distreqx.distributions.AbstractDistribution)
¤
Abstract distribution + concrete stddev.
stddev() -> PyTree[Array]
¤
Calculate the standard deviation.
distreqx.distributions.AbstractSurvivalDistribution(distreqx.distributions.AbstractDistribution)
¤
Abstract distribution + concrete survival_function and
log_survival_function.
survival_function(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the survival function at value.
Note that by default we use a numerically not necessarily stable definition of the survival function in terms of the CDF. More stable definitions should be implemented in subclasses for distributions for which they exist.
Arguments:
value: An event.
Returns:
- The survival function evaluated at
value, i.e. \(P(X > x)\) with \(x\) equal tovalue.
log_survival_function(value: PyTree[Array]) -> PyTree[Array]
¤
Evaluates the log of the survival function at value.
Note that by default we use a numerically not necessarily stable definition of the log of the survival function in terms of the CDF. More stable definitions should be implemented in subclasses for distributions for which they exist.
Arguments:
value: An event.
Returns:
- The log of the survival function evaluated at
value, i.e. \(\log P(X > x)\) with \(x\) equal tovalue.
distreqx.distributions.AbstractTransformed(distreqx.distributions.AbstractSurvivalDistribution, distreqx.distributions.AbstractProbDistribution)
¤
Abstract base class for transformed distributions.
See distreqx.distributions.Transformed for full documentation.
dtype
property
¤
See Distribution.dtype.
event_shape
property
¤
See Distribution.event_shape.
log_prob(value: PyTree) -> Array
¤
See Distribution.log_prob.
sample(key: Key[Array, '']) -> PyTree
¤
Return a sample.
sample_and_log_prob(key: Key[Array, '']) -> tuple
¤
Return a sample and log prob.
This function is more efficient than calling sample and log_prob
separately, because it uses only the forward methods of the bijector. It
also works for bijectors that don't implement inverse methods.
Arguments:
key: PRNG key.
Returns:
- A tuple of a sample and its log probs.
entropy(input_hint: PyTree | None = None) -> Array
¤
Calculates the Shannon entropy (in Nats).
Only works for bijectors with constant Jacobian determinant.
Arguments:
input_hint: an example sample from the base distribution, used to compute the constant forward log-determinant. If not specified, it is computed using a zero array of the shape and dtype of a sample from the base distribution.
Returns:
- The entropy of the distribution.
Raises:
NotImplementedError: if bijector's Jacobian determinant is not known to be constant.
distreqx.distributions.AbstractMultivariateNormalFromBijector(distreqx.distributions.AbstractTransformed)
¤
AbstractMultivariateNormalFromBijector()
variance() -> PyTree[Array]
¤
Calculates the variance.
stddev() -> PyTree[Array]
¤
Calculates the standard deviation.
kl_divergence(other_dist, **kwargs) -> Array
¤
Calculates the KL divergence to another distribution.
Arguments:
other_dist: A compatible disteqx distribution.kwargs: Additional kwargs.
Returns:
The divergence \(D_{\mathrm{KL}}(P \parallel Q)\), where \(P\) is this
distribution and \(Q\) is other_dist.