scvi.distributions.ZeroInflatedLogNormal#

class scvi.distributions.ZeroInflatedLogNormal(mu, scale, zi_logits, normal_mu=None, validate_args=False)[source]#

Bases: LogNormal

Zero-inflated log-normal distribution.

A mixture distribution of a point mass at zero and a log-normal distribution. This is a mixed distribution with discrete support at zero and continuous support over (0, ∞).

In the (mu, scale, zi_logits) parameterization, samples are generated as follows:

  1. \(\pi = \textrm{sigmoid}(\texttt{zi\_logits})\)

  2. \(b \sim \textrm{Bernoulli}(\pi)\)

  3. If \(b = 1\): \(x = 0\)

  4. If \(b = 0\): \(z \sim \textrm{Normal}(\mu, \sigma)\), \(x = \exp(z)\)

The probability mass/density function (mixed discrete-continuous) is:

\[\begin{split}p(x; \mu, \sigma, \pi) = \begin{cases} \pi & \text{if } x = 0 \\ (1 - \pi) \cdot f_{LN}(x) & \text{if } x > 0 \end{cases}\end{split}\]

where \(f_{LN}(x; \mu, \sigma) = \frac{1}{x \sigma \sqrt{2\pi}} \exp\left(-\frac{(\ln x - \mu)^2}{2\sigma^2}\right)\) is the log-normal density.

Note: The point mass at \(x = 0\) has probability \(\pi\), and the continuous log-normal component (for \(x > 0\)) has probability \((1-\pi)\).

Parameters:
  • mu (Tensor) – Mean of the normal distribution in log space.

  • scale (Tensor) – Standard deviation of the normal distribution in log space.

  • zi_logits (Tensor) – Logits scale of zero inflation probability.

  • normal_mu (Tensor | None (default: None)) – Normalized mean expression of the distribution.

  • validate_args (bool (default: False)) – Raise ValueError if arguments do not match constraints.

Attributes table#

arg_constraints

mean

Mean of the zero-inflated distribution.

support

variance

Variance of the zero-inflated distribution.

zi_logits

ZI logits.

zi_probs

ZI probabilities.

base_dist

Methods table#

get_normalized(key)

Get normalized values.

log_prob(value)

Log probability.

sample([sample_shape])

Sample from the distribution.

Attributes#

ZeroInflatedLogNormal.arg_constraints: dict[str, Constraint] = {'loc': Optional(Real()), 'scale': Optional(GreaterThan(lower_bound=0)), 'zi_logits': Optional(Real())}#
ZeroInflatedLogNormal.mean[source]#

Mean of the zero-inflated distribution.

ZeroInflatedLogNormal.support = GreaterThanEq(lower_bound=0.0)#
ZeroInflatedLogNormal.variance[source]#

Variance of the zero-inflated distribution.

ZeroInflatedLogNormal.zi_logits[source]#

ZI logits.

ZeroInflatedLogNormal.zi_probs[source]#

ZI probabilities.

ZeroInflatedLogNormal.base_dist: Normal#

Methods#

ZeroInflatedLogNormal.get_normalized(key)[source]#

Get normalized values.

Return type:

Tensor

ZeroInflatedLogNormal.log_prob(value)[source]#

Log probability.

Return type:

Tensor

ZeroInflatedLogNormal.sample(sample_shape=None)[source]#

Sample from the distribution.

Return type:

Tensor