scvi.external.drvi.LogNegativeBinomial#

class scvi.external.drvi.LogNegativeBinomial(log_m, log_r, log_scale=None, validate_args=False)[source]#

Bases: Distribution

Negative binomial distribution parameterized in log space.

A negative binomial whose mean and dispersion are supplied as log_m (\(\log\mu\)) and log_r (\(\log\theta\)). The log-probability is the standard negative-binomial log-probability, but rewritten so that it is evaluated directly from the log-parameters via softplus() — this avoids ever materializing \(\mu\) or \(\theta\) and is numerically stable for very small/large means. This is DRVI’s “pnb” likelihood and is what enables the additive (log-space) split decoder.

Mathematically equivalent to scvi.distributions.NegativeBinomial with mu = exp(log_m), theta = exp(log_r).

Parameters:
  • log_m (Tensor) – Log of the mean \(\log\mu\).

  • log_r (Tensor) – Log of the inverse-dispersion \(\log\theta\) (theta = exp(log_r)).

  • log_scale (Tensor | None (default: None)) – Optional log of the library-size-independent normalized mean, exposed as scale for RNASeqMixin (e.g. log_softmax of the decoder output).

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

Attributes table#

arg_constraints

mean

Returns the mean of the distribution.

mu

scale

support

theta

variance

Returns the variance of the distribution.

Methods table#

get_normalized(key)

Return a named mean-space parameter (RNASeqMixin contract).

log_prob(value)

Negative-binomial log-probability evaluated from the log-parameters.

sample([sample_shape])

Sample via the Gamma-Poisson mixture (same as a negative binomial).

Attributes#

LogNegativeBinomial.arg_constraints = {'log_m': Real(), 'log_r': Real()}#
LogNegativeBinomial.mean[source]#
LogNegativeBinomial.mu[source]#
LogNegativeBinomial.scale[source]#
LogNegativeBinomial.support = IntegerGreaterThan(lower_bound=0)#
LogNegativeBinomial.theta[source]#
LogNegativeBinomial.variance[source]#

Methods#

LogNegativeBinomial.get_normalized(key)[source]#

Return a named mean-space parameter (RNASeqMixin contract).

Return type:

Tensor

LogNegativeBinomial.log_prob(value)[source]#

Negative-binomial log-probability evaluated from the log-parameters.

Return type:

Tensor

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

Sample via the Gamma-Poisson mixture (same as a negative binomial).

Return type:

Tensor