Distributions - zward/Amua GitHub Wiki

Overview

Many common probability distributions are built-in to Amua. Distributions can be used to model:

  • A random variable drawn from the distribution - indicated by the argument ~
  • The expected value of a distribution - indicated by the argument E
  • The variance of a distribution - indicated by the argument V
  • The probability density/mass (PDF/PMF) of a distribution - indicated by the argument f
  • The cumulative probability (CDF) of a distribution - indicated by the argument F
  • The quantile (inverse CDF) of a distribution - indicated by the argument Q

In addition to scalars, distributions also support vector (matrix) arguments, and will return a result matrix of the same shape. For example, Beta(2,1,~) returns a single sample, Beta(rep(2,10),rep(1,10),~) returns a vector of 10 i.i.d. samples, and Beta([2,2],[2,2](/zward/Amua/wiki/2,2],[2,2), [1,1],[1,1](/zward/Amua/wiki/1,1],[1,1), ~) returns a 2x2 matrix of samples. Matrix table elements can also be used as arguments. See FAQ: How do I use a vector parameter?

Distributions will turn green in the formula bar. Hovering over a distribution name in the formula bar will show a tool-tip with more information. The plot function tool also provides an easy way to visualize distributions.

Types of Distributions

Discrete

Distribution Name Description Parameters Support
Bern Bernoulli The probability distribution of a single Boolean-valued outcome p: Probability of success Integers in {0,1}
Bin Binomial Used to model the number of successes that occur in a fixed number of repeated trials n: Number of trials (Integer >0) p: Probability of success Integers in {0,1,...,n}
Cat Categorical A discrete probability distribution of a random variable that can take on one of n possible values p: Row vector of size ncontaining event probabilities (real numbers in [0,1]) that sum to 1.0 Integers in {0,1,...n-1}
DUnif Discrete Uniform Used to model a discrete distribution where all values are equally likely a: Minimum value, inclusive (integer) b: Maximum value, inclusive (integer) Integers in {a,a+1,...,b}
Geom Geometric Used to model the number of successes that occur before the first failure p: Probability of success Integers in {0,1,...}
HGeom Hypergeometric Used to model the number of successes in a fixed number of draws without replacement w: Number of possible successes (Integer >0) b: Number of other possible outcomes (Integer >0) n: Number of draws (Integer >0) Integers in {0,1,...,min(w,n)}
NBin Negative Binomial Used to model the number of successes that occur among repeated trials before a specified number of failures happen r: Number of failures until the trials are stopped (Integer ≥0) p: Probability of success Integers in {0,1,...}
Pois Poisson Used to model the number of events that occur in a fixed interval of time/space with a known average rate λ: Average number of events in the interval (>0) Integers in {0,1,...}
Zipf Zipf Used to model discrete power law distributions s: Exponent (real number >0) n: Number of elements (integer ≥1) Integers in {1,2,...,n}

Continuous

Distribution Name Description Parameters Support
Beta Beta A continuous distribution bounded by 0 and 1. Often used to model probabilities a: Shape parameter >0 b: Shape parameter >0 Real numbers in [0,1]
Cauchy Cauchy A bell-shaped distribution with heavy tails. Note: Mean and variance are undefined x_0: Location parameter γ: Scale parameter >0 Real numbers
ChiSq Chi-Square Distribution of the sum of squares of k independent standard normal variables k: Degrees of freedom (Integer >0) Real numbers ≥0
Expo Exponential Used to model the time between events with a constant average rate λ: Average rate of events >0 Real numbers >0
Gamma Gamma A continuous distribution that yields positive real numbers k: Shape >0 θ: Scale >0 Real numbers >0
Gumbel Gumbel Used to model the distribution of the extrema (max/min) of a number of samples of various distributions μ: Location β: Scale >0 Real numbers
HalfCauchy Half-Cauchy Positive Half-Cauchy. Note: Mean and variance are undefined γ: Scale parameter >0 Real numbers >0
HalfNorm Half-Normal Positive Half-Normal σ: Standard deviation >0 Real numbers >0
Laplace Laplace A continuous distribution that can be thought of as two Exponential distributions put back-to-back μ: Location b: Scale >0 Real numbers
Logistic Logistic A continuous distribution that resembles the Normal distribution in shape but has heavier tails μ: Location s: Scale >0 Real numbers
LogNorm Log-Normal A continuous distribution of a random variable whose logarithm follows a Normal distribution μ: Location σ: Scale >0 Real numbers >0
Norm Normal Canonical bell-shaped distribution μ: Mean σ: Standard deviation >0 Real numbers
Pareto Pareto A power law probability distribution k: Scale >0, minimum possible value of x α: Shape >0, Pareto index Real numbers >0
PERT PERT Distribution (Program Evaluation and Review Technique) The PERT method converts a Triangular distribution to a Beta-shaped distribution. It is often used in risk analysis to model subjective estimates a: Minimum value, inclusive b: Mode (most likely value) c: Maximum value, exclusive Real numbers in [a,c)
StudentT Student's t-distribution A bell-shaped distribution centered at 0 ν: Degrees of freedom >0 Real numbers
Tri Triangular A simple distribution to model the minimum, most likely, and maximum values of a random variable a: Minimum value, inclusive b: Mode (most likely value) c: Maximum value, exclusive Real numbers in [a,c)
TruncNorm Truncated Normal A normal distribution bound by min/max values μ: Mean σ: Standard deviation >0 a: Minimum value b: Maximum value Real numbers in [a,b]
Unif Uniform Used to model a continuous distribution where all values are equally likely a: Minimum value, inclusive b: Maximum value, exclusive Real numbers in [a,b)
Weibull Weibull Often used to model time-to-failure a: Shape parameter >0 b: Scale parameter >0 Real numbers ≥0

Multivariate

Distribution Name Description Parameters Support
Dir Dirichlet A multivariate generalization of the Beta distribution α: Row vector of concentration parameters (Real numbers >0) Row vector of real numbers in (0,1) that sum to 1.0
Multi Multinomial A generalization of the Binomial distribution to multiple categories n: Number of trials (Integer >0) p: Row vector containing event probabilities (real numbers in [0,1] that sum to 1.0) Row vector of integers in {0,1,...,n} that sum to n
MvNorm Multivariate Normal A multivariate normal distribution μ: Means (column vector) Σ: Covariance matrix (symmetric positive definite) Column vector of real numbers

For more information, see FAQ: How do I sample from a Dirichlet distribution?