Stan Functions Reference
Overview
Built-In Functions
1
Void Functions
1.1
Print statement
1.2
Reject statement
2
Integer-Valued Basic Functions
2.1
Integer-valued arithmetic operators
2.1.1
Binary infix operators
2.1.2
Unary prefix operators
2.2
Absolute functions
2.3
Bound functions
2.4
Size functions
2.5
Casting functions
3
Real-Valued Basic Functions
3.1
Vectorization of real-valued functions
3.1.1
Unary function vectorization
3.1.2
Binary function vectorization
3.2
Mathematical constants
3.3
Special values
3.4
Log probability function
3.5
Logical functions
3.5.1
Comparison operators
3.5.2
Boolean operators
3.5.3
Logical functions
3.6
Real-valued arithmetic operators
3.6.1
Binary infix operators
3.6.2
Unary prefix operators
3.7
Step-like functions
3.7.1
Absolute value functions
3.7.2
Bounds functions
3.7.3
Arithmetic functions
3.7.4
Rounding functions
3.8
Power and logarithm functions
3.9
Trigonometric functions
3.10
Hyperbolic trigonometric functions
3.11
Link functions
3.12
Probability-related functions
3.12.1
Normal cumulative distribution functions
3.12.2
Other probability-related functions
3.13
Combinatorial functions
3.14
Composed functions
3.15
Special functions
4
Complex-Valued Basic Functions
4.1
Complex assignment and promotion
4.1.1
Complex function arguments
4.2
Complex constructors and accessors
4.2.1
Complex constructors
4.2.2
Complex accessors
4.3
Complex arithmetic operators
4.3.1
Unary operators
4.3.2
Binary operators
4.4
Complex comparison operators
4.5
Complex (compound) assignment operators
4.6
Complex special functions
4.7
Complex exponential and power functions
4.8
Complex trigonometric functions
4.9
Complex hyperbolic trigonometric functions
5
Array Operations
5.1
Reductions
5.1.1
Minimum and maximum
5.1.2
Sum, product, and log sum of exp
5.1.3
Sample mean, variance, and standard deviation
5.1.4
Norms
5.1.5
Euclidean distance and squared distance
5.1.6
Quantile
5.2
Array size and dimension function
5.3
Array broadcasting
5.4
Array concatenation
5.5
Sorting functions
5.6
Reversing functions
6
Matrix Operations
6.1
Integer-valued matrix size functions
6.2
Matrix arithmetic operators
6.2.1
Negation prefix operators
6.2.2
Infix matrix operators
6.2.3
Broadcast infix operators
6.3
Transposition operator
6.4
Elementwise functions
6.5
Dot products and specialized products
6.5.1
Specialized products
6.6
Reductions
6.6.1
Log sum of exponents
6.6.2
Minimum and maximum
6.6.3
Sums and products
6.6.4
Sample moments
6.6.5
Quantile
6.7
Broadcast functions
6.7.1
Symmetrization
6.8
Diagonal matrix functions
6.9
Container construction functions
6.10
Slicing and blocking functions
6.10.1
Columns and rows
6.10.2
Block operations
6.11
Matrix concatenation
6.12
Special matrix functions
6.12.1
Softmax
6.12.2
Cumulative sums
6.13
Gaussian Process Covariance Functions
6.13.1
Exponentiated quadratic kernel
6.13.2
Dot product kernel
6.13.3
Exponential kernel
6.13.4
Matern 3/2 kernel
6.13.5
Matern 5/2 kernel
6.13.6
Periodic kernel
6.14
Linear algebra functions and solvers
6.14.1
Matrix division operators and functions
6.14.2
Symmetric positive-definite matrix division functions
6.14.3
Matrix exponential
6.14.4
Matrix power
6.14.5
Linear algebra functions
6.15
Sort functions
6.16
Reverse functions
7
Complex Matrix Operations
7.1
Complex promotion
Promotion of complex arguments
7.1.1
Signature selection
Signatures for complex functions
Generic functions work for complex containers
7.2
Integer-valued complex matrix size functions
7.3
Complex matrix arithmetic operators
7.3.1
Negation prefix operators
7.3.2
Infix complex_matrix operators
7.3.3
Broadcast infix operators
7.4
Complex Transposition Operator
7.5
Complex elementwise functions
7.6
Dot products and specialized products for complex matrices
7.6.1
Specialized products
7.7
Complex reductions
7.7.1
Sums and products
7.8
Vectorized accessor functions
7.8.1
Type “demotion”
7.8.2
Real and imaginary component accessor functions
7.9
Complex broadcast functions
7.9.1
Symmetrization
7.10
Diagonal complex matrix functions
7.11
Slicing and blocking functions for complex matrices
7.11.1
Columns and rows
7.11.2
Block operations
7.12
Complex matrix concatenation
7.12.1
Horizontal concatenation
7.12.2
Vertical concatenation
7.13
Complex special matrix functions
7.13.1
Fast Fourier transforms
7.13.2
Cumulative sums
7.14
Complex linear algebra functions
7.14.1
Complex matrix division operators and functions
7.14.2
Linear algebra functions
7.15
Reverse functions for complex matrices
8
Sparse Matrix Operations
8.1
Compressed row storage
8.2
Conversion functions
8.2.1
Dense to sparse conversion
8.2.2
Sparse to dense conversion
8.3
Sparse matrix arithmetic
8.3.1
Sparse matrix multiplication
9
Mixed Operations
10
Compound Arithmetic and Assignment
10.1
Compound addition and assignment
10.2
Compound subtraction and assignment
10.3
Compound multiplication and assignment
10.4
Compound division and assignment
10.5
Compound elementwise multiplication and assignment
10.6
Compound elementwise division and assignment
11
Higher-Order Functions
11.1
Algebraic equation solvers
11.1.1
Specifying an algebraic equation as a function
11.1.2
Call to the algebraic solver
11.2
Ordinary differential equation (ODE) solvers
11.2.1
Non-stiff solver
11.2.2
Stiff solver
11.2.3
Adjoint solver
11.2.4
ODE system function
11.2.5
Arguments to the ODE solvers
11.2.6
Arguments to the adjoint ODE solver
11.3
Differential-Algebraic equation (DAE) solver
11.3.1
The DAE solver
11.3.2
DAE system function
11.3.3
Arguments to the DAE solver
11.4
1D integrator
11.4.1
Specifying an integrand as a function
11.4.2
Call to the 1D integrator
11.5
Reduce-sum function
11.5.1
Specifying the reduce-sum function
11.5.2
The partial sum function
11.6
Map-rect function
11.6.1
Specifying the mapped function
11.6.2
Rectangular map
12
Deprecated Functions
12.1
multiply_log
and
binomial_coefficient_log
functions
12.2
get_lp()
function
12.3
fabs
function
12.4
Integer division with
operator/
12.5
Real arguments to logical operators
operator&&
,
operator||
, and
operator!
12.6
integrate_ode_rk45, integrate_ode_adams, integrate_ode_bdf ODE Integrators
12.6.1
Specifying an ordinary differential equation as a function
12.6.2
Non-stiff solver
12.6.3
Stiff solver
12.6.4
Arguments to the ODE solvers
12.7
algebra_solver, algebra_solver_newton algebraic solvers
12.7.1
Specifying an algebraic equation as a function
12.7.2
Call to the algebraic solver
12.8
Exponentiated quadratic covariance functions
13
Removed Functions
14
Conventions for Probability Functions
14.1
Suffix marks type of function
14.2
Argument order and the vertical bar
14.3
Sampling notation
14.4
Finite inputs
14.5
Boundary conditions
14.6
Pseudorandom number generators
14.6.1
Restricted to transformed data and generated quantities
14.6.2
Limited vectorization
14.7
Cumulative distribution functions
14.8
Vectorization
14.8.1
Vectorized function signatures
14.8.2
Evaluating vectorized log probability functions
14.8.3
Evaluating vectorized PRNG functions
Discrete Distributions
15
Binary Distributions
15.1
Bernoulli distribution
15.1.1
Probability mass function
15.1.2
Sampling statement
15.1.3
Stan Functions
15.2
Bernoulli distribution, logit parameterization
15.2.1
Probability mass function
15.2.2
Sampling statement
15.2.3
Stan Functions
15.3
Bernoulli-logit generalized linear model (Logistic Regression)
15.3.1
Probability mass function
15.3.2
Sampling statement
15.3.3
Stan Functions
16
Bounded Discrete Distributions
16.1
Binomial distribution
16.1.1
Probability mass function
16.1.2
Log probability mass function
16.1.3
Gradient of log probability mass function
16.1.4
Sampling statement
16.1.5
Stan functions
16.2
Binomial distribution, logit parameterization
16.2.1
Probability mass function
16.2.2
Log probability mass function
16.2.3
Gradient of log probability mass function
16.2.4
Sampling statement
16.2.5
Stan functions
16.3
Beta-binomial distribution
16.3.1
Probability mass function
16.3.2
Sampling statement
16.3.3
Stan functions
16.4
Hypergeometric distribution
16.4.1
Probability mass function
16.4.2
Sampling statement
16.4.3
Stan functions
16.5
Categorical distribution
16.5.1
Probability mass functions
16.5.2
Sampling statement
16.5.3
Sampling statement
16.5.4
Stan functions
16.6
Categorical logit generalized linear model (softmax regression)
16.6.1
Probability mass functions
16.6.2
Sampling statement
16.6.3
Stan functions
16.7
Discrete range distribution
16.7.1
Probability mass functions
16.7.2
Sampling statement
16.7.3
Stan functions
16.8
Ordered logistic distribution
16.8.1
Probability mass function
16.8.2
Sampling statement
16.8.3
Stan functions
16.9
Ordered logistic generalized linear model (ordinal regression)
16.9.1
Probability mass function
16.9.2
Sampling statement
16.9.3
Stan functions
16.10
Ordered probit distribution
16.10.1
Probability mass function
16.10.2
Sampling statement
16.10.3
Stan functions
17
Unbounded Discrete Distributions
17.1
Negative binomial distribution
17.1.1
Probability mass function
17.1.2
Sampling statement
17.1.3
Stan functions
17.2
Negative binomial distribution (alternative parameterization)
17.2.1
Probability mass function
17.2.2
Sampling statement
17.2.3
Stan functions
17.3
Negative binomial distribution (log alternative parameterization)
17.3.1
Sampling statement
17.3.2
Stan functions
17.4
Negative-binomial-2-log generalized linear model (negative binomial regression)
17.4.1
Probability mass function
17.4.2
Sampling statement
17.4.3
Stan functions
17.5
Poisson distribution
17.5.1
Probability mass function
17.5.2
Sampling statement
17.5.3
Stan functions
17.6
Poisson distribution, log parameterization
17.6.1
Probability mass function
17.6.2
Sampling statement
17.6.3
Stan functions
17.7
Poisson-log generalized linear model (Poisson regression)
17.7.1
Probability mass function
17.7.2
Sampling statement
17.7.3
Stan functions
18
Multivariate Discrete Distributions
18.1
Multinomial distribution
18.1.1
Probability mass function
18.1.2
Sampling statement
18.1.3
Stan functions
18.2
Multinomial distribution, logit parameterization
18.2.1
Probability mass function
18.2.2
Sampling statement
18.2.3
Stan functions
Continuous Distributions
19
Unbounded Continuous Distributions
19.1
Normal distribution
19.1.1
Probability density function
19.1.2
Sampling statement
19.1.3
Stan functions
19.1.4
Standard normal distribution
19.1.5
Sampling statement
19.1.6
Stan functions
19.2
Normal-id generalized linear model (linear regression)
19.2.1
Probability distribution function
19.2.2
Sampling statement
19.2.3
Stan functions
19.3
Exponentially modified normal distribution
19.3.1
Probability density function
19.3.2
Sampling statement
19.3.3
Stan functions
19.4
Skew normal distribution
19.4.1
Probability density function
19.4.2
Sampling statement
19.4.3
Stan functions
19.5
Student-t distribution
19.5.1
Probability density function
19.5.2
Sampling statement
19.5.3
Stan functions
19.6
Cauchy distribution
19.6.1
Probability density function
19.6.2
Sampling statement
19.6.3
Stan functions
19.7
Double exponential (Laplace) distribution
19.7.1
Probability density function
19.7.2
Sampling statement
19.7.3
Stan functions
19.8
Logistic distribution
19.8.1
Probability density function
19.8.2
Sampling statement
19.8.3
Stan functions
19.9
Gumbel distribution
19.9.1
Probability density function
19.9.2
Sampling statement
19.9.3
Stan functions
19.10
Skew double exponential distribution
19.10.1
Probability density function
19.10.2
Sampling statement
19.10.3
Stan functions
20
Positive Continuous Distributions
20.1
Lognormal distribution
20.1.1
Probability density function
20.1.2
Sampling statement
20.1.3
Stan functions
20.2
Chi-square distribution
20.2.1
Probability density function
20.2.2
Sampling statement
20.2.3
Stan functions
20.3
Inverse chi-square distribution
20.3.1
Probability density function
20.3.2
Sampling statement
20.3.3
Stan functions
20.4
Scaled inverse chi-square distribution
20.4.1
Probability density function
20.4.2
Sampling statement
20.4.3
Stan functions
20.5
Exponential distribution
20.5.1
Probability density function
20.5.2
Sampling statement
20.5.3
Stan functions
20.6
Gamma distribution
20.6.1
Probability density function
20.6.2
Sampling statement
20.6.3
Stan functions
20.7
Inverse gamma Distribution
20.7.1
Probability density function
20.7.2
Sampling statement
20.7.3
Stan functions
20.8
Weibull distribution
20.8.1
Probability density function
20.8.2
Sampling statement
20.8.3
Stan functions
20.9
Frechet distribution
20.9.1
Probability density function
20.9.2
Sampling statement
20.9.3
Stan functions
20.10
Rayleigh distribution
20.10.1
Probability density function
20.10.2
Sampling statement
20.10.3
Stan functions
20.11
Log-logistic distribution
20.11.1
Probability density function
20.11.2
Sampling statement
20.11.3
Stan functions
21
Positive Lower-Bounded Distributions
21.1
Pareto distribution
21.1.1
Probability density function
21.1.2
Sampling statement
21.1.3
Stan functions
21.2
Pareto type 2 distribution
21.2.1
Probability density function
21.2.2
Sampling statement
21.2.3
Stan functions
21.3
Wiener First Passage Time Distribution
21.3.1
Probability density function
21.3.2
Sampling statement
21.3.3
Stan functions
21.3.4
boundaries
22
Continuous Distributions on [0, 1]
22.1
Beta distribution
22.1.1
Probability density function
22.1.2
Sampling statement
22.1.3
Stan functions
22.2
Beta proportion distribution
22.2.1
Probability density function
22.2.2
Sampling statement
22.2.3
Stan functions
23
Circular Distributions
23.1
Von Mises distribution
23.1.1
Probability density function
23.1.2
Sampling statement
23.1.3
Stan functions
23.1.4
Numerical stability
24
Bounded Continuous Distributions
24.1
Uniform distribution
24.1.1
Probability density function
24.1.2
Sampling statement
24.1.3
Stan functions
25
Distributions over Unbounded Vectors
25.1
Multivariate normal distribution
25.1.1
Probability density function
25.1.2
Sampling statement
25.1.3
Stan functions
25.2
Multivariate normal distribution, precision parameterization
25.2.1
Probability density function
25.2.2
Sampling statement
25.2.3
Stan functions
25.3
Multivariate normal distribution, Cholesky parameterization
25.3.1
Probability density function
25.3.2
Sampling statement
25.3.3
Stan functions
25.4
Multivariate Gaussian process distribution
25.4.1
Probability density function
25.4.2
Sampling statement
25.4.3
Stan functions
25.5
Multivariate Gaussian process distribution, Cholesky parameterization
25.5.1
Probability density function
25.5.2
Sampling statement
25.5.3
Stan functions
25.6
Multivariate Student-t distribution
25.6.1
Probability density function
25.6.2
Sampling statement
25.6.3
Stan functions
25.7
Multivariate Student-t distribution, Cholesky parameterization
25.7.1
Probability density function
25.7.2
Sampling statement
25.7.3
Stan functions
25.8
Gaussian dynamic linear models
25.8.1
Sampling statement
25.8.2
Stan functions
26
Simplex Distributions
26.1
Dirichlet distribution
26.1.1
Probability density function
26.1.2
Meaning of Dirichlet parameters
26.1.3
Sampling statement
26.1.4
Stan functions
27
Correlation Matrix Distributions
27.1
LKJ correlation distribution
27.1.1
Probability density function
27.1.2
Sampling statement
27.1.3
Stan functions
27.2
Cholesky LKJ correlation distribution
27.2.1
Probability density function
27.2.2
Sampling statement
27.2.3
Stan functions
28
Covariance Matrix Distributions
28.1
Wishart distribution
28.1.1
Probability density function
28.1.2
Sampling statement
28.1.3
Stan functions
28.2
Wishart distribution, Cholesky Parameterization
28.2.1
Probability density function
28.2.2
Stan functions
28.3
Inverse Wishart distribution
28.3.1
Probability density function
28.3.2
Sampling statement
28.3.3
Stan functions
28.4
Inverse Wishart distribution, Cholesky Parameterization
28.4.1
Probability density function
28.4.2
Stan functions
Additional Distributions
29
Hidden Markov Models
29.1
Stan functions
Appendix
30
Mathematical Functions
30.1
Beta
30.2
Incomplete beta
30.3
Gamma
30.4
Digamma
References
Stan Functions Reference
This is an old version,
view current version
.
Discrete Distributions