scvi.distributions.NegativeBinomial#

class scvi.distributions.NegativeBinomial(total_count=None, probs=None, logits=None, mu=None, theta=None, scale=None, validate_args=False)[source]#

Bases: Distribution

Negative binomial distribution.

One of the following parameterizations must be provided:

(1), (total_count, probs) where total_count is the number of failures until the experiment is stopped and probs the success probability. (2), (mu, theta) parameterization, which is the one used by scvi-tools. These parameters respectively control the mean and inverse dispersion of the distribution.

In the (mu, theta) parameterization, samples from the negative binomial are generated as follows:

  1. \(w \sim \textrm{Gamma}(\underbrace{\theta}_{\text{shape}}, \underbrace{\theta/\mu}_{\text{rate}})\)

  2. \(x \sim \textrm{Poisson}(w)\)

Parameters:
  • total_count (Tensor | None (default: None)) – Number of failures until the experiment is stopped.

  • probs (Tensor | None (default: None)) – The success probability.

  • mu (Tensor | None (default: None)) – Mean of the distribution.

  • theta (Tensor | None (default: None)) – Inverse dispersion.

  • 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

Returns the mean of the distribution.

support

variance

Returns the variance of the distribution.

Methods table#

get_normalized(key)

log_prob(value)

Returns the log of the probability density/mass function evaluated at value.

sample([sample_shape])

Sample from the distribution.

Attributes#

NegativeBinomial.arg_constraints = {'mu': Optional(GreaterThanEq(lower_bound=0)), 'scale': Optional(GreaterThanEq(lower_bound=0)), 'theta': Optional(GreaterThanEq(lower_bound=0))}#
NegativeBinomial.mean[source]#
NegativeBinomial.support = IntegerGreaterThan(lower_bound=0)#
NegativeBinomial.variance[source]#

Methods#

NegativeBinomial.get_normalized(key)[source]#
Return type:

Tensor

NegativeBinomial.log_prob(value)[source]#

Returns the log of the probability density/mass function evaluated at value.

Parameters:

value (Tensor)

Return type:

Tensor

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

Sample from the distribution.

Return type:

Tensor