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
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
Euclidean distance and squared distance
5.1.5
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
Sparse Matrix Operations
7.1
Compressed row storage
7.2
Conversion functions
7.2.1
Dense to sparse conversion
7.2.2
Sparse to dense conversion
7.3
Sparse matrix arithmetic
7.3.1
Sparse matrix multiplication
8
Mixed Operations
9
Compound Arithmetic and Assignment
9.1
Compound addition and assignment
9.2
Compound subtraction and assignment
9.3
Compound multiplication and assignment
9.4
Compound division and assignment
9.5
Compound elementwise multiplication and assignment
9.6
Compound elementwise division and assignment
10
Higher-Order Functions
10.1
Algebraic equation solver
10.1.1
Specifying an algebraic equation as a function
10.1.2
Call to the algebraic solver
10.2
Ordinary differential equation (ODE) solvers
10.2.1
Non-stiff solver
10.2.2
Stiff solver
10.2.3
Adjoint solver
10.2.4
ODE system function
10.2.5
Arguments to the ODE solvers
10.2.6
Arguments to the adjoint ODE solver
10.3
Differential-Algebraic equation (DAE) solver
10.3.1
The DAE solver
10.3.2
DAE system function
10.3.3
Arguments to the DAE solver
10.4
1D integrator
10.4.1
Specifying an integrand as a function
10.4.2
Call to the 1D integrator
10.5
Reduce-sum function
10.5.1
Specifying the reduce-sum function
10.5.2
The partial sum function
10.6
Map-rect function
10.6.1
Specifying the mapped function
10.6.2
Rectangular map
11
Deprecated Functions
11.1
multiply_log
and
binomial_coefficient_log
functions
11.2
get_lp()
function
11.3
abs(real x)
function
11.4
Integer division with
operator/
11.5
integrate_ode_rk45, integrate_ode_adams, integrate_ode_bdf ODE Integrators
11.5.1
Specifying an ordinary differential equation as a function
11.5.2
Non-stiff solver
11.5.3
Stiff solver
11.5.4
Arguments to the ODE solvers
11.6
Exponentiated quadratic covariance functions
12
Removed Functions
13
Conventions for Probability Functions
13.1
Suffix marks type of function
13.2
Argument order and the vertical bar
13.3
Sampling notation
13.4
Finite inputs
13.5
Boundary conditions
13.6
Pseudorandom number generators
13.6.1
Restricted to transformed data and generated quantities
13.6.2
Limited vectorization
13.7
Cumulative distribution functions
13.8
Vectorization
13.8.1
Vectorized function signatures
13.8.2
Evaluating vectorized log probability functions
13.8.3
Evaluating vectorized PRNG functions
Discrete Distributions
14
Binary Distributions
14.1
Bernoulli distribution
14.1.1
Probability mass function
14.1.2
Sampling statement
14.1.3
Stan Functions
14.2
Bernoulli distribution, logit parameterization
14.2.1
Probability mass function
14.2.2
Sampling statement
14.2.3
Stan Functions
14.3
Bernoulli-logit generalized linear model (Logistic Regression)
14.3.1
Probability mass function
14.3.2
Sampling statement
14.3.3
Stan Functions
15
Bounded Discrete Distributions
15.1
Binomial distribution
15.1.1
Probability mass function
15.1.2
Log probability mass function
15.1.3
Gradient of log probability mass function
15.1.4
Sampling statement
15.1.5
Stan functions
15.2
Binomial distribution, logit parameterization
15.2.1
Probability mass function
15.2.2
Log probability mass function
15.2.3
Gradient of log probability mass function
15.2.4
Sampling statement
15.2.5
Stan functions
15.3
Beta-binomial distribution
15.3.1
Probability mass function
15.3.2
Sampling statement
15.3.3
Stan functions
15.4
Hypergeometric distribution
15.4.1
Probability mass function
15.4.2
Sampling statement
15.4.3
Stan functions
15.5
Categorical distribution
15.5.1
Probability mass functions
15.5.2
Sampling statement
15.5.3
Sampling statement
15.5.4
Stan functions
15.6
Categorical logit generalized linear model (softmax regression)
15.6.1
Probability mass functions
15.6.2
Sampling statement
15.6.3
Stan functions
15.7
Discrete range distribution
15.7.1
Probability mass functions
15.7.2
Sampling statement
15.7.3
Stan functions
15.8
Ordered logistic distribution
15.8.1
Probability mass function
15.8.2
Sampling statement
15.8.3
Stan functions
15.9
Ordered logistic generalized linear model (ordinal regression)
15.9.1
Probability mass function
15.9.2
Sampling statement
15.9.3
Stan functions
15.10
Ordered probit distribution
15.10.1
Probability mass function
15.10.2
Sampling statement
15.10.3
Stan functions
16
Unbounded Discrete Distributions
16.1
Negative binomial distribution
16.1.1
Probability mass function
16.1.2
Sampling statement
16.1.3
Stan functions
16.2
Negative binomial distribution (alternative parameterization)
16.2.1
Probability mass function
16.2.2
Sampling statement
16.2.3
Stan functions
16.3
Negative binomial distribution (log alternative parameterization)
16.3.1
Sampling statement
16.3.2
Stan functions
16.4
Negative-binomial-2-log generalized linear model (negative binomial regression)
16.4.1
Probability mass function
16.4.2
Sampling statement
16.4.3
Stan functions
16.5
Poisson distribution
16.5.1
Probability mass function
16.5.2
Sampling statement
16.5.3
Stan functions
16.6
Poisson distribution, log parameterization
16.6.1
Probability mass function
16.6.2
Sampling statement
16.6.3
Stan functions
16.7
Poisson-log generalized linear model (Poisson regression)
16.7.1
Probability mass function
16.7.2
Sampling statement
16.7.3
Stan functions
17
Multivariate Discrete Distributions
17.1
Multinomial distribution
17.1.1
Probability mass function
17.1.2
Sampling statement
17.1.3
Stan functions
17.2
Multinomial distribution, logit parameterization
17.2.1
Probability mass function
17.2.2
Sampling statement
17.2.3
Stan functions
Continuous Distributions
18
Unbounded Continuous Distributions
18.1
Normal distribution
18.1.1
Probability density function
18.1.2
Sampling statement
18.1.3
Stan functions
18.1.4
Standard normal distribution
18.1.5
Sampling statement
18.1.6
Stan functions
18.2
Normal-id generalized linear model (linear regression)
18.2.1
Probability distribution function
18.2.2
Sampling statement
18.2.3
Stan functions
18.3
Exponentially modified normal distribution
18.3.1
Probability density function
18.3.2
Sampling statement
18.3.3
Stan functions
18.4
Skew normal distribution
18.4.1
Probability density function
18.4.2
Sampling statement
18.4.3
Stan functions
18.5
Student-t distribution
18.5.1
Probability density function
18.5.2
Sampling statement
18.5.3
Stan functions
18.6
Cauchy distribution
18.6.1
Probability density function
18.6.2
Sampling statement
18.6.3
Stan functions
18.7
Double exponential (Laplace) distribution
18.7.1
Probability density function
18.7.2
Sampling statement
18.7.3
Stan functions
18.8
Logistic distribution
18.8.1
Probability density function
18.8.2
Sampling statement
18.8.3
Stan functions
18.9
Gumbel distribution
18.9.1
Probability density function
18.9.2
Sampling statement
18.9.3
Stan functions
18.10
Skew double exponential distribution
18.10.1
Probability density function
18.10.2
Sampling statement
18.10.3
Stan functions
19
Positive Continuous Distributions
19.1
Lognormal distribution
19.1.1
Probability density function
19.1.2
Sampling statement
19.1.3
Stan functions
19.2
Chi-square distribution
19.2.1
Probability density function
19.2.2
Sampling statement
19.2.3
Stan functions
19.3
Inverse chi-square distribution
19.3.1
Probability density function
19.3.2
Sampling statement
19.3.3
Stan functions
19.4
Scaled inverse chi-square distribution
19.4.1
Probability density function
19.4.2
Sampling statement
19.4.3
Stan functions
19.5
Exponential distribution
19.5.1
Probability density function
19.5.2
Sampling statement
19.5.3
Stan functions
19.6
Gamma distribution
19.6.1
Probability density function
19.6.2
Sampling statement
19.6.3
Stan functions
19.7
Inverse gamma Distribution
19.7.1
Probability density function
19.7.2
Sampling statement
19.7.3
Stan functions
19.8
Weibull distribution
19.8.1
Probability density function
19.8.2
Sampling statement
19.8.3
Stan functions
19.9
Frechet distribution
19.9.1
Probability density function
19.9.2
Sampling statement
19.9.3
Stan functions
19.10
Rayleigh distribution
19.10.1
Probability density function
19.10.2
Sampling statement
19.10.3
Stan functions
19.11
Log-logistic distribution
19.11.1
Probability density function
19.11.2
Sampling statement
19.11.3
Stan functions
20
Positive Lower-Bounded Distributions
20.1
Pareto distribution
20.1.1
Probability density function
20.1.2
Sampling statement
20.1.3
Stan functions
20.2
Pareto type 2 distribution
20.2.1
Probability density function
20.2.2
Sampling statement
20.2.3
Stan functions
20.3
Wiener First Passage Time Distribution
20.3.1
Probability density function
20.3.2
Sampling statement
20.3.3
Stan functions
20.3.4
boundaries
21
Continuous Distributions on [0, 1]
21.1
Beta distribution
21.1.1
Probability density function
21.1.2
Sampling statement
21.1.3
Stan functions
21.2
Beta proportion distribution
21.2.1
Probability density function
21.2.2
Sampling statement
21.2.3
Stan functions
22
Circular Distributions
22.1
Von Mises distribution
22.1.1
Probability density function
22.1.2
Sampling statement
22.1.3
Stan functions
22.1.4
Numerical stability
23
Bounded Continuous Distributions
23.1
Uniform distribution
23.1.1
Probability density function
23.1.2
Sampling statement
23.1.3
Stan functions
24
Distributions over Unbounded Vectors
24.1
Multivariate normal distribution
24.1.1
Probability density function
24.1.2
Sampling statement
24.1.3
Stan functions
24.2
Multivariate normal distribution, precision parameterization
24.2.1
Probability density function
24.2.2
Sampling statement
24.2.3
Stan functions
24.3
Multivariate normal distribution, Cholesky parameterization
24.3.1
Probability density function
24.3.2
Sampling statement
24.3.3
Stan functions
24.4
Multivariate Gaussian process distribution
24.4.1
Probability density function
24.4.2
Sampling statement
24.4.3
Stan functions
24.5
Multivariate Gaussian process distribution, Cholesky parameterization
24.5.1
Probability density function
24.5.2
Sampling statement
24.5.3
Stan functions
24.6
Multivariate Student-t distribution
24.6.1
Probability density function
24.6.2
Sampling statement
24.6.3
Stan functions
24.7
Gaussian dynamic linear models
24.7.1
Sampling statement
24.7.2
Stan functions
25
Simplex Distributions
25.1
Dirichlet distribution
25.1.1
Probability density function
25.1.2
Meaning of Dirichlet parameters
25.1.3
Sampling statement
25.1.4
Stan functions
26
Correlation Matrix Distributions
26.1
LKJ correlation distribution
26.1.1
Probability density function
26.1.2
Sampling statement
26.1.3
Stan functions
26.2
Cholesky LKJ correlation distribution
26.2.1
Probability density function
26.2.2
Sampling statement
26.2.3
Stan functions
27
Covariance Matrix Distributions
27.1
Wishart distribution
27.1.1
Probability density function
27.1.2
Sampling statement
27.1.3
Stan functions
27.2
Inverse Wishart distribution
27.2.1
Probability density function
27.2.2
Sampling statement
27.2.3
Stan functions
Additional Distributions
28
Hidden Markov Models
28.1
Stan functions
Appendix
29
Mathematical Functions
29.1
Beta
29.2
Incomplete beta
29.3
Gamma
29.4
Digamma
References
Stan Functions Reference
This is an old version,
view current version
.
Built-In Functions