basic – Low-level random numbers

The aesara.tensor.random module provides random-number drawing functionality that closely resembles the numpy.random module.

Reference

class aesara.tensor.random.RandomStream[source]

A helper class that tracks changes in a shared numpy.random.RandomState and behaves like numpy.random.RandomState by managing access to RandomVariables. For example:

from aesara.tensor.random.utils import RandomStream

rng = RandomStream()
sample = rng.normal(0, 1, size=(2, 2))
class aesara.tensor.random.RandomStateType(Type)[source]

A Type for variables that will take numpy.random.RandomState values.

aesara.tensor.random.random_state_type(name=None)[source]

Return a new Variable whose Variable.type is an instance of RandomStateType.

class aesara.tensor.random.RandomVariable(Op)[source]

Op that draws random numbers from a numpy.random.RandomState object. This Op is parameterized to draw numbers from many possible distributions.

Distributions

Aesara can produce RandomVariables that draw samples from many different statistical distributions, using the following Ops. The RandomVariables behave similarly to NumPy’s Generalized Universal Functions (or gunfunc): it supports “core” random variable Ops that map distinctly shaped inputs to potentially non-scalar outputs. We document this behavior in the following with gufunc-like signatures.

class aesara.tensor.random.basic.UniformRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A uniform continuous random variable.

The probability density function for uniform within the interval [l, h) is:

\begin{split}
    f(x; l, h) = \begin{cases}
                  \frac{1}{h-l}\quad \text{for $l \leq x \leq h$},\\
                   0\quad \text{otherwise}.
               \end{cases}
\end{split}

__call__(low=0.0, high=1.0, size=None, **kwargs)[source]

Draw samples from a uniform distribution.

The results are undefined when high < low.

Signature

(), () -> ()

param low:Lower boundary l of the output interval; all values generated will be greater than or equal to low.
param high:Upper boundary h of the output interval; all values generated will be less than or equal to high.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.RandIntRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A discrete uniform random variable.

Only available for RandomStateType. Use integers with RandomGeneratorTypes.

__call__(low, high=None, size=None, **kwargs)[source]

Draw samples from a discrete uniform distribution.

Signature

() -> ()

param low:Lower boundary of the output interval. All values generated will be greater than or equal to low, unless high=None, in which case all values generated are greater than or equal to 0 and smaller than low (exclusive).
param high:Upper boundary of the output interval. All values generated will be smaller than high (exclusive).
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.IntegersRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A discrete uniform random variable.

Only available for RandomGeneratorType. Use randint with RandomStateTypes.

__call__(low, high=None, size=None, **kwargs)[source]

Draw samples from a discrete uniform distribution.

Signature

() -> ()

param low:Lower boundary of the output interval. All values generated will be greater than or equal to low (inclusive).
param high:Upper boundary of the output interval. All values generated will be smaller than high (exclusive).
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.ChoiceRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

Randomly choose an element in a sequence.

__call__(a, size=None, replace=True, p=None, **kwargs)[source]

Generate a random sample from an array.

Signature

(x) -> ()

param a:The array from which to randomly sample an element. If an int, a sample is generated from aesara.tensor.arange(a).
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent samples are returned. Default is None, in which case a single sample is returned.
param replace:When True, sampling is performed with replacement.
param p:The probabilities associated with each entry in a. If not given, all elements have equal probability.
class aesara.tensor.random.basic.PermutationRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

Randomly shuffle a sequence.

__call__(x, **kwargs)[source]

Randomly permute a sequence or a range of values.

Signature

(x) -> (x)

param x:If x is an integer, randomly permute np.arange(x). If x is a sequence, shuffle its elements randomly.
class aesara.tensor.random.basic.BernoulliRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Bernoulli discrete random variable.

The probability mass function for bernoulli in terms of the probability of success p of a single trial is:

\begin{split}
    f(k; p) = \begin{cases}
                        (1-p)\quad \text{if $k = 0$},\\
                        p\quad \text{if $k=1$}\\
                \end{cases}
\end{split}

where 0 \leq p \leq 1.

__call__(p, size=None, **kwargs)[source]

Draw samples from a Bernoulli distribution.

Signature

() -> ()

param p:Probability of success p of a single trial.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.BetaRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A beta continuous random variable.

The probability density function for beta in terms of its parameters \alpha and \beta is:

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

for 0 \leq x \leq 1. B is the beta function defined as:

B(\alpha, \beta) = \int_0^1 t^{\alpha-1} (1-t)^{\beta-1} \mathrm{d}t

__call__(alpha, beta, size=None, **kwargs)[source]

Draw samples from a beta distribution.

Signature

(), () -> ()

param alpha:Alpha parameter \alpha of the distribution. Must be positive.
param beta:Beta parameter \beta of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.BetaBinomialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A beta-binomial discrete random variable.

The probability mass function for betabinom in terms of its shape parameters n \geq 0, a > 0, b > 0 and the probability p is:

f(k; p, n, a, b) = {n \choose k} \frac{\operatorname{B}(k+a, n-k+b)}{\operatorname{B}(a,b)}

where \operatorname{B} is the beta function:

\operatorname{B}(a, b) = \int_0^1 t^{a-1} (1-t)^{b-1} \mathrm{d}t

__call__(n, a, b, size=None, **kwargs)[source]

Draw samples from a beta-binomial distribution.

Signature

(), (), () -> ()

param n:Shape parameter n. Must be a positive integer.
param a:Shape parameter a. Must be positive.
param b:Shape parameter b. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.BinomialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A binomial discrete random variable.

The probability mass function for binomial for the number k of successes in terms of the probability of success p of a single trial and the number n of trials is:

f(k; p, n) = {n \choose k} p^k (1-p)^{n-k}

__call__(n, p, size=None, **kwargs)[source]

Draw samples from a binomial distribution.

Signature

(), () -> ()

param n:Number of trials n. Must be a positive integer.
param p:Probability of success p of a single trial.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.CauchyRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Cauchy continuous random variable.

The probability density function for cauchy in terms of its location parameter x_0 and scale parameter \gamma is:

f(x; x_0, \gamma) = \frac{1}{\pi \gamma \left(1 + (\frac{x-x_0}{\gamma})^2\right)}

where \gamma > 0.

__call__(loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a Cauchy distribution.

Signature

(), () -> ()

param loc:Location parameter x_0 of the distribution.
param scale:Scale parameter \gamma of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.CategoricalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A categorical discrete random variable.

The probability mass function of categorical in terms of its N event probabilities p_1, \dots, p_N is:

P(k=i) = p_k

where \sum_i p_i = 1.

__call__(p, size=None, **kwargs)[source]

Draw samples from a discrete categorical distribution.

Signature

(j) -> ()

param p:An array that contains the N event probabilities.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed random samples are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.ChiSquareRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A chi square continuous random variable.

The probability density function for chisquare in terms of the number of degrees of freedom k is:

f(x; k) = \frac{(1/2)^{k/2}}{\Gamma(k/2)} x^{k/2-1} e^{-x/2}

for k > 2. \Gamma is the gamma function:

\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t

This variable is obtained by summing the squares k independent, standard normally distributed random variables.

__call__(df, size=None, **kwargs)[source]

Draw samples from a chisquare distribution.

Signature

() -> ()

param df:The number k of degrees of freedom. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.DirichletRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Dirichlet continuous random variable.

The probability density function for dirichlet in terms of the vector of concentration parameters \boldsymbol{\alpha} is:

f(x; \boldsymbol{\alpha}) = \prod_{i=1}^k x_i^{\alpha_i-1}

where x is a vector, such that x_i > 0\;\forall i and \sum_{i=1}^k x_i = 1.

__call__(alphas, size=None, **kwargs)[source]

Draw samples from a dirichlet distribution.

Signature

(k) -> (k)

param alphas:A sequence of concentration parameters \boldsymbol{\alpha} of the distribution. A sequence of length k will produce samples of length k.
param size:Given a size of, for example, (r, s, t), r * s * t independent, identically distributed samples are generated. Because each sample is k-dimensional, the output shape is (r, s, t, k). If no shape is specified, a single k-dimensional sample is returned.
class aesara.tensor.random.basic.ExponentialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

An exponential continuous random variable.

The probability density function for exponential in terms of its scale parameter \beta is:

f(x; \beta) = \frac{\exp(-x / \beta)}{\beta}

for x \geq 0 and \beta > 0.

__call__(scale=1.0, size=None, **kwargs)[source]

Draw samples from an exponential distribution.

Signature

() -> ()

param scale:The scale \beta of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.GammaRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A gamma continuous random variable.

The probability density function for gamma in terms of the shape parameter \alpha and rate parameter \beta is:

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

for x \geq 0, \alpha > 0 and \beta > 0. \Gamma is the gamma function:

\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t

__call__(shape, rate, size=None, **kwargs)[source]

Draw samples from a gamma distribution.

Signature

(), () -> ()

param shape:The shape \alpha of the gamma distribution. Must be positive.
param rate:The rate \beta of the gamma distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.GenGammaRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A generalized gamma continuous random variable.

The probability density function of gengamma in terms of its scale parameter \alpha and other parameters p and \lambda is:

f(x; \alpha, \lambda, p) = \frac{p/\lambda^\alpha}{\Gamma(\alpha/p)} x^{\alpha-1} e^{-(x/\lambda)^p}

for x > 0, where \alpha, \lambda, p > 0.

__call__(alpha=1.0, p=1.0, lambd=1.0, size=None, **kwargs)[source]

Draw samples from a generalized gamma distribution.

Signature

(), (), () -> ()

param alpha:Parameter \alpha. Must be positive.
param p:Parameter p. Must be positive.
param lambd:Scale parameter \lambda. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.GeometricRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A geometric discrete random variable.

The probability mass function for geometric for the number of successes k before the first failure in terms of the probability of success p of a single trial is:

f(k; p) = p^{k-1}(1-p)

for 0 \geq p \geq 1.

__call__(p, size=None, **kwargs)[source]

Draw samples from a geometric distribution.

Signature

() -> ()

param p:Probability of success p of an individual trial.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.GumbelRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A gumbel continuous random variable.

The probability density function for gumbel in terms of its location parameter \mu and scale parameter \beta is:

f(x; \mu, \beta) = \frac{\exp(-(x + e^{(x-\mu)/\beta})}{\beta}

for \beta > 0.

__call__(loc: Union[ndarray, float], scale: Union[ndarray, float] = 1.0, size: Optional[Union[List[int], int]] = None, **kwargs) RandomVariable[source]

Draw samples from a gumbel distribution.

Signature

(), () -> ()

param loc:The location parameter \mu of the distribution.
param scale:The scale \beta of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.HalfCauchyRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A half-Cauchy continuous random variable.

The probability density function for halfcauchy in terms of its location parameter x_0 and scale parameter \gamma is:

f(x; x_0, \gamma) = \frac{1}{\pi \gamma \left(1 + (\frac{x-x_0}{\gamma})^2\right)}

for x \geq 0 where \gamma > 0.

__call__(loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a half-Cauchy distribution.

Signature

(), () -> ()

param loc:Location parameter x_0 of the distribution.
param scale:Scale parameter \gamma of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.HalfNormalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A half-normal continuous random variable.

The probability density function for halfnormal in terms of its location parameter \mu and scale parameter \sigma is:

f(x; \mu, \sigma) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}

for x \geq 0 and \sigma > 0.

__call__(loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a half-normal distribution.

Signature

(), () -> ()

param loc:Location parameter \mu of the distribution.
param scale:Scale parameter \sigma of the distribution.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.HyperGeometricRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A hypergeometric discrete random variable.

The probability mass function for hypergeometric for the number of successes k in n draws without replacement, from a finite population of size N with K desired items is:

f(k; n, N, K) = \frac{{K \choose k} {N-K \choose n-k}}{{N \choose n}}

__call__(ngood, nbad, nsample, size=None, **kwargs)[source]

Draw samples from a geometric distribution.

Signature

(), (), () -> ()

param ngood:Number K of desirable items in the population. Positive integer.
param nbad:Number N-K of undesirable items in the population. Positive integer.
param nsample:Number n of items sampled. Must be less than N, i.e. ngood + nbad.` Positive integer.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.InvGammaRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

An inverse-gamma continuous random variable.

The probability density function for invgamma in terms of its shape parameter \alpha and scale parameter \beta is:

f(x; \alpha, \beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{-(\alpha+1)} \exp\left(-\frac{\beta}{x}\right)

for x > 0, where \alpha > 0 and \beta > 0. Gamma is the gamma function :

\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t

__call__(shape, scale, size=None, **kwargs)[source]

Draw samples from an inverse-gamma distribution.

Signature

(), () -> ()

param shape:Shape parameter \alpha of the distribution. Must be positive.
param scale:Scale parameter \beta of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed sample are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.LaplaceRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Laplace continuous random variable.

The probability density function for laplace in terms of its location parameter \mu and scale parameter \lambda is:

f(x; \mu, \lambda) = \frac{1}{2 \lambda} \exp\left(-\frac{|x-\mu|}{\lambda}\right)

with \lambda > 0.

__call__(loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a Laplace distribution.

Signature

(), () -> ()

param loc:Location parameter \mu of the distribution.
param scale:Scale parameter \lambda of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.LogisticRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A logistic continuous random variable.

The probability density function for logistic in terms of its location parameter \mu and scale parameter s is :

f(x; \mu, s) = \frac{e^{-(x-\mu)/s}}{s(1+e^{-(x-\mu)/s})^2}

for s > 0.

__call__(loc=0, scale=1, size=None, **kwargs)[source]

Draw samples from a logistic distribution.

Signature

(), () -> ()

param loc:The location parameter \mu of the distribution.
param scale:The scale s of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.LogNormalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A lognormal continuous random variable.

The probability density function for lognormal in terms of the mean parameter \mu and sigma parameter \sigma is:

f(x; \mu, \sigma) = \frac{1}{x \sqrt{2 \pi \sigma^2}} e^{-\frac{(\ln(x)-\mu)^2}{2\sigma^2}}

for x > 0 and \sigma > 0.

__call__(mean=0.0, sigma=1.0, size=None, **kwargs)[source]

Draw sample from a lognormal distribution.

Signature

(), () -> ()

param mean:Mean \mu of the random variable’s natural logarithm.
param sigma:Standard deviation \sigma of the random variable’s natural logarithm.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.MultinomialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A multinomial discrete random variable.

The probability mass function of multinomial in terms of the number of experiments n and the probabilities p_1, \dots, p_k of the k different possible outcomes is:

f(x_1,\dots,x_k; n, p_1, \dots, p_k) = \frac{n!}{x_1! \dots x_k!} \prod_{i=1}^k x_i^{p_i}

where n>0 and \sum_{i=1}^k p_i = 1.

Notes

The length of the support dimension is determined by the last dimension in the second parameter (i.e. the probabilities vector).

__call__(n, p, size=None, **kwargs)[source]

Draw samples from a discrete multinomial distribution.

Signature

(), (n) -> (n)

param n:Number of experiments n. Must be a positive integer.
param p:Probabilities of each of the k different outcomes.
param size:Given a size of, for example, (r, s, t), r * s * t independent, identically distributed samples are generated. Because each sample is k-dimensional, the output shape is (r, s, t, k). If no shape is specified, a single k-dimensional sample is returned.
class aesara.tensor.random.basic.MvNormalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A multivariate normal random variable.

The probability density function for multivariate_normal in term of its location parameter \boldsymbol{\mu} and covariance matrix \Sigma is

f(\boldsymbol{x}; \boldsymbol{\mu}, \Sigma) = \det(2 \pi \Sigma)^{-1/2}  \exp\left(-\frac{1}{2} (\boldsymbol{x} - \boldsymbol{\mu})^T \Sigma (\boldsymbol{x} - \boldsymbol{\mu})\right)

where \Sigma is a positive semi-definite matrix.

__call__(mean=None, cov=None, size=None, **kwargs)[source]

“Draw samples from a multivariate normal distribution.

Signature

(n), (n,n) -> (n)

param mean:Location parameter (mean) \boldsymbol{\mu} of the distribution. Vector of length N.
param cov:Covariance matrix \Sigma of the distribution. Must be a symmetric and positive-semidefinite NxN matrix.
param size:Given a size of, for example, (m, n, k), m * n * k independent, identically distributed samples are generated. Because each sample is N-dimensional, the output shape is (m, n, k, N). If no shape is specified, a single N-dimensional sample is returned.
class aesara.tensor.random.basic.NegBinomialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A negative binomial discrete random variable.

The probability mass function for nbinom for the number k of draws before observing the nth success in terms of the probability of success p of a single trial is:

f(k; p, n) = {k+n-1 \choose n-1} p^n (1-p)^{k}

__call__(n, p, size=None, **kwargs)[source]

Draw samples from a negative binomial distribution.

Signature

(), () -> ()

param n:Number of successes n. Must be a positive integer.
param p:Probability of success p of a single trial.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.NormalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A normal continuous random variable.

The probability density function for normal in terms of its location parameter (mean) \mu and scale parameter (standard deviation) \sigma is:

f(x; \mu, \sigma) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}

for \sigma > 0.

__call__(loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a normal distribution.

Signature

(), () -> ()

param loc:Mean \mu of the normal distribution.
param scale:Standard deviation \sigma of the normal distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.ParetoRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A pareto continuous random variable.

The probability density function for pareto in terms of its shape parameter b and scale parameter x_m is:

f(x; b, x_m) = \frac{b x_m^b}{x^{b+1}}

and is defined for x \geq x_m.

__call__(b, scale=1.0, size=None, **kwargs)[source]

Draw samples from a pareto distribution.

Signature

(), () -> ()

param b:The shape b (or exponent) of the pareto distribution. Must be positive.
param scale:The scale x_m of the pareto distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.PoissonRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A poisson discrete random variable.

The probability mass function for poisson in terms of the expected number of events \lambda is:

f(k; \lambda) = \frac{\lambda^k e^{-\lambda}}{k!}

for \lambda > 0.

__call__(lam=1.0, size=None, **kwargs)[source]

Draw samples from a poisson distribution.

Signature

() -> ()

param lam:Expected number of events \lambda. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.StandardNormalRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A standard normal continuous random variable.

The probability density function for standard_normal is:

f(x) = \frac{1}{\sqrt{2 \pi}} e^{-\frac{x^2}{2}}

__call__(size=None, **kwargs)[source]

Draw samples from a standard normal distribution.

Signature

nil -> ()

param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.StudentTRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Student’s t continuous random variable.

The probability density function for t in terms of its degrees of freedom parameter \nu, location parameter \mu and scale parameter \sigma is:

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

for \nu > 0, \sigma > 0.

__call__(df, loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a Student’s t distribution.

Signature

(), (), () -> ()

param df:Degrees of freedom parameter \nu of the distribution. Must be positive.
param loc:Location parameter \mu of the distribution.
param scale:Scale parameter \sigma of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.TriangularRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A triangular continuous random variable.

The probability density function for triangular within the interval [l, r) and mode m (where the peak of the distribution occurs) is:

\begin{split}
    f(x; l, m, r) = \begin{cases}
                        \frac{2(x-l)}{(r-l)(m-l)}\quad \text{for $l \leq x \leq m$},\\
                        \frac{2(r-x)}{(r-l)(r-m)}\quad \text{for $m \leq x \leq r$},\\
                        0\quad \text{otherwise}.
                    \end{cases}
\end{split}

__call__(left, mode, right, size=None, **kwargs)[source]

Draw samples from a triangular distribution.

Signature

(), (), () -> ()

param left:Lower boundary l of the output interval; all values generated will be greater than or equal to left.
param mode:Mode m of the distribution, where the peak occurs. Must be such that left <= mode <= right.
param right:Upper boundary r of the output interval; all values generated will be less than or equal to right. Must be larger than left.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.TruncExponentialRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A truncated exponential continuous random variable.

The probability density function for truncexp in terms of its shape parameter b, location parameter \alpha and scale parameter \beta is:

f(x; b, \alpha, \beta) = \frac{\exp(-(x-\alpha)/\beta)}{\beta (1-\exp(-b))}

for 0 \leq x \leq b and \beta > 0.

__call__(b, loc=0.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a truncated exponential distribution.

Signature

(), (), () -> ()

param b:Shape parameter b of the distribution. Must be positive.
param loc:Location parameter \alpha of the distribution.
param scale:Scale parameter \beta of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None in which case a single sample is returned.
class aesara.tensor.random.basic.VonMisesRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A von Misses continuous random variable.

The probability density function for vonmisses in terms of its mode \mu and dispersion parameter \kappa is :

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

for x \in [-\pi, \pi] and \kappa > 0. I_0 is the modified Bessel function of order 0.

__call__(mu, kappa, size=None, **kwargs)[source]

Draw samples from a von Mises distribution.

Signature

(), () -> ()

param mu:The mode \mu of the distribution.
param kappa:The dispersion parameter \kappa of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.
class aesara.tensor.random.basic.WaldRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A Wald (or inverse Gaussian) continuous random variable.

The probability density function for wald in terms of its mean parameter \mu and shape parameter \lambda is:

f(x; \mu, \lambda) = \sqrt{\frac{\lambda}{2 \pi x^3}} \exp\left(-\frac{\lambda (x-\mu)^2}{2 \mu^2 x}\right)

for x > 0, where \mu > 0 and \lambda > 0.

__call__(mean=1.0, scale=1.0, size=None, **kwargs)[source]

Draw samples from a Wald distribution.

Signature

(), () -> ()

param mean:Mean parameter \mu of the distribution. Must be positive.
param shape:Shape parameter \lambda of the distribution. Must be positive.
param size:Sample shape. If the given size is (m, n, k), then m * n * k independent, identically distributed samples are returned. Default is None, in which case a single sample is returned.
class aesara.tensor.random.basic.WeibullRV(name=None, ndim_supp=None, ndims_params=None, dtype=None, inplace=None)[source]

A weibull continuous random variable.

The probability density function for weibull in terms of its shape parameter k is :

f(x; k) = k x^{k-1} e^{-x^k}

for x \geq 0 and k > 0.

__call__(shape, size=None, **kwargs)[source]

Draw samples from a weibull distribution.

Signature

() -> ()

param shape:The shape k of the distribution. Must be positive.
param size:Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.