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:
BetaBinomialBeta 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:\(p_i \sim \textrm{Beta}(\mu, \gamma)\)
\(y_i \sim \textrm{Ber}(p_i)\)
\(y = \sum_{i}y_i\)
- Parameters:
total_count (
Tensor) – Number of trials. Must be a non-negative integer.alpha (
Tensor|None(default:None)) – As inBetaBinomial, serves as the first shape parameterization of the beta distribution. Must be greater than0.beta (
Tensor|None(default:None)) – As inBetaBinomial, serves as the second shape parameterization of the beta distribution. Must be greater than0.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)) – RaiseValueErrorif arguments do not match the constraints.eps (
float(default:1e-08)) – Numerical stability constant. (See Notes)
Notes
Under the hood we use
BetaBinomialto 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 causealphaorbetato be equal to (exactly) zero. This is not allowed (alphaandbetamust be strictly greater than 0), so we clamp these values to be greater than a small constanteps.
Attributes table#
Methods table#
|
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)#