scvi.distributions.ZeroInflatedGamma#

class scvi.distributions.ZeroInflatedGamma(concentration, rate, zi_logits, scale=None, validate_args=False)[source]#

Bases: Gamma

Zero-inflated Gamma distribution.

A mixture distribution of a point mass at zero and a Gamma distribution. This is ideal for continuous positive data with excess zeros.

In the (concentration, rate, 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\): \(x \sim \textrm{Gamma}(\alpha, \beta)\)

The probability density function is:

\[\begin{split}f(x; \alpha, \beta, \pi) = \begin{cases} \pi & \text{if } x = 0 \\ (1 - \pi) \cdot f_{\Gamma}(x) & \text{if } x > 0 \end{cases}\end{split}\]

where \(f_{\Gamma}(x; \alpha, \beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1} e^{-\beta x}\) is the Gamma density.

Parameters:
  • concentration (Tensor) – Shape parameter (α > 0) of the Gamma distribution.

  • rate (Tensor) – Rate parameter (β > 0) of the Gamma distribution.

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

  • scale (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.

Methods table#

get_normalized(key)

Get normalized values.

log_prob(value)

Log probability.

sample([sample_shape])

Sample from the distribution.

Attributes#

ZeroInflatedGamma.arg_constraints = {'concentration': Optional(GreaterThan(lower_bound=0)), 'rate': Optional(GreaterThan(lower_bound=0)), 'zi_logits': Optional(Real())}#
ZeroInflatedGamma.mean[source]#

Mean of the zero-inflated distribution.

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

Variance of the zero-inflated distribution.

ZeroInflatedGamma.zi_logits[source]#

ZI logits.

ZeroInflatedGamma.zi_probs[source]#

ZI probabilities.

Methods#

ZeroInflatedGamma.get_normalized(key)[source]#

Get normalized values.

Return type:

Tensor

ZeroInflatedGamma.log_prob(value)[source]#

Log probability.

Return type:

Tensor

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

Sample from the distribution.

Return type:

Tensor