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
Array Operations
4.1
Reductions
4.1.1
Minimum and maximum
4.1.2
Sum, product, and log sum of exp
4.1.3
Sample mean, variance, and standard deviation
4.1.4
Euclidean distance and squared distance
4.2
Array size and dimension function
4.3
Array broadcasting
4.4
Array concatenation
4.5
Sorting functions
4.6
Reversing functions
5
Matrix Operations
5.1
Integer-valued matrix size functions
5.2
Matrix arithmetic operators
5.2.1
Negation prefix operators
5.2.2
Infix matrix operators
5.2.3
Broadcast infix operators
5.3
Transposition operator
5.4
Elementwise functions
5.5
Dot products and specialized products
5.5.1
Specialized products
5.6
Reductions
5.6.1
Log sum of exponents
5.6.2
Minimum and maximum
5.6.3
Sums and products
5.6.4
Sample moments
5.7
Broadcast functions
5.7.1
Symmetrization
5.8
Diagonal matrix functions
5.9
Container construction functions
5.10
Slicing and blocking functions
5.10.1
Columns and rows
5.10.2
Block operations
5.11
Matrix concatenation
5.12
Special matrix functions
5.12.1
Softmax
5.12.2
Cumulative sums
5.13
Covariance functions
5.13.1
Exponentiated quadratic covariance function
5.14
Linear algebra functions and solvers
5.14.1
Matrix division operators and functions
5.14.2
Symmetric positive-definite matrix division functions
5.14.3
Matrix exponential
5.14.4
Matrix power
5.14.5
Linear algebra functions
5.15
Sort functions
5.16
Reverse functions
6
Sparse Matrix Operations
6.1
Compressed row storage
6.2
Conversion functions
6.2.1
Dense to sparse conversion
6.2.2
Sparse to dense conversion
6.3
Sparse matrix arithmetic
6.3.1
Sparse matrix multiplication
7
Mixed Operations
8
Compound Arithmetic and Assignment
8.1
Compound addition and assignment
8.2
Compound subtraction and assignment
8.3
Compound multiplication and assignment
8.4
Compound division and assignment
8.5
Compound elementwise multiplication and assignment
8.6
Compound elementwise division and assignment
9
Higher-Order Functions
9.1
Algebraic equation solver
9.1.1
Specifying an algebraic equation as a function
9.1.2
Call to the algebraic solver
9.2
Ordinary differential equation (ODE) solvers
9.2.1
Non-stiff solver
9.2.2
Stiff solver
9.2.3
ODE system function
9.2.4
Arguments to the ODE solvers
9.3
1D integrator
9.3.1
Specifying an integrand as a function
9.3.2
Call to the 1D integrator
9.4
Reduce-sum function
9.4.1
Specifying the reduce-sum function
9.4.2
The partial sum function
9.5
Map-rect function
9.5.1
Specifying the mapped function
9.5.2
Rectangular map
10
Deprecated Functions
10.1
integrate_ode_rk45, integrate_ode_adams, integrate_ode_bdf ODE integrators
10.1.1
Specifying an ordinary differential equation as a function
10.1.2
Non-stiff solver
10.1.3
Stiff solver
10.1.4
Arguments to the ODE solvers
11
Conventions for Probability Functions
11.1
Suffix marks type of function
11.2
Argument order and the vertical bar
11.3
Sampling notation
11.4
Finite inputs
11.5
Boundary conditions
11.6
Pseudorandom number generators
11.6.1
Restricted to transformed data and generated quantities
11.6.2
Limited vectorization
11.7
Cumulative distribution functions
11.8
Vectorization
11.8.1
Vectorized function signatures
11.8.2
Evaluating vectorized log probability functions
11.8.3
Evaluating vectorized PRNG functions
Discrete Distributions
12
Binary Distributions
12.1
Bernoulli distribution
12.1.1
Probability mass function
12.1.2
Sampling statement
12.1.3
Stan Functions
12.2
Bernoulli distribution, logit parameterization
12.2.1
Probability mass function
12.2.2
Sampling statement
12.2.3
Stan Functions
12.3
Bernoulli-logit generalized linear model (Logistic Regression)
12.3.1
Probability mass function
12.3.2
Sampling statement
12.3.3
Stan Functions
13
Bounded Discrete Distributions
13.1
Binomial distribution
13.1.1
Probability mass function
13.1.2
Log probability mass function
13.1.3
Gradient of log probability mass function
13.1.4
Sampling statement
13.1.5
Stan functions
13.2
Binomial distribution, logit parameterization
13.2.1
Probability mass function
13.2.2
Log probability mass function
13.2.3
Gradient of log probability mass function
13.2.4
Sampling statement
13.2.5
Stan functions
13.3
Beta-binomial distribution
13.3.1
Probability mass function
13.3.2
Sampling statement
13.3.3
Stan functions
13.4
Hypergeometric distribution
13.4.1
Probability mass function
13.4.2
Sampling statement
13.4.3
Stan functions
13.5
Categorical distribution
13.5.1
Probability mass functions
13.5.2
Sampling statement
13.5.3
Sampling statement
13.5.4
Stan functions
13.6
Categorical logit generalized linear model (softmax regression)
13.6.1
Probability mass functions
13.6.2
Sampling statement
13.6.3
Stan functions
13.7
Discrete range distribution
13.7.1
Probability mass functions
13.7.2
Sampling statement
13.7.3
Stan functions
13.8
Ordered logistic distribution
13.8.1
Probability mass function
13.8.2
Sampling statement
13.8.3
Stan functions
13.9
Ordered logistic generalized linear model (ordinal regression)
13.9.1
Probability mass function
13.9.2
Sampling statement
13.9.3
Stan functions
13.10
Ordered probit distribution
13.10.1
Probability mass function
13.10.2
Sampling statement
13.10.3
Stan functions
14
Unbounded Discrete Distributions
14.1
Negative binomial distribution
14.1.1
Probability mass function
14.1.2
Sampling statement
14.1.3
Stan functions
14.2
Negative binomial distribution (alternative parameterization)
14.2.1
Probability mass function
14.2.2
Sampling statement
14.2.3
Stan functions
14.3
Negative binomial distribution (log alternative parameterization)
14.3.1
Sampling statement
14.3.2
Stan functions
14.4
Negative-binomial-2-log generalized linear model (negative binomial regression)
14.4.1
Probability mass function
14.4.2
Sampling statement
14.4.3
Stan functions
14.5
Poisson distribution
14.5.1
Probability mass function
14.5.2
Sampling statement
14.5.3
Stan functions
14.6
Poisson distribution, log parameterization
14.6.1
Probability mass function
14.6.2
Sampling statement
14.6.3
Stan functions
14.7
Poisson-log generalized linear model (Poisson regression)
14.7.1
Probability mass function
14.7.2
Sampling statement
14.7.3
Stan functions
15
Multivariate Discrete Distributions
15.1
Multinomial distribution
15.1.1
Probability mass function
15.1.2
Sampling statement
15.1.3
Stan functions
15.2
Multinomial distribution, logit parameterization
15.2.1
Probability mass function
15.2.2
Sampling statement
15.2.3
Stan functions
Continuous Distributions
16
Unbounded Continuous Distributions
16.1
Normal distribution
16.1.1
Probability density function
16.1.2
Sampling statement
16.1.3
Stan functions
16.1.4
Standard normal distribution
16.1.5
Sampling statement
16.1.6
Stan functions
16.2
Normal-id generalized linear model (linear regression)
16.2.1
Probability distribution function
16.2.2
Sampling statement
16.2.3
Stan functions
16.3
Exponentially modified normal distribution
16.3.1
Probability density function
16.3.2
Sampling statement
16.3.3
Stan functions
16.4
Skew normal distribution
16.4.1
Probability density function
16.4.2
Sampling statement
16.4.3
Stan functions
16.5
Student-t distribution
16.5.1
Probability density function
16.5.2
Sampling statement
16.5.3
Stan functions
16.6
Cauchy distribution
16.6.1
Probability density function
16.6.2
Sampling statement
16.6.3
Stan functions
16.7
Double exponential (Laplace) distribution
16.7.1
Probability density function
16.7.2
Sampling statement
16.7.3
Stan functions
16.8
Logistic distribution
16.8.1
Probability density function
16.8.2
Sampling statement
16.8.3
Stan functions
16.9
Gumbel distribution
16.9.1
Probability density function
16.9.2
Sampling statement
16.9.3
Stan functions
17
Positive Continuous Distributions
17.1
Lognormal distribution
17.1.1
Probability density function
17.1.2
Sampling statement
17.1.3
Stan functions
17.2
Chi-square distribution
17.2.1
Probability density function
17.2.2
Sampling statement
17.2.3
Stan functions
17.3
Inverse chi-square distribution
17.3.1
Probability density function
17.3.2
Sampling statement
17.3.3
Stan functions
17.4
Scaled inverse chi-square distribution
17.4.1
Probability density function
17.4.2
Sampling statement
17.4.3
Stan functions
17.5
Exponential distribution
17.5.1
Probability density function
17.5.2
Sampling statement
17.5.3
Stan functions
17.6
Gamma distribution
17.6.1
Probability density function
17.6.2
Sampling statement
17.6.3
Stan functions
17.7
Inverse gamma Distribution
17.7.1
Probability density function
17.7.2
Sampling statement
17.7.3
Stan functions
17.8
Weibull distribution
17.8.1
Probability density function
17.8.2
Sampling statement
17.8.3
Stan functions
17.9
Frechet distribution
17.9.1
Probability density function
17.9.2
Sampling statement
17.9.3
Stan functions
17.10
Rayleigh distribution
17.10.1
Probability density function
17.10.2
Sampling statement
17.10.3
Stan functions
18
Positive Lower-Bounded Distributions
18.1
Pareto distribution
18.1.1
Probability density function
18.1.2
Sampling statement
18.1.3
Stan functions
18.2
Pareto type 2 distribution
18.2.1
Probability density function
18.2.2
Sampling statement
18.2.3
Stan functions
18.3
Wiener First Passage Time Distribution
18.3.1
Probability density function
18.3.2
Sampling statement
18.3.3
Stan functions
18.3.4
boundaries
19
Continuous Distributions on [0, 1]
19.1
Beta distribution
19.1.1
Probability density function
19.1.2
Sampling statement
19.1.3
Stan functions
19.2
Beta proportion distribution
19.2.1
Probability density function
19.2.2
Sampling statement
19.2.3
Stan functions
20
Circular Distributions
20.1
Von Mises distribution
20.1.1
Probability density function
20.1.2
Sampling statement
20.1.3
Stan functions
20.1.4
Numerical stability
21
Bounded Continuous Distributions
21.1
Uniform distribution
21.1.1
Probability density function
21.1.2
Sampling statement
21.1.3
Stan functions
22
Distributions over Unbounded Vectors
22.1
Multivariate normal distribution
22.1.1
Probability density function
22.1.2
Sampling statement
22.1.3
Stan functions
22.2
Multivariate normal distribution, precision parameterization
22.2.1
Probability density function
22.2.2
Sampling statement
22.2.3
Stan functions
22.3
Multivariate normal distribution, Cholesky parameterization
22.3.1
Probability density function
22.3.2
Sampling statement
22.3.3
Stan functions
22.4
Multivariate Gaussian process distribution
22.4.1
Probability density function
22.4.2
Sampling statement
22.4.3
Stan functions
22.5
Multivariate Gaussian process distribution, Cholesky parameterization
22.5.1
Probability density function
22.5.2
Sampling statement
22.5.3
Stan functions
22.6
Multivariate Student-t distribution
22.6.1
Probability density function
22.6.2
Sampling statement
22.6.3
Stan functions
22.7
Gaussian dynamic linear models
22.7.1
Sampling statement
22.7.2
Stan functions
23
Simplex Distributions
23.1
Dirichlet distribution
23.1.1
Probability density function
23.1.2
Meaning of Dirichlet parameters
23.1.3
Sampling statement
23.1.4
Stan functions
24
Correlation Matrix Distributions
24.1
LKJ correlation distribution
24.1.1
Probability density function
24.1.2
Sampling statement
24.1.3
Stan functions
24.2
Cholesky LKJ correlation distribution
24.2.1
Probability density function
24.2.2
Sampling statement
24.2.3
Stan functions
25
Covariance Matrix Distributions
25.1
Wishart distribution
25.1.1
Probability density function
25.1.2
Sampling statement
25.1.3
Stan functions
25.2
Inverse Wishart distribution
25.2.1
Probability density function
25.2.2
Sampling statement
25.2.3
Stan functions
Additional Distributions
26
Hidden Markov Models
26.1
Stan functions
Appendix
27
Mathematical Functions
27.1
Beta
27.2
Incomplete beta
27.3
Gamma
27.4
Digamma
References
Stan Functions Reference
This is an old version,
view current version
.
Additional Distributions