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
Covariance functions
6.13.1
Exponentiated quadratic covariance function
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
1D integrator
10.3.1
Specifying an integrand as a function
10.3.2
Call to the 1D integrator
10.4
Reduce-sum function
10.4.1
Specifying the reduce-sum function
10.4.2
The partial sum function
10.5
Map-rect function
10.5.1
Specifying the mapped function
10.5.2
Rectangular map
11
Deprecated Functions
11.1
integrate_ode_rk45, integrate_ode_adams, integrate_ode_bdf ODE integrators
11.1.1
Specifying an ordinary differential equation as a function
11.1.2
Non-stiff solver
11.1.3
Stiff solver
11.1.4
Arguments to the ODE solvers
12
Conventions for Probability Functions
12.1
Suffix marks type of function
12.2
Argument order and the vertical bar
12.3
Sampling notation
12.4
Finite inputs
12.5
Boundary conditions
12.6
Pseudorandom number generators
12.6.1
Restricted to transformed data and generated quantities
12.6.2
Limited vectorization
12.7
Cumulative distribution functions
12.8
Vectorization
12.8.1
Vectorized function signatures
12.8.2
Evaluating vectorized log probability functions
12.8.3
Evaluating vectorized PRNG functions
Discrete Distributions
13
Binary Distributions
13.1
Bernoulli distribution
13.1.1
Probability mass function
13.1.2
Sampling statement
13.1.3
Stan Functions
13.2
Bernoulli distribution, logit parameterization
13.2.1
Probability mass function
13.2.2
Sampling statement
13.2.3
Stan Functions
13.3
Bernoulli-logit generalized linear model (Logistic Regression)
13.3.1
Probability mass function
13.3.2
Sampling statement
13.3.3
Stan Functions
14
Bounded Discrete Distributions
14.1
Binomial distribution
14.1.1
Probability mass function
14.1.2
Log probability mass function
14.1.3
Gradient of log probability mass function
14.1.4
Sampling statement
14.1.5
Stan functions
14.2
Binomial distribution, logit parameterization
14.2.1
Probability mass function
14.2.2
Log probability mass function
14.2.3
Gradient of log probability mass function
14.2.4
Sampling statement
14.2.5
Stan functions
14.3
Beta-binomial distribution
14.3.1
Probability mass function
14.3.2
Sampling statement
14.3.3
Stan functions
14.4
Hypergeometric distribution
14.4.1
Probability mass function
14.4.2
Sampling statement
14.4.3
Stan functions
14.5
Categorical distribution
14.5.1
Probability mass functions
14.5.2
Sampling statement
14.5.3
Sampling statement
14.5.4
Stan functions
14.6
Categorical logit generalized linear model (softmax regression)
14.6.1
Probability mass functions
14.6.2
Sampling statement
14.6.3
Stan functions
14.7
Discrete range distribution
14.7.1
Probability mass functions
14.7.2
Sampling statement
14.7.3
Stan functions
14.8
Ordered logistic distribution
14.8.1
Probability mass function
14.8.2
Sampling statement
14.8.3
Stan functions
14.9
Ordered logistic generalized linear model (ordinal regression)
14.9.1
Probability mass function
14.9.2
Sampling statement
14.9.3
Stan functions
14.10
Ordered probit distribution
14.10.1
Probability mass function
14.10.2
Sampling statement
14.10.3
Stan functions
15
Unbounded Discrete Distributions
15.1
Negative binomial distribution
15.1.1
Probability mass function
15.1.2
Sampling statement
15.1.3
Stan functions
15.2
Negative binomial distribution (alternative parameterization)
15.2.1
Probability mass function
15.2.2
Sampling statement
15.2.3
Stan functions
15.3
Negative binomial distribution (log alternative parameterization)
15.3.1
Sampling statement
15.3.2
Stan functions
15.4
Negative-binomial-2-log generalized linear model (negative binomial regression)
15.4.1
Probability mass function
15.4.2
Sampling statement
15.4.3
Stan functions
15.5
Poisson distribution
15.5.1
Probability mass function
15.5.2
Sampling statement
15.5.3
Stan functions
15.6
Poisson distribution, log parameterization
15.6.1
Probability mass function
15.6.2
Sampling statement
15.6.3
Stan functions
15.7
Poisson-log generalized linear model (Poisson regression)
15.7.1
Probability mass function
15.7.2
Sampling statement
15.7.3
Stan functions
16
Multivariate Discrete Distributions
16.1
Multinomial distribution
16.1.1
Probability mass function
16.1.2
Sampling statement
16.1.3
Stan functions
16.2
Multinomial distribution, logit parameterization
16.2.1
Probability mass function
16.2.2
Sampling statement
16.2.3
Stan functions
Continuous Distributions
17
Unbounded Continuous Distributions
17.1
Normal distribution
17.1.1
Probability density function
17.1.2
Sampling statement
17.1.3
Stan functions
17.1.4
Standard normal distribution
17.1.5
Sampling statement
17.1.6
Stan functions
17.2
Normal-id generalized linear model (linear regression)
17.2.1
Probability distribution function
17.2.2
Sampling statement
17.2.3
Stan functions
17.3
Exponentially modified normal distribution
17.3.1
Probability density function
17.3.2
Sampling statement
17.3.3
Stan functions
17.4
Skew normal distribution
17.4.1
Probability density function
17.4.2
Sampling statement
17.4.3
Stan functions
17.5
Student-t distribution
17.5.1
Probability density function
17.5.2
Sampling statement
17.5.3
Stan functions
17.6
Cauchy distribution
17.6.1
Probability density function
17.6.2
Sampling statement
17.6.3
Stan functions
17.7
Double exponential (Laplace) distribution
17.7.1
Probability density function
17.7.2
Sampling statement
17.7.3
Stan functions
17.8
Logistic distribution
17.8.1
Probability density function
17.8.2
Sampling statement
17.8.3
Stan functions
17.9
Gumbel distribution
17.9.1
Probability density function
17.9.2
Sampling statement
17.9.3
Stan functions
17.10
Skew double exponential distribution
17.10.1
Probability density function
17.10.2
Sampling statement
17.10.3
Stan functions
18
Positive Continuous Distributions
18.1
Lognormal distribution
18.1.1
Probability density function
18.1.2
Sampling statement
18.1.3
Stan functions
18.2
Chi-square distribution
18.2.1
Probability density function
18.2.2
Sampling statement
18.2.3
Stan functions
18.3
Inverse chi-square distribution
18.3.1
Probability density function
18.3.2
Sampling statement
18.3.3
Stan functions
18.4
Scaled inverse chi-square distribution
18.4.1
Probability density function
18.4.2
Sampling statement
18.4.3
Stan functions
18.5
Exponential distribution
18.5.1
Probability density function
18.5.2
Sampling statement
18.5.3
Stan functions
18.6
Gamma distribution
18.6.1
Probability density function
18.6.2
Sampling statement
18.6.3
Stan functions
18.7
Inverse gamma Distribution
18.7.1
Probability density function
18.7.2
Sampling statement
18.7.3
Stan functions
18.8
Weibull distribution
18.8.1
Probability density function
18.8.2
Sampling statement
18.8.3
Stan functions
18.9
Frechet distribution
18.9.1
Probability density function
18.9.2
Sampling statement
18.9.3
Stan functions
18.10
Rayleigh distribution
18.10.1
Probability density function
18.10.2
Sampling statement
18.10.3
Stan functions
19
Positive Lower-Bounded Distributions
19.1
Pareto distribution
19.1.1
Probability density function
19.1.2
Sampling statement
19.1.3
Stan functions
19.2
Pareto type 2 distribution
19.2.1
Probability density function
19.2.2
Sampling statement
19.2.3
Stan functions
19.3
Wiener First Passage Time Distribution
19.3.1
Probability density function
19.3.2
Sampling statement
19.3.3
Stan functions
19.3.4
boundaries
20
Continuous Distributions on [0, 1]
20.1
Beta distribution
20.1.1
Probability density function
20.1.2
Sampling statement
20.1.3
Stan functions
20.2
Beta proportion distribution
20.2.1
Probability density function
20.2.2
Sampling statement
20.2.3
Stan functions
21
Circular Distributions
21.1
Von Mises distribution
21.1.1
Probability density function
21.1.2
Sampling statement
21.1.3
Stan functions
21.1.4
Numerical stability
22
Bounded Continuous Distributions
22.1
Uniform distribution
22.1.1
Probability density function
22.1.2
Sampling statement
22.1.3
Stan functions
23
Distributions over Unbounded Vectors
23.1
Multivariate normal distribution
23.1.1
Probability density function
23.1.2
Sampling statement
23.1.3
Stan functions
23.2
Multivariate normal distribution, precision parameterization
23.2.1
Probability density function
23.2.2
Sampling statement
23.2.3
Stan functions
23.3
Multivariate normal distribution, Cholesky parameterization
23.3.1
Probability density function
23.3.2
Sampling statement
23.3.3
Stan functions
23.4
Multivariate Gaussian process distribution
23.4.1
Probability density function
23.4.2
Sampling statement
23.4.3
Stan functions
23.5
Multivariate Gaussian process distribution, Cholesky parameterization
23.5.1
Probability density function
23.5.2
Sampling statement
23.5.3
Stan functions
23.6
Multivariate Student-t distribution
23.6.1
Probability density function
23.6.2
Sampling statement
23.6.3
Stan functions
23.7
Gaussian dynamic linear models
23.7.1
Sampling statement
23.7.2
Stan functions
24
Simplex Distributions
24.1
Dirichlet distribution
24.1.1
Probability density function
24.1.2
Meaning of Dirichlet parameters
24.1.3
Sampling statement
24.1.4
Stan functions
25
Correlation Matrix Distributions
25.1
LKJ correlation distribution
25.1.1
Probability density function
25.1.2
Sampling statement
25.1.3
Stan functions
25.2
Cholesky LKJ correlation distribution
25.2.1
Probability density function
25.2.2
Sampling statement
25.2.3
Stan functions
26
Covariance Matrix Distributions
26.1
Wishart distribution
26.1.1
Probability density function
26.1.2
Sampling statement
26.1.3
Stan functions
26.2
Inverse Wishart distribution
26.2.1
Probability density function
26.2.2
Sampling statement
26.2.3
Stan functions
Additional Distributions
27
Hidden Markov Models
27.1
Stan functions
Appendix
28
Mathematical Functions
28.1
Beta
28.2
Incomplete beta
28.3
Gamma
28.4
Digamma
References
Stan Functions Reference
This is an old version,
view current version
.
5
Array Operations
Reductions
Array size and dimension function
Array broadcasting
Array concatenation
Sorting functions
Reversing functions