scvi.distributions.BetaBinomial#

class scvi.distributions.BetaBinomial(total_count, alpha=None, beta=None, mu=None, gamma=None, validate_args=False, eps=1e-08)[source]#

Bases: BetaBinomial

Beta binomial distribution.

One of the following parameterizations must be provided:

1. (alpha, beta, total_counts) where alpha and beta are the shape parameters of the beta distribution and total_counts is the number of trials.

2. (mu, gamma, total_counts), which is the one used by methylVI. These parameters respectively control the mean and dispersion of the distribution.

In the (mu, gamma) parameterization, samples from the beta-binomial are generated as follows:

  1. \(p_i \sim \textrm{Beta}(\mu, \gamma)\)

  2. \(y_i \sim \textrm{Ber}(p_i)\)

  3. \(y = \sum_{i}y_i\)

Parameters:
  • total_count (Tensor) – Number of trials. Must be a non-negative integer.

  • alpha (Tensor | None (default: None)) – As in BetaBinomial, serves as the first shape parameterization of the beta distribution. Must be greater than 0.

  • beta (Tensor | None (default: None)) – As in BetaBinomial, serves as the second shape parameterization of the beta distribution. Must be greater than 0.

  • mu (Tensor | None (default: None)) – Mean of the distribution. Must be within the interval (0, 1).

  • gamma (Tensor | None (default: None)) – Dispersion. Must be within the interval (0, 1).

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

  • eps (float (default: 1e-08)) – Numerical stability constant. (See Notes)

Notes

Under the hood we use BetaBinomial to implement the Beta-Binomial distribution. Thus, when the user specifies a (mu, gamma) parameterization, we must convert to the (alpha, beta) parameterization used by the underlying Pyro distribution class. During this process, numerical stability issues sometimes cause alpha or beta to be equal to (exactly) zero. This is not allowed (alpha and beta must be strictly greater than 0), so we clamp these values to be greater than a small constant eps.

Attributes table#

Methods table#

sample([sample_shape])

Sample from the distribution.

Attributes#

BetaBinomial.arg_constraints = {'alpha': Optional(GreaterThan(lower_bound=0)), 'beta': Optional(GreaterThan(lower_bound=0)), 'gamma': Optional(OpenInterval(lower_bound=0, upper_bound=1)), 'mu': Optional(OpenInterval(lower_bound=0, upper_bound=1)), 'total_count': IntegerGreaterThan(lower_bound=0)}#
BetaBinomial.support = IntegerGreaterThan(lower_bound=0)#

Methods#

BetaBinomial.sample(sample_shape=())[source]#

Sample from the distribution.

Return type:

Tensor