scvi.distributions.JaxNegativeBinomialMeanDisp#
- class scvi.distributions.JaxNegativeBinomialMeanDisp(mean, inverse_dispersion, validate_args=None, eps=1e-08)[source]#
Negative binomial parameterized by mean and inverse dispersion.
Attributes table#
Returns the shape over which the distribution parameters are batched. |
|
Number of dimensions of individual events. |
|
Returns the shape of a single sample from the distribution without batching. |
|
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the mean is: |
|
|
|
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the variance is: |
Methods table#
|
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the cumulative distribution function is: |
|
Returns the entropy of the distribution. |
|
Returns an array with shape len(support) x batch_shape containing all values in the support. |
|
Returns a new |
|
Expands a distribution by adding |
|
Get arguments of the distribution. |
|
The inverse cumulative distribution function of this distribution. |
|
Infers |
|
Log probability. |
|
Masks a distribution by a boolean or boolean-valued array that is broadcastable to the distributions |
|
|
|
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the sampling procedure is: |
|
Same as |
|
|
|
The tensor shape of samples from this distribution. |
|
Interpret the rightmost reinterpreted_batch_ndims batch dimensions as dependent event dimensions. |
|
|
|
Validate the arguments of the distribution. |
Attributes#
- JaxNegativeBinomialMeanDisp.arg_constraints: dict[str, Any] = {'inverse_dispersion': Positive(lower_bound=0.0), 'mean': Positive(lower_bound=0.0)}#
- JaxNegativeBinomialMeanDisp.batch_shape[source]#
Returns the shape over which the distribution parameters are batched.
- JaxNegativeBinomialMeanDisp.event_dim[source]#
Number of dimensions of individual events. :rtype: int
- Type:
return
- JaxNegativeBinomialMeanDisp.event_shape[source]#
Returns the shape of a single sample from the distribution without batching.
- JaxNegativeBinomialMeanDisp.has_enumerate_support: bool = False#
- JaxNegativeBinomialMeanDisp.pytree_aux_fields: tuple[str, ...] = ('_batch_shape', '_event_shape')#
- JaxNegativeBinomialMeanDisp.pytree_data_fields: tuple[str, ...] = ('concentration',)#
- JaxNegativeBinomialMeanDisp.reparametrized_params: list[str] = []#
- JaxNegativeBinomialMeanDisp.support(x) = IntegerNonnegative(lower_bound=0)#
Methods#
- JaxNegativeBinomialMeanDisp.cdf(value)[source]#
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the cumulative distribution function is:
\[F_{X}(x) = \frac{1}{\mathrm{B}(\alpha, x + 1)} \int_{0}^{\frac{\lambda}{1 + \lambda}} t^{\alpha - 1} (1 - t)^{x} dt\]which is the regularized incomplete beta function. This implementation uses
betainc().
- JaxNegativeBinomialMeanDisp.enumerate_support(expand=True)[source]#
Returns an array with shape len(support) x batch_shape containing all values in the support.
- JaxNegativeBinomialMeanDisp.expand(batch_shape)[source]#
Returns a new
ExpandedDistributioninstance with batch dimensions expanded to batch_shape.- Parameters:
batch_shape (tuple) – batch shape to expand to.
- Returns:
an instance of ExpandedDistribution.
- Return type:
ExpandedDistribution
- JaxNegativeBinomialMeanDisp.expand_by(sample_shape)[source]#
Expands a distribution by adding
sample_shapeto the left side of itsbatch_shape. To expand internal dims ofself.batch_shapefrom 1 to something larger, useexpand()instead.- Parameters:
sample_shape (tuple) – The size of the iid batch to be drawn from the distribution.
- Returns:
An expanded version of this distribution.
- Return type:
ExpandedDistribution
- JaxNegativeBinomialMeanDisp.icdf(q)[source]#
The inverse cumulative distribution function of this distribution.
- classmethod JaxNegativeBinomialMeanDisp.infer_shapes(*args, **kwargs)[source]#
Infers
batch_shapeandevent_shapegiven shapes of args to__init__().Note
This assumes distribution shape depends only on the shapes of tensor inputs, not in the data contained in those inputs.
- Parameters:
- Returns:
A pair
(batch_shape, event_shape)of the shapes of a distribution that would be created with input args of the given shapes.- Return type:
- JaxNegativeBinomialMeanDisp.mask(mask)[source]#
Masks a distribution by a boolean or boolean-valued array that is broadcastable to the distributions
Distribution.batch_shape.- Parameters:
mask (bool or jnp.ndarray) – A boolean or boolean valued array (True includes a site, False excludes a site).
- Returns:
A masked copy of this distribution.
- Return type:
MaskedDistribution
Example:
- JaxNegativeBinomialMeanDisp.sample(key, sample_shape=())[source]#
If \(X \sim \mathrm{GammaPoisson}(\alpha, \lambda)\), then the sampling procedure is:
\[\begin{split}\begin{align*} \theta &\sim \mathrm{Gamma}(\alpha, \lambda) \\ X \mid \theta &\sim \mathrm{Poisson}(\theta) \end{align*}\end{split}\]It uses
Gammato generate samples from the Gamma distribution andPoissonto generate samples from the Poisson distribution.
- JaxNegativeBinomialMeanDisp.sample_with_intermediates(key, sample_shape=())[source]#
Same as
sampleexcept that any intermediate computations are returned (useful for TransformedDistribution).- Parameters:
key (jax.random.key) – the rng_key key to be used for the distribution.
sample_shape (tuple) – the sample shape for the distribution.
- Returns:
an array of shape sample_shape + batch_shape + event_shape
- Return type:
- JaxNegativeBinomialMeanDisp.shape(sample_shape=())[source]#
The tensor shape of samples from this distribution.
Samples are of shape:
d.shape(sample_shape) == sample_shape + d.batch_shape + d.event_shape
- JaxNegativeBinomialMeanDisp.to_event(reinterpreted_batch_ndims=None)[source]#
Interpret the rightmost reinterpreted_batch_ndims batch dimensions as dependent event dimensions.
- classmethod JaxNegativeBinomialMeanDisp.tree_unflatten(aux_data, params)[source]#
- Return type:
Distribution