Continuous

Uniform(*args, **kwargs)

Continuous uniform log-likelihood.

Flat(*args, **kwargs)

Uninformative log-likelihood that returns 0 regardless of the passed value.

HalfFlat(*args, **kwargs)

Improper flat prior over the positive reals.

Normal(name, *args[, rng, dims, initval, ...])

Univariate normal log-likelihood.

TruncatedNormal(*args, **kwargs)

Univariate truncated normal log-likelihood.

Beta(name, *args[, rng, dims, initval, ...])

Beta log-likelihood.

Kumaraswamy(name, *args[, rng, dims, ...])

Kumaraswamy log-likelihood.

Exponential(name, *args[, rng, dims, ...])

Exponential log-likelihood.

Laplace(name, *args[, rng, dims, initval, ...])

Laplace log-likelihood.

StudentT(name, *args[, rng, dims, initval, ...])

Student's T log-likelihood.

Cauchy(name, *args[, rng, dims, initval, ...])

Cauchy log-likelihood.

HalfCauchy(name, *args[, rng, dims, ...])

Half-Cauchy log-likelihood.

Gamma(name, *args[, rng, dims, initval, ...])

Gamma log-likelihood.

Weibull(name, *args[, rng, dims, initval, ...])

Weibull log-likelihood.

HalfStudentT(name, *args[, rng, dims, ...])

Half Student's T log-likelihood

LogNormal(name, *args[, rng, dims, initval, ...])

Note: Class name Lognormal is deprecated, use LogNormal now!

ChiSquared(name, *args[, rng, dims, ...])

\(\chi^2\) log-likelihood.

HalfNormal(name, *args[, rng, dims, ...])

Half-normal log-likelihood.

Wald(name, *args[, rng, dims, initval, ...])

Wald log-likelihood.

Pareto(*args, **kwargs)

Pareto log-likelihood.

InverseGamma(name, *args[, rng, dims, ...])

Inverse gamma log-likelihood, the reciprocal of the gamma distribution.

ExGaussian(name, *args[, rng, dims, ...])

Exponentially modified Gaussian log-likelihood.

VonMises(name, *args[, rng, dims, initval, ...])

Univariate VonMises log-likelihood.

SkewNormal(name, *args[, rng, dims, ...])

Univariate skew-normal log-likelihood.

Triangular(*args, **kwargs)

Continuous Triangular log-likelihood

Gumbel(name, *args[, rng, dims, initval, ...])

Univariate Gumbel log-likelihood

Logistic(name, *args[, rng, dims, initval, ...])

Logistic log-likelihood.

LogitNormal(name, *args[, rng, dims, ...])

Logit-Normal log-likelihood.

Interpolated(*args, **kwargs)

Univariate probability distribution defined as a linear interpolation of probability density function evaluated on some lattice of points.

Rice(name, *args[, rng, dims, initval, ...])

Rice distribution.

Moyal(name, *args[, rng, dims, initval, ...])

Moyal log-likelihood.

AsymmetricLaplace(name, *args[, rng, dims, ...])

Asymmetric-Laplace log-likelihood.

PolyaGamma(name, *args[, rng, dims, ...])

The Polya-Gamma distribution.

A collection of common probability distributions for stochastic nodes in PyMC.

class pymc.distributions.continuous.AsymmetricLaplace(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Asymmetric-Laplace log-likelihood.

The pdf of this distribution is

\[\begin{split}{f(x|\\b,\kappa,\mu) = \left({\frac{\\b}{\kappa + 1/\kappa}}\right)\,e^{-(x-\mu)\\b\,s\kappa ^{s}}}\end{split}\]

where

\[s = sgn(x-\mu)\]

Support

\(x \in \mathbb{R}\)

Mean

\(\mu-\frac{\\\kappa-1/\kappa}b\)

Variance

\(\frac{1+\kappa^{4}}{b^2\kappa^2 }\)

Parameters
b: float

Scale parameter (b > 0)

kappa: float

Symmetry parameter (kappa > 0)

mu: float

Location parameter

See Also:
——–
`Reference <https://en.wikipedia.org/wiki/Asymmetric_Laplace_distribution>`_

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(b, kappa, mu=0, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(b, kappa, mu)[source]

Calculate log-probability of Asymmetric-Laplace distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Beta(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Beta log-likelihood.

The pdf of this distribution is

\[f(x \mid \alpha, \beta) = \frac{x^{\alpha - 1} (1 - x)^{\beta - 1}}{B(\alpha, \beta)}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-1.png

Support

\(x \in (0, 1)\)

Mean

\(\dfrac{\alpha}{\alpha + \beta}\)

Variance

\(\dfrac{\alpha \beta}{(\alpha+\beta)^2(\alpha+\beta+1)}\)

Beta distribution can be parameterized either in terms of alpha and beta or mean and standard deviation. The link between the two parametrizations is given by

\[ \begin{align}\begin{aligned}\begin{split}\alpha &= \mu \kappa \\ \beta &= (1 - \mu) \kappa\end{split}\\\text{where } \kappa = \frac{\mu(1-\mu)}{\sigma^2} - 1\end{aligned}\end{align} \]
Parameters
alpha: float

alpha > 0.

beta: float

beta > 0.

mu: float

Alternative mean (0 < mu < 1).

sigma: float

Alternative standard deviation (0 < sigma < sqrt(mu * (1 - mu))).

Notes

Beta distribution is a conjugate prior for the parameter \(p\) of the binomial distribution.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha, beta)[source]

Compute the log of the cumulative distribution function for Beta distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.Cauchy(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Cauchy log-likelihood.

Also known as the Lorentz or the Breit-Wigner distribution.

The pdf of this distribution is

\[f(x \mid \alpha, \beta) = \frac{1}{\pi \beta [1 + (\frac{x-\alpha}{\beta})^2]}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-2.png

Support

\(x \in \mathbb{R}\)

Mode

\(\alpha\)

Mean

undefined

Variance

undefined

Parameters
alpha: float

Location parameter

beta: float

Scale parameter > 0

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha, beta, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha, beta)[source]

Compute the log of the cumulative distribution function for Cauchy distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.ChiSquared(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

\(\chi^2\) log-likelihood.

The pdf of this distribution is

\[f(x \mid \nu) = \frac{x^{(\nu-2)/2}e^{-x/2}}{2^{\nu/2}\Gamma(\nu/2)}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-3.png

Support

\(x \in [0, \infty)\)

Mean

\(\nu\)

Variance

\(2 \nu\)

Parameters
nu: float

Degrees of freedom (nu > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(nu, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(nu)[source]

Compute the log of the cumulative distribution function for ChiSquared distribution at the specified value.

Parameters
value: numeric or np.ndarray or `TensorVariable`

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or TensorVariable.

Returns
——-
TensorVariable
class pymc.distributions.continuous.ExGaussian(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Exponentially modified Gaussian log-likelihood.

Results from the convolution of a normal distribution with an exponential distribution.

The pdf of this distribution is

\[f(x \mid \mu, \sigma, \tau) = \frac{1}{\nu}\; \exp\left\{\frac{\mu-x}{\nu}+\frac{\sigma^2}{2\nu^2}\right\} \Phi\left(\frac{x-\mu}{\sigma}-\frac{\sigma}{\nu}\right)\]

where \(\Phi\) is the cumulative distribution function of the standard normal distribution.

(Source code, png, hires.png, pdf)

../../_images/continuous-4.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu + \nu\)

Variance

\(\sigma^2 + \nu^2\)

Parameters
mu: float

Mean of the normal distribution.

sigma: float

Standard deviation of the normal distribution (sigma > 0).

nu: float

Mean of the exponential distribution (nu > 0).

References

Rigby2005

Rigby R.A. and Stasinopoulos D.M. (2005). “Generalized additive models for location, scale and shape” Applied Statististics., 54, part 3, pp 507-554.

Lacouture2008

Lacouture, Y. and Couseanou, D. (2008). “How to use MATLAB to fit the ex-Gaussian and other probability functions to a distribution of response times”. Tutorials in Quantitative Methods for Psychology, Vol. 4, No. 1, pp 35-45.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0.0, sigma=None, nu=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, sigma, nu)[source]

Compute the log of the cumulative distribution function for ExGaussian distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable

References

Rigby2005

R.A. Rigby (2005). “Generalized additive models for location, scale and shape” https://doi.org/10.1111/j.1467-9876.2005.00510.x

logp(mu, sigma, nu)[source]

Calculate log-probability of ExGaussian distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Exponential(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Exponential log-likelihood.

The pdf of this distribution is

\[f(x \mid \lambda) = \lambda \exp\left\{ -\lambda x \right\}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-5.png

Support

\(x \in [0, \infty)\)

Mean

\(\dfrac{1}{\lambda}\)

Variance

\(\dfrac{1}{\lambda^2}\)

Parameters
lam: float

Rate or inverse scale (lam > 0)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(lam, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu)[source]

Compute the log of cumulative distribution function for the Exponential distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.Flat(*args, **kwargs)[source]

Uninformative log-likelihood that returns 0 regardless of the passed value.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(*, size=None, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf()[source]

Compute the log of the cumulative distribution function for Flat distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
logp()[source]

Calculate log-probability of Flat distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Gamma(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Gamma log-likelihood.

Represents the sum of alpha exponentially distributed random variables, each of which has rate beta.

The pdf of this distribution is

\[f(x \mid \alpha, \beta) = \frac{\beta^{\alpha}x^{\alpha-1}e^{-\beta x}}{\Gamma(\alpha)}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-6.png

Support

\(x \in (0, \infty)\)

Mean

\(\dfrac{\alpha}{\beta}\)

Variance

\(\dfrac{\alpha}{\beta^2}\)

Gamma distribution can be parameterized either in terms of alpha and beta or mean and standard deviation. The link between the two parametrizations is given by

\[\begin{split}\alpha &= \frac{\mu^2}{\sigma^2} \\ \beta &= \frac{\mu}{\sigma^2}\end{split}\]
Parameters
alpha: float

Shape parameter (alpha > 0).

beta: float

Rate parameter (beta > 0).

mu: float

Alternative shape parameter (mu > 0).

sigma: float

Alternative scale parameter (sigma > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha=None, beta=None, mu=None, sigma=None, sd=None, no_assert=False, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha, inv_beta)[source]

Compute the log of the cumulative distribution function for Gamma distribution at the specified value.

Parameters
value: numeric or np.ndarray or `TensorVariable`

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or TensorVariable.

Returns
TensorVariable
class pymc.distributions.continuous.Gumbel(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Univariate Gumbel log-likelihood

The pdf of this distribution is

\[f(x \mid \mu, \beta) = \frac{1}{\beta}e^{-(z + e^{-z})}\]

where

\[z = \frac{x - \mu}{\beta}.\]

(Source code, png, hires.png, pdf)

../../_images/continuous-7.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu + \beta\gamma\), where \(\gamma\) is the Euler-Mascheroni constant

Variance

\(\frac{\pi^2}{6} \beta^2\)

Parameters
mu: float

Location parameter.

beta: float

Scale parameter (beta > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu: Optional[float] = None, beta: Optional[float] = None, no_assert: bool = False, **kwargs) aesara.tensor.random.op.RandomVariable[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], beta: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable]) aesara.tensor.var.TensorVariable[source]

Compute the log of the cumulative distribution function for Gumbel distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.HalfCauchy(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Half-Cauchy log-likelihood.

The pdf of this distribution is

\[f(x \mid \beta) = \frac{2}{\pi \beta [1 + (\frac{x}{\beta})^2]}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-8.png

Support

\(x \in [0, \infty)\)

Mode

0

Mean

undefined

Variance

undefined

Parameters
beta: float

Scale parameter (beta > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(beta, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(loc, beta)[source]

Compute the log of the cumulative distribution function for HalfCauchy distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.HalfFlat(*args, **kwargs)[source]

Improper flat prior over the positive reals.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(*, size=None, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf()[source]

Compute the log of the cumulative distribution function for HalfFlat distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
logp()[source]

Calculate log-probability of HalfFlat distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.HalfNormal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Half-normal log-likelihood.

The pdf of this distribution is

\[ \begin{align}\begin{aligned}f(x \mid \tau) = \sqrt{\frac{2\tau}{\pi}} \exp\left(\frac{-x^2 \tau}{2}\right)\\f(x \mid \sigma) = \sqrt{\frac{2}{\pi\sigma^2}} \exp\left(\frac{-x^2}{2\sigma^2}\right)\end{aligned}\end{align} \]

Note

The parameters sigma/tau (\(\sigma\)/\(\tau\)) refer to the standard deviation/precision of the unfolded normal distribution, for the standard deviation of the half-normal distribution, see below. For the half-normal, they are just two parameterisation \(\sigma^2 \equiv \frac{1}{\tau}\) of a scale parameter

(Source code, png, hires.png, pdf)

../../_images/continuous-9.png

Support

\(x \in [0, \infty)\)

Mean

\(\sqrt{\dfrac{2}{\tau \pi}}\) or \(\dfrac{\sigma \sqrt{2}}{\sqrt{\pi}}\)

Variance

\(\dfrac{1}{\tau}\left(1 - \dfrac{2}{\pi}\right)\) or \(\sigma^2\left(1 - \dfrac{2}{\pi}\right)\)

Parameters
sigma: float

Scale parameter \(sigma\) (sigma > 0) (only required if tau is not specified).

tau: float

Precision \(tau\) (tau > 0) (only required if sigma is not specified).

Examples

with pm.Model():
    x = pm.HalfNormal('x', sigma=10)

with pm.Model():
    x = pm.HalfNormal('x', tau=1/15)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(sigma=None, tau=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(loc, sigma)[source]

Compute the log of the cumulative distribution function for HalfNormal distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.HalfStudentT(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Half Student’s T log-likelihood

The pdf of this distribution is

\[f(x \mid \sigma,\nu) = \frac{2\;\Gamma\left(\frac{\nu+1}{2}\right)} {\Gamma\left(\frac{\nu}{2}\right)\sqrt{\nu\pi\sigma^2}} \left(1+\frac{1}{\nu}\frac{x^2}{\sigma^2}\right)^{-\frac{\nu+1}{2}}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-10.png

Support

\(x \in [0, \infty)\)

Parameters
nu: float

Degrees of freedom, also known as normality parameter (nu > 0).

sigma: float

Scale parameter (sigma > 0). Converges to the standard deviation as nu increases. (only required if lam is not specified)

lam: float

Scale parameter (lam > 0). Converges to the precision as nu increases. (only required if sigma is not specified)

Examples

# Only pass in one of lam or sigma, but not both.
with pm.Model():
    x = pm.HalfStudentT('x', sigma=10, nu=10)

with pm.Model():
    x = pm.HalfStudentT('x', lam=4, nu=10)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(nu=1, sigma=None, lam=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(nu, sigma)[source]

Calculate log-probability of HalfStudentT distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Interpolated(*args, **kwargs)[source]

Univariate probability distribution defined as a linear interpolation of probability density function evaluated on some lattice of points.

The lattice can be uneven, so the steps between different points can have different size and it is possible to vary the precision between regions of the support.

The probability density function values don not have to be normalized, as the interpolated density is any way normalized to make the total probability equal to $1$.

Both parameters x_points and values pdf_points are not variables, but plain array-like objects, so they are constant and cannot be sampled.

(Source code)

Support

\(x \in [x\_points[0], x\_points[-1]]\)

Parameters
x_points: array-like

A monotonically growing list of values. Must be non-symbolic

pdf_points: array-like

Probability density function evaluated on lattice x_points. Must be non-symbolic

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(x_points, pdf_points, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(x_points, pdf_points, cdf_points)[source]

Calculate log-probability of Interpolated distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.InverseGamma(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Inverse gamma log-likelihood, the reciprocal of the gamma distribution.

The pdf of this distribution is

\[f(x \mid \alpha, \beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{-\alpha - 1} \exp\left(\frac{-\beta}{x}\right)\]

(Source code, png, hires.png, pdf)

../../_images/continuous-12.png

Support

\(x \in (0, \infty)\)

Mean

\(\dfrac{\beta}{\alpha-1}\) for \(\alpha > 1\)

Variance

\(\dfrac{\beta^2}{(\alpha-1)^2(\alpha - 2)}\) for \(\alpha > 2\)

Parameters
alpha: float

Shape parameter (alpha > 0).

beta: float

Scale parameter (beta > 0).

mu: float

Alternative shape parameter (mu > 0).

sigma: float

Alternative scale parameter (sigma > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha, beta)[source]

Compute the log of the cumulative distribution function for Inverse Gamma distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.Kumaraswamy(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Kumaraswamy log-likelihood.

The pdf of this distribution is

\[f(x \mid a, b) = abx^{a-1}(1-x^a)^{b-1}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-13.png

Support

\(x \in (0, 1)\)

Mean

\(b B(1 + \tfrac{1}{a}, b)\)

Variance

\(b B(1 + \tfrac{2}{a}, b) - (b B(1 + \tfrac{1}{a}, b))^2\)

Parameters
a: float

a > 0.

b: float

b > 0.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(a, b, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(a, b)[source]

Compute the log of cumulative distribution function for the Kumaraswamy distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
logp(a, b)[source]

Calculate log-probability of Kumaraswamy distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Laplace(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Laplace log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, b) = \frac{1}{2b} \exp \left\{ - \frac{|x - \mu|}{b} \right\}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-14.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu\)

Variance

\(2 b^2\)

Parameters
mu: float

Location parameter.

b: float

Scale parameter (b > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu, b, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, b)[source]

Compute the log of the cumulative distribution function for Laplace distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.LogNormal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Note: Class name Lognormal is deprecated, use LogNormal now!

Log-normal log-likelihood.

Distribution of any random variable whose logarithm is normally distributed. A variable might be modeled as log-normal if it can be thought of as the multiplicative product of many small independent factors.

The pdf of this distribution is

\[f(x \mid \mu, \tau) = \frac{1}{x} \sqrt{\frac{\tau}{2\pi}} \exp\left\{ -\frac{\tau}{2} (\ln(x)-\mu)^2 \right\}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-15.png

Support

\(x \in [0, \infty)\)

Mean

\(\exp\{\mu + \frac{1}{2\tau}\}\)

Variance

\((\exp\{\frac{1}{\tau}\} - 1) \times \exp\{2\mu + \frac{1}{\tau}\}\)

Parameters
mu: float

Location parameter.

sigma: float

Standard deviation. (sigma > 0). (only required if tau is not specified).

tau: float

Scale parameter (tau > 0). (only required if sigma is not specified).

Examples

# Example to show that we pass in only ``sigma`` or ``tau`` but not both.
with pm.Model():
    x = pm.LogNormal('x', mu=2, sigma=30)

with pm.Model():
    x = pm.LogNormal('x', mu=2, tau=1/100)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0, sigma=None, tau=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, sigma)[source]

Compute the log of the cumulative distribution function for LogNormal distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.Logistic(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Logistic log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, s) = \frac{\exp\left(-\frac{x - \mu}{s}\right)}{s \left(1 + \exp\left(-\frac{x - \mu}{s}\right)\right)^2}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-16.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu\)

Variance

\(\frac{s^2 \pi^2}{3}\)

Parameters
mu: float

Mean.

s: float

Scale (s > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0.0, s=1.0, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, s)[source]

Compute the log of the cumulative distribution function for Logistic distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.LogitNormal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Logit-Normal log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, \tau) = \frac{1}{x(1-x)} \sqrt{\frac{\tau}{2\pi}} \exp\left\{ -\frac{\tau}{2} (logit(x)-\mu)^2 \right\}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-17.png

Support

\(x \in (0, 1)\)

Mean

no analytical solution

Variance

no analytical solution

Parameters
mu: float

Location parameter.

sigma: float

Scale parameter (sigma > 0).

tau: float

Scale parameter (tau > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0, sigma=None, tau=None, sd=None, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(mu, sigma)[source]

Calculate log-probability of LogitNormal distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Moyal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Moyal log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu,\sigma) = \frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{1}{2}\left(z + e^{-z}\right)},\]

where

\[z = \frac{x-\mu}{\sigma}.\]

(Source code, png, hires.png, pdf)

../../_images/continuous-18.png

Support

\(x \in (-\infty, \infty)\)

Mean

\(\mu + \sigma\left(\gamma + \log 2\right)\), where \(\gamma\) is the Euler-Mascheroni constant

Variance

\(\frac{\pi^{2}}{2}\sigma^{2}\)

Parameters
mu: float

Location parameter.

sigma: float

Scale parameter (sigma > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0, sigma=1.0, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, sigma)[source]

Compute the log of the cumulative distribution function for Moyal distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
logp(mu, sigma)[source]

Calculate log-probability of Moyal distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Normal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Univariate normal log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, \tau) = \sqrt{\frac{\tau}{2\pi}} \exp\left\{ -\frac{\tau}{2} (x-\mu)^2 \right\}\]

Normal distribution can be parameterized either in terms of precision or standard deviation. The link between the two parametrizations is given by

\[\tau = \dfrac{1}{\sigma^2}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-19.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu\)

Variance

\(\dfrac{1}{\tau}\) or \(\sigma^2\)

Parameters
mu: float

Mean.

sigma: float

Standard deviation (sigma > 0) (only required if tau is not specified).

tau: float

Precision (tau > 0) (only required if sigma is not specified).

Examples

with pm.Model():
    x = pm.Normal('x', mu=0, sigma=10)

with pm.Model():
    x = pm.Normal('x', mu=0, tau=1/23)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0, sigma=None, tau=None, sd=None, no_assert=False, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu, sigma)[source]

Compute the log of the cumulative distribution function for Normal distribution at the specified value.

Parameters
value: numeric or np.ndarray or `TensorVariable`

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or TensorVariable.

Returns
TensorVariable
class pymc.distributions.continuous.Pareto(*args, **kwargs)[source]

Pareto log-likelihood.

Often used to characterize wealth distribution, or other examples of the 80/20 rule.

The pdf of this distribution is

\[f(x \mid \alpha, m) = \frac{\alpha m^{\alpha}}{x^{\alpha+1}}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-20.png

Support

\(x \in [m, \infty)\)

Mean

\(\dfrac{\alpha m}{\alpha - 1}\) for \(\alpha \ge 1\)

Variance

\(\dfrac{m \alpha}{(\alpha - 1)^2 (\alpha - 2)}\) for \(\alpha > 2\)

Parameters
alpha: float

Shape parameter (alpha > 0).

m: float

Scale parameter (m > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha: Optional[float] = None, m: Optional[float] = None, no_assert: bool = False, **kwargs) aesara.tensor.random.op.RandomVariable[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], m: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable])[source]

Compute the log of the cumulative distribution function for Pareto distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.PolyaGamma(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

The Polya-Gamma distribution.

The distribution is parametrized by h (shape parameter) and z (exponential tilting parameter). The pdf of this distribution is

\[f(x \mid h, z) = cosh^h(\frac{z}{2})e^{-\frac{1}{2}xz^2}f(x \mid h, 0),\]

where \(f(x \mid h, 0)\) is the pdf of a \(PG(h, 0)\) variable. Notice that the pdf of this distribution is expressed as an alternating-sign sum of inverse-Gaussian densities.

\[X = \Sigma_{k=1}^{\infty}\frac{Ga(h, 1)}{d_k},\]

where \(d_k = 2(k - 0.5)^2\pi^2 + z^2/2\), \(Ga(h, 1)\) is a gamma random variable with shape parameter h and scale parameter 1.

(Source code)

Support

\(x \in (0, \infty)\)

Mean

\(dfrac{h}{4} if :math:\), \(\dfrac{tanh(z/2)h}{2z}\) otherwise.

Variance

\(0.041666688h\) if \(z=0\), \(\dfrac{h(sinh(z) - z)(1 - tanh^2(z/2))}{4z^3}\) otherwise.

Parameters
h: float, optional

The shape parameter of the distribution (h > 0).

z: float, optional

The exponential tilting parameter of the distribution.

References

1

Polson, Nicholas G., James G. Scott, and Jesse Windle. “Bayesian inference for logistic models using Pólya–Gamma latent variables.” Journal of the American statistical Association 108.504 (2013): 1339-1349.

2

Windle, Jesse, Nicholas G. Polson, and James G. Scott. “Sampling Polya-Gamma random variates: alternate and approximate techniques.” arXiv preprint arXiv:1405.0506 (2014)

3

Luc Devroye. “On exact simulation algorithms for some distributions related to Jacobi theta functions.” Statistics & Probability Letters, Volume 79, Issue 21, (2009): 2251-2259.

4

Windle, J. (2013). Forecasting high-dimensional, time-varying variance-covariance matrices with high-frequency data and sampling Pólya-Gamma random variates for posterior distributions derived from logistic likelihoods.(PhD thesis). Retrieved from http://hdl.handle.net/2152/21842

Examples

rng = np.random.default_rng()
with pm.Model():
    x = pm.PolyaGamma('x', h=1, z=5.5)
with pm.Model():
    x = pm.PolyaGamma('x', h=25, z=-2.3, rng=rng, size=(100, 5))

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(h=1.0, z=0.0, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(h, z)[source]

Compute the log of the cumulative distribution function for the Polya-Gamma distribution at the specified value.

Parameters
value: numeric or np.ndarray or `TensorVariable`

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array.

Returns
TensorVariable
logp(h, z)[source]

Calculate log-probability of Polya-Gamma distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array.

Returns
TensorVariable
class pymc.distributions.continuous.Rice(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Rice distribution.

\[f(x\mid \nu ,\sigma )= {\frac {x}{\sigma ^{2}}}\exp \left({\frac {-(x^{2}+\nu ^{2})}{2\sigma ^{2}}}\right)I_{0}\left({\frac {x\nu }{\sigma ^{2}}}\right),\]

(Source code, png, hires.png, pdf)

../../_images/continuous-22.png

Support

\(x \in (0, \infty)\)

Mean

\(\sigma {\sqrt {\pi /2}}\,\,L_{{1/2}}(-\nu ^{2}/2\sigma ^{2})\)

Variance

\(2\sigma ^{2}+\nu ^{2}-{\frac {\pi \sigma ^{2}}{2}}L_{{1/2}}^{2}\left({\frac {-\nu ^{2}}{2\sigma ^{2}}}\right)\)

Parameters
nu: float

noncentrality parameter.

sigma: float

scale parameter.

b: float

shape parameter (alternative to nu).

Notes

The distribution \(\mathrm{Rice}\left(|\nu|,\sigma\right)\) is the distribution of \(R=\sqrt{X^2+Y^2}\) where \(X\sim N(\nu \cos{\theta}, \sigma^2)\), \(Y\sim N(\nu \sin{\theta}, \sigma^2)\) are independent and for any real \(\theta\).

The distribution is defined with either nu or b. The link between the two parametrizations is given by

\[b = \dfrac{\nu}{\sigma}\]

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(nu=None, sigma=None, b=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(b, sigma)[source]

Calculate log-probability of Rice distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.SkewNormal(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Univariate skew-normal log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, \tau, \alpha) = 2 \Phi((x-\mu)\sqrt{\tau}\alpha) \phi(x,\mu,\tau)\]

(Source code, png, hires.png, pdf)

../../_images/continuous-23.png

Support

\(x \in \mathbb{R}\)

Mean

\(\mu + \sigma \sqrt{\frac{2}{\pi}} \frac {\alpha }{{\sqrt {1+\alpha ^{2}}}}\)

Variance

\(\sigma^2 \left( 1-\frac{2\alpha^2}{(\alpha^2+1) \pi} \right)\)

Skew-normal distribution can be parameterized either in terms of precision or standard deviation. The link between the two parametrizations is given by

\[\tau = \dfrac{1}{\sigma^2}\]
Parameters
mu: float

Location parameter.

sigma: float

Scale parameter (sigma > 0).

tau: float

Alternative scale parameter (tau > 0).

alpha: float

Skewness parameter.

Notes

When alpha=0 we recover the Normal distribution and mu becomes the mean, tau the precision and sigma the standard deviation. In the limit of alpha approaching plus/minus infinite we get a half-normal distribution.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha=1, mu=0.0, sigma=None, tau=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(mu, sigma, alpha)[source]

Calculate log-probability of SkewNormal distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.StudentT(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Student’s T log-likelihood.

Describes a normal variable whose precision is gamma distributed. If only nu parameter is passed, this specifies a standard (central) Student’s T.

The pdf of this distribution is

\[f(x|\mu,\lambda,\nu) = \frac{\Gamma(\frac{\nu + 1}{2})}{\Gamma(\frac{\nu}{2})} \left(\frac{\lambda}{\pi\nu}\right)^{\frac{1}{2}} \left[1+\frac{\lambda(x-\mu)^2}{\nu}\right]^{-\frac{\nu+1}{2}}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-24.png

Support

\(x \in \mathbb{R}\)

Parameters
nu: float

Degrees of freedom, also known as normality parameter (nu > 0).

mu: float

Location parameter.

sigma: float

Scale parameter (sigma > 0). Converges to the standard deviation as nu increases. (only required if lam is not specified)

lam: float

Scale parameter (lam > 0). Converges to the precision as nu increases. (only required if sigma is not specified)

Examples

with pm.Model():
    x = pm.StudentT('x', nu=15, mu=0, sigma=10)

with pm.Model():
    x = pm.StudentT('x', nu=15, mu=0, lam=1/23)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(nu, mu=0, lam=None, sigma=None, sd=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(nu, mu, sigma)[source]

Compute the log of the cumulative distribution function for Student’s T distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
logp(nu, mu, sigma)[source]

Calculate log-probability of StudentT distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Triangular(*args, **kwargs)[source]

Continuous Triangular log-likelihood

The pdf of this distribution is

\[\begin{split}\begin{cases} 0 & \text{for } x < a, \\ \frac{2(x-a)}{(b-a)(c-a)} & \text{for } a \le x < c, \\[4pt] \frac{2}{b-a} & \text{for } x = c, \\[4pt] \frac{2(b-x)}{(b-a)(b-c)} & \text{for } c < x \le b, \\[4pt] 0 & \text{for } b < x. \end{cases}\end{split}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-25.png

Support

\(x \in [lower, upper]\)

Mean

\(\dfrac{lower + upper + c}{3}\)

Variance

\(\dfrac{upper^2 + lower^2 +c^2 - lower*upper - lower*c - upper*c}{18}\)

Parameters
lower: float

Lower limit.

c: float

mode

upper: float

Upper limit.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(lower=0, upper=1, c=0.5, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(lower, c, upper)[source]

Compute the log of the cumulative distribution function for Triangular distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable
class pymc.distributions.continuous.TruncatedNormal(*args, **kwargs)[source]

Univariate truncated normal log-likelihood.

The pdf of this distribution is

\[f(x;\mu ,\sigma ,a,b)={\frac {\phi ({\frac {x-\mu }{\sigma }})}{ \sigma \left(\Phi ({\frac {b-\mu }{\sigma }})-\Phi ({\frac {a-\mu }{\sigma }})\right)}}\]

Truncated normal distribution can be parameterized either in terms of precision or standard deviation. The link between the two parametrizations is given by

\[\tau = \dfrac{1}{\sigma^2}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-26.png

Support

\(x \in [a, b]\)

Mean

\(\mu +{\frac {\phi (\alpha )-\phi (\beta )}{Z}}\sigma\)

Variance

\(\sigma ^{2}\left[1+{\frac {\alpha \phi (\alpha )-\beta \phi (\beta )}{Z}}-\left({\frac {\phi (\alpha )-\phi (\beta )}{Z}}\right)^{2}\right]\)

Parameters
mu: float

Mean.

sigma: float

Standard deviation (sigma > 0).

lower: float (optional)

Left bound.

upper: float (optional)

Right bound.

Examples

with pm.Model():
    x = pm.TruncatedNormal('x', mu=0, sigma=10, lower=0)

with pm.Model():
    x = pm.TruncatedNormal('x', mu=0, sigma=10, upper=1)

with pm.Model():
    x = pm.TruncatedNormal('x', mu=0, sigma=10, lower=0, upper=1)

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu: Optional[Union[float, numpy.ndarray]] = None, sigma: Optional[Union[float, numpy.ndarray]] = None, tau: Optional[Union[float, numpy.ndarray]] = None, sd: Optional[Union[float, numpy.ndarray]] = None, lower: Optional[Union[float, numpy.ndarray]] = None, upper: Optional[Union[float, numpy.ndarray]] = None, transform: str = 'auto', *args, **kwargs) aesara.tensor.random.op.RandomVariable[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logp(mu: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], sigma: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], lower: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], upper: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable]) aesara.tensor.random.op.RandomVariable[source]

Calculate log-probability of TruncatedNormal distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

Returns
TensorVariable
class pymc.distributions.continuous.Uniform(*args, **kwargs)[source]

Continuous uniform log-likelihood.

The pdf of this distribution is

\[f(x \mid lower, upper) = \frac{1}{upper-lower}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-27.png

Support

\(x \in [lower, upper]\)

Mean

\(\dfrac{lower + upper}{2}\)

Variance

\(\dfrac{(upper - lower)^2}{12}\)

Parameters
lower: float

Lower limit.

upper: float

Upper limit.

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(lower=0, upper=1, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(lower, upper)[source]

Compute the log of the cumulative distribution function for Uniform distribution at the specified value.

Parameters
value: numeric or np.ndarray or `TensorVariable`

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or TensorVariable.

Returns
TensorVariable
class pymc.distributions.continuous.VonMises(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Univariate VonMises log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, \kappa) = \frac{e^{\kappa\cos(x-\mu)}}{2\pi I_0(\kappa)}\]

where \(I_0\) is the modified Bessel function of order 0.

(Source code, png, hires.png, pdf)

../../_images/continuous-28.png

Support

\(x \in [-\pi, \pi]\)

Mean

\(\mu\)

Variance

\(1-\frac{I_1(\kappa)}{I_0(\kappa)}\)

Parameters
mu: float

Mean.

kappa: float

Concentration (frac{1}{kappa} is analogous to sigma^2).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu=0.0, kappa=None, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

class pymc.distributions.continuous.Wald(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Wald log-likelihood.

The pdf of this distribution is

\[f(x \mid \mu, \lambda) = \left(\frac{\lambda}{2\pi}\right)^{1/2} x^{-3/2} \exp\left\{ -\frac{\lambda}{2x}\left(\frac{x-\mu}{\mu}\right)^2 \right\}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-29.png

Support

\(x \in (0, \infty)\)

Mean

\(\mu\)

Variance

\(\dfrac{\mu^3}{\lambda}\)

Wald distribution can be parameterized either in terms of lam or phi. The link between the two parametrizations is given by

\[\phi = \dfrac{\lambda}{\mu}\]
Parameters
mu: float, optional

Mean of the distribution (mu > 0).

lam: float, optional

Relative precision (lam > 0).

phi: float, optional

Alternative shape parameter (phi > 0).

alpha: float, optional

Shift/location parameter (alpha >= 0).

Notes

To instantiate the distribution specify any of the following

  • only mu (in this case lam will be 1)

  • mu and lam

  • mu and phi

  • lam and phi

References

Tweedie1957

Tweedie, M. C. K. (1957). Statistical Properties of Inverse Gaussian Distributions I. The Annals of Mathematical Statistics, Vol. 28, No. 2, pp. 362-377

Michael1976

Michael, J. R., Schucany, W. R. and Hass, R. W. (1976). Generating Random Variates Using Transformations with Multiple Roots. The American Statistician, Vol. 30, No. 2, pp. 88-90

Giner2016

Göknur Giner, Gordon K. Smyth (2016) statmod: Probability Calculations for the Inverse Gaussian Distribution

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(mu: Optional[Union[float, numpy.ndarray]] = None, lam: Optional[Union[float, numpy.ndarray]] = None, phi: Optional[Union[float, numpy.ndarray]] = None, alpha: Union[float, numpy.ndarray] = 0.0, *args, **kwargs) aesara.tensor.random.op.RandomVariable[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(mu: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], lam: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], alpha: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable]) aesara.tensor.random.op.RandomVariable[source]

Compute the log of the cumulative distribution function for Wald distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

mu: float or TensorVariable

Mean of the distribution (mu > 0).

lam: float or TensorVariable

Relative precision (lam > 0).

alpha: float or TensorVariable

Shift/location parameter (alpha >= 0).

Returns
TensorVariable
logp(mu: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], lam: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable], alpha: Union[float, numpy.ndarray, aesara.tensor.var.TensorVariable]) aesara.tensor.random.op.RandomVariable[source]

Calculate log-probability of Wald distribution at specified value.

Parameters
value: numeric

Value(s) for which log-probability is calculated. If the log probabilities for multiple values are desired the values must be provided in a numpy array or Aesara tensor

mu: float or TensorVariable

Mean of the distribution (mu > 0).

lam: float or TensorVariable

Relative precision (lam > 0).

alpha: float or TensorVariable

Shift/location parameter (alpha >= 0).

Returns
TensorVariable
class pymc.distributions.continuous.Weibull(name: str, *args, rng=None, dims: Optional[Union[str, Sequence[Union[str, None, ellipsis]]]] = None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]

Weibull log-likelihood.

The pdf of this distribution is

\[f(x \mid \alpha, \beta) = \frac{\alpha x^{\alpha - 1} \exp(-(\frac{x}{\beta})^{\alpha})}{\beta^\alpha}\]

(Source code, png, hires.png, pdf)

../../_images/continuous-30.png

Support

\(x \in [0, \infty)\)

Mean

\(\beta \Gamma(1 + \frac{1}{\alpha})\)

Variance

\(\beta^2 \Gamma(1 + \frac{2}{\alpha} - \mu^2/\beta^2)\)

Parameters
alpha: float

Shape parameter (alpha > 0).

beta: float

Scale parameter (beta > 0).

Adds a RandomVariable corresponding to a PyMC distribution to the current model.

Note that all remaining kwargs must be compatible with .dist()

Parameters
clstype

A PyMC distribution.

namestr

Name for the new model variable.

rngoptional

Random number generator to use with the RandomVariable.

dimstuple, optional

A tuple of dimension names known to the model.

initvaloptional

Numeric or symbolic untransformed initial value of matching shape, or one of the following initial value strategies: “moment”, “prior”. Depending on the sampler’s settings, a random jitter may be added to numeric, symbolic or moment-based initial values in the transformed space.

observedoptional

Observed data to be passed when registering the random variable in the model. See Model.register_rv.

total_sizefloat, optional

See Model.register_rv.

transformoptional

See Model.register_rv.

**kwargs

Keyword arguments that will be forwarded to .dist(). Most prominently: shape and size

Returns
rvRandomVariable

The created RV, registered in the Model.

classmethod dist(alpha, beta, *args, **kwargs)[source]

Creates a RandomVariable corresponding to the cls distribution.

Parameters
dist_paramsarray-like

The inputs to the RandomVariable Op.

shapeint, tuple, Variable, optional

A tuple of sizes for each dimension of the new RV.

An Ellipsis (…) may be inserted in the last position to short-hand refer to all the dimensions that the RV would get if no shape/size/dims were passed at all.

sizeint, tuple, Variable, optional

For creating the RV like in Aesara/NumPy.

Returns
rvRandomVariable

The created RV.

logcdf(alpha, beta)[source]

Compute the log of the cumulative distribution function for Weibull distribution at the specified value.

Parameters
value: numeric or np.ndarray or aesara.tensor

Value(s) for which log CDF is calculated. If the log CDF for multiple values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
TensorVariable