Stan Functions Reference
Overview
Interfaces and Platforms
Web Site
GitHub Organization
Forums
Licensing
Acknowledgements
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
3
Real-Valued Basic Functions
3.1
Vectorization of Real-Valued Functions
3.1.1
Unary 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
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.2.4
Elementwise Arithmetic Operations
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.8
Diagonal Matrix Functions
5.9
Slicing and Blocking Functions
5.9.1
Columns and Rows
5.9.2
Block Operations
5.10
Matrix Concatenation
5.10.0.1
Horizontal concatenation
5.10.0.2
Vertical concatenation
5.11
Special Matrix Functions
5.11.1
Softmax
5.11.2
Cumulative Sums
5.12
Covariance Functions
5.12.1
Exponentiated quadratic covariance function
5.13
Linear Algebra Functions and Solvers
5.13.1
Matrix Division Operators and Functions
5.13.2
Symmetric positive-definite matrix division functions
5.13.3
Matrix Exponential
5.13.4
Matrix Power
5.13.5
Linear Algebra Functions
5.14
Sort Functions
5.15
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
Discrete Distributions
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
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
Ordered Logistic Distribution
13.7.1
Probability Mass Function
13.7.2
Sampling Statement
13.7.3
Stan Functions
13.8
Ordered Logistic Generalized Linear Model (Ordinal Regression)
13.8.1
Probability Mass Function
13.8.2
Sampling Statement
13.8.3
Stan Functions
13.9
Ordered Probit Distribution
13.9.1
Probability Mass Function
13.9.2
Sampling Statement
13.9.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
.
Discrete Distributions