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
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
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.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
Linear Algebra Functions
5.14
Sort 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 Solvers
9.2.1
Specifying an Ordinary Differential Equation as a Function
9.2.2
Non-Stiff Solver
9.2.3
Stiff Solver
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
Higher-Order Map
9.4.1
Specifying the Mapped Function
9.4.2
Rectangular Map
Discrete Distributions
10
Conventions for Probability Functions
10.1
Suffix Marks Type of Function
10.2
Argument Order and the Vertical Bar
10.3
Sampling Notation
10.4
Finite Inputs
10.5
Boundary Conditions
10.6
Pseudorandom Number Generators
10.6.1
Restricted to Transformed Data and Generated Quantities
10.6.2
Limited Vectorization
10.7
Cumulative Distribution Functions
10.8
Vectorization
10.8.1
Vectorized Function Signatures
10.8.2
Evaluating Vectorized Log Probability Functions
10.8.3
Evaluating Vectorized PRNG Functions
11
Binary Distributions
11.1
Bernoulli Distribution
11.1.1
Probability Mass Function
11.1.2
Sampling Statement
11.1.3
Stan Functions
11.2
Bernoulli Distribution, Logit Parameterization
11.2.1
Probability Mass Function
11.2.2
Sampling Statement
11.2.3
Stan Functions
11.3
Bernoulli-Logit Generalised Linear Model (Logistic Regression)
11.3.1
Probability Mass Function
11.3.2
Sampling Statement
11.3.3
Stan Functions
12
Bounded Discrete Distributions
12.1
Binomial Distribution
12.1.1
Probability Mass Function
12.1.2
Log Probability Mass Function
12.1.3
Gradient of Log Probability Mass Function
12.1.4
Sampling Statement
12.1.5
Stan Functions
12.2
Binomial Distribution, Logit Parameterization
12.2.1
Probability Mass Function
12.2.2
Log Probability Mass Function
12.2.3
Gradient of Log Probability Mass Function
12.2.4
Sampling Statement
12.2.5
Stan Functions
12.3
Beta-Binomial Distribution
12.3.1
Probability Mass Function
12.3.2
Sampling Statement
12.3.3
Stan Functions
12.4
Hypergeometric Distribution
12.4.1
Probability Mass Function
12.4.2
Sampling Statement
12.4.3
Stan Functions
12.5
Categorical Distribution
12.5.1
Probability Mass Functions
12.5.2
Sampling Statement
12.5.3
Sampling Statement
12.5.4
Stan Functions
12.6
Ordered Logistic Distribution
12.6.1
Probability Mass Function
12.6.2
Sampling Statement
12.6.3
Stan Functions
12.7
Ordered Probit Distribution
12.7.1
Probability Mass Function
12.7.2
Sampling Statement
12.7.3
Stan Functions
13
Unbounded Discrete Distributions
13.1
Negative Binomial Distribution
13.1.1
Probability Mass Function
13.1.2
Sampling Statement
13.1.3
Stan Functions
13.2
Negative Binomial Distribution (alternative parameterization)
13.2.1
Probability Mass Function
13.2.2
Sampling Statement
13.2.3
Stan Functions
13.3
Negative Binomial Distribution (log alternative parameterization)
13.3.1
Sampling Statement
13.3.2
Stan Functions
13.4
Negative-Binomial-2-Log Generalised Linear Model (Negative Binomial Regression)
13.4.1
Probability Mass Function
13.4.2
Sampling Statement
13.4.3
Stan Functions
13.5
Poisson Distribution
13.5.1
Probability Mass Function
13.5.2
Sampling Statement
13.5.3
Stan Functions
13.6
Poisson Distribution, Log Parameterization
13.6.1
Probability Mass Function
13.6.2
Sampling Statement
13.6.3
Stan Functions
13.7
Poisson-Log Generalised Linear Model (Poisson Regression)
13.7.1
Probability Mass Function
13.7.2
Sampling Statement
13.7.3
Stan Functions
14
Multivariate Discrete Distributions
14.1
Multinomial Distribution
14.1.1
Probability Mass Function
14.1.2
Sampling Statement
14.1.3
Stan Functions
Continuous Distributions
15
Unbounded Continuous Distributions
15.1
Normal Distribution
15.1.1
Probability Density Function
15.1.2
Sampling Statement
15.1.3
Stan Functions
15.1.4
Standard Normal Distribution
15.1.5
Stan Functions
15.1.6
Sampling Statement
15.2
Normal-Id Generalised Linear Model (Linear Regression)
15.2.1
Probability Mass Function
15.2.2
Sampling Statement
15.2.3
Stan Functions
15.3
Exponentially Modified Normal Distribution
15.3.1
Probability Density Function
15.3.2
Sampling Statement
15.3.3
Stan Functions
15.4
Skew Normal Distribution
15.4.1
Probability Density Function
15.4.2
Sampling Statement
15.4.3
Stan Functions
15.5
Student-T Distribution
15.5.1
Probability Density Function
15.5.2
Sampling Statement
15.5.3
Stan Functions
15.6
Cauchy Distribution
15.6.1
Probability Density Function
15.6.2
Sampling Statement
15.6.3
Stan Functions
15.7
Double Exponential (Laplace) Distribution
15.7.1
Probability Density Function
15.7.2
Sampling Statement
15.7.3
Stan Functions
15.8
Logistic Distribution
15.8.1
Probability Density Function
15.8.2
Sampling Statement
15.8.3
Stan Functions
15.9
Gumbel Distribution
15.9.1
Probability Density Function
15.9.2
Sampling Statement
15.9.3
Stan Functions
16
Positive Continuous Distributions
16.1
Lognormal Distribution
16.1.1
Probability Density Function
16.1.2
Sampling Statement
16.1.3
Stan Functions
16.2
Chi-Square Distribution
16.2.1
Probability Density Function
16.2.2
Sampling Statement
16.2.3
Stan Functions
16.3
Inverse Chi-Square Distribution
16.3.1
Probability Density Function
16.3.2
Sampling Statement
16.3.3
Stan Functions
16.4
Scaled Inverse Chi-Square Distribution
16.4.1
Probability Density Function
16.4.2
Sampling Statement
16.4.3
Stan Functions
16.5
Exponential Distribution
16.5.1
Probability Density Function
16.5.2
Sampling Statement
16.5.3
Stan Functions
16.6
Gamma Distribution
16.6.1
Probability Density Function
16.6.2
Sampling Statement
16.6.3
Stan Functions
16.7
Inverse Gamma Distribution
16.7.1
Probability Density Function
16.7.2
Sampling Statement
16.7.3
Stan Functions
16.8
Weibull Distribution
16.8.1
Probability Density Function
16.8.2
Sampling Statement
16.8.3
Stan Functions
16.9
Frechet Distribution
16.9.1
Probability Density Function
16.9.2
Sampling Statement
16.9.3
Stan Functions
17
Non-negative Continuous Distributions
17.1
Rayleigh Distribution
17.1.1
Probability Density Function
17.1.2
Sampling Statement
17.1.3
Stan Functions
17.2
Wiener First Passage Time Distribution
17.2.1
Probability Density Function
17.2.2
Sampling Statement
17.2.3
Stan Functions
17.2.4
Boundaries
18
Positive Lower-Bounded Probabilities
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
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 Probabilities
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
Appendix
26
Mathematical Functions
26.1
Beta
26.2
Incomplete Beta
26.3
Gamma
26.4
Digamma
References
Stan Functions Reference
This is an old version,
view current version
.
Discrete Distributions