\part{Discrete Distributions}\label{discrete-prob-functions.part}


\chapter{Binary Distributions}

\noindent
Binary probability distributions have support on $\setlist{0,1}$,
where 1 represents the value true and 0 the value false.

\section{Bernoulli Distribution}

\subsubsection{Probability Mass Function}

If $\theta \in [0,1]$, then for $y \in \setlist{0,1}$, 
\[
\distro{Bernoulli}(y|\theta)
=
\left\{
\begin{array}{ll}
\theta & \mbox{if } y = 1, \mbox{ and}
\\
1 - \theta & \mbox{if } y = 0.
\end{array}
\right.
\]

\pitem{y}{bernoulli}{theta}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{bernoulli\_log}{ints \farg{y}, reals \farg{theta}}{The
  log Bernoulli probability mass of \farg{y} given chance of success
  \farg{theta}}

%

\end{description}

\begin{description}
%
\fitem{real}{bernoulli\_cdf}{ints \farg{y}, reals \farg{theta}}{The
  Bernoulli cumulative distribution function of \farg{y} given chance of success
  \farg{theta}}
%
\fitem{real}{bernoulli\_cdf\_log}{ints \farg{y}, reals \farg{theta}}{The
  log of the Bernoulli cumulative distribution function of \farg{y} given 
  chance of success \farg{theta}}
%
\fitem{real}{bernoulli\_ccdf\_log}{ints \farg{y}, reals \farg{theta}}{The
  log of the Bernoulli complementary cumulative distribution function of 
  \farg{y} given chance of success \farg{theta}}
\end{description}
%
\begin{description}
\fitem{int}{bernoulli\_rng}{real \farg{theta}}{Generate a Bernoulli
  variate with chance of success \farg{theta}; may only be used in
  generated quantities block}
\end{description}

\section{Bernoulli Distribution, Logit Parameterization}

\Stan also supplies a direct parameterization in terms of a
logit-transformed chance-of-success parameter.  This parameterization
is more numerically stable if the chance-of-success parameter is on
the logit scale, as with the linear predictor in a logistic
regression.  

\subsubsection{Probability Mass Function}

If $\alpha \in \reals$, then for $c \in \setlist{0,1}$,
\[
\distro{BernoulliLogit}(c|\alpha)
=
\distro{Bernoulli}(c|\mbox{logit}^{-1}(\alpha))
= 
\left\{
\begin{array}{ll}
\mbox{logit}^{-1}(\alpha) & \mbox{if } y = 1, \mbox{ and}
\\
1 - \mbox{logit}^{-1}(\alpha) & \mbox{if } y = 0.
\end{array}
\right.
\]

\pitem{y}{bernoulli\_logit}{alpha}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{bernoulli\_logit\_log}{ints \farg{y}, reals \farg{alpha}}{The
  log Bernoulli probability mass of \farg{y} given logit chance of success
  \code{exp(\farg{alpha})}}
%
\end{description}



\chapter{Bounded Discrete Distributions}\label{betafun.chapter}

\noindent
Bounded discrete probability functions have support on
$\setlist{0,\ldots,N}$ for some upper bound $N$.


\section{Binomial Distribution}

\subsubsection{Probability Mass Function}

Suppose $N \in \nats$ and $\theta \in [0,1]$, and $n \in
\{0,\ldots,N\}$.
\[
\distro{Binomial}(n|N,\theta)
= {N \choose n} \theta^n (1 - \theta)^{N - n}.
\]


\subsubsection{Log Probability Mass Function}

\begin{eqnarray*}
\log \distro{Binomial}(n|N,\theta)
& = &
\log \Gamma(N+1) - \log \Gamma(n + 1) - \log \Gamma(N- n + 1)
\\[4pt]
& & { } + n \log \theta + (N - n) \log (1 - \theta), 
\end{eqnarray*}


\subsubsection{Gradient of Log Probability Mass Function}

\[
\frac{\partial}{\partial \theta} \log \distro{Binomial}(n|N,\theta)
= \frac{n}{\theta}
- \frac{N - n}{1 - \theta}
\]


\pitem{n}{binomial}{N,theta}

\subsubsection{Stan Functions}

\begin{description}
%
  \fitem{real}{binomial\_log}{ints \farg{n}, ints \farg{N}, reals
    \farg{theta}}{The log binomial probability mass of \farg{n}
    successes in \farg{N} trials given chance of success \farg{theta}}
%
  \fitem{real}{binomial\_cdf}{ints \farg{n}, ints \farg{N}, reals
    \farg{theta}}{The binomial cumulative distribution function of \farg{n}
    successes in \farg{N} trials given chance of success \farg{theta}}
%
  \fitem{real}{binomial\_cdf\_log}{ints \farg{n}, ints \farg{N}, reals
    \farg{theta}}{The log of the binomial cumulative distribution function of 
    \farg{n} successes in \farg{N} trials given chance of success \farg{theta}}
%
  \fitem{real}{binomial\_ccdf\_log}{ints \farg{n}, ints \farg{N}, reals
    \farg{theta}}{The log of the binomial complementary cumulative distribution 
     function of \farg{n} successes in \farg{N} trials given chance of success
    \farg{theta}}
%
\end{description}
%
\begin{description}
\fitem{int}{binomial\_rng}{int \farg{N}, real \farg{theta}}{Generate a binomial
  variate with \farg{N} trials and chance of success \farg{theta}; may only be used in
  generated quantities block}
\end{description}



\section{Binomial Distribution, Logit Parameterization}

Stan also provides a version of the binomial probability mass function
distribution with the chance of success parameterized on the
unconstrained logistic scale.  

\subsubsection{Probability Mass Function}

Suppose $N \in \nats$, $\alpha \in \reals$, and $n \in
\{0,\ldots,N\}$.

\begin{eqnarray*}
\distro{BinomialLogit}(n|N,\alpha)
& = & \distro{BinomialLogit}(n|N,\mbox{logit}^{-1}(\alpha))
\\[6pt]
& = & {N \choose n} \left( \mbox{logit}^{-1}(\alpha) \right)^{n}
                    \left( 1 - \mbox{logit}^{-1}(\alpha) \right)^{N - n}.
\end{eqnarray*}


\subsubsection{Log Probability Mass Function}

\begin{eqnarray*}
\log \distro{BinomialLogit}(n|N,\alpha)
& = &
\log \Gamma(N+1) - \log \Gamma(n + 1) - \log \Gamma(N- n + 1)
\\[4pt]
& & { } + n \log \mbox{logit}^{-1}(\alpha) + (N - n) \log \left( 1 -
  \mbox{logit}^{-1}(\alpha) \right), 
\end{eqnarray*}


\subsubsection{Gradient of Log Probability Mass Function}

\[
\frac{\partial}{\partial \alpha} \log \distro{BinomialLogit}(n|N,\alpha)
= \frac{n}{\mbox{logit}^{-1}(-\alpha)}
- \frac{N - n}{\mbox{logit}^{-1}(\alpha)}
\]

\pitem{n}{binomial\_logit}{N,alpha}

\subsubsection{Stan Functions}

\begin{description}
%
  \fitem{real}{binomial\_logit\_log}{ints \farg{n}, ints \farg{N}, reals
    \farg{alpha}}{The log binomial probability mass of \farg{n}
    successes in \farg{N} trials given logit-scaled chance of success \farg{alpha}}
%
\end{description}



\section{Beta-Binomial Distribution}

\subsubsection{Probability Mass Function}

If $N \in \nats$, $\alpha \in \posreals$, and $\beta \in \posreals$,
then for $n \in \setlist{0,\ldots,N}$,
\[
\distro{BetaBinomial}(n|N,\alpha,\beta)
= 
{N \choose n} \frac{\Betafun(n+\alpha, N -n +
  \beta)}{\Betafun(\alpha,\beta)},
\]
%
where the beta function $\Betafun(x,y)$ is defined for $x \in
\posreals$ and $y \in \posreals$ by
%
\[
\Betafun(x,y)
= \frac{\Gamma(x) \ \Gamma(y)}{\Gamma(x + y)}.
\]

\pitem{n}{beta\_binomial}{N,alpha}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{beta\_binomial\_log}{ints \farg{n}, ints \farg{N}, reals
  \farg{alpha}, reals \farg{beta}}{The log beta-binomial probability mass
  of \farg{n} successes in \farg{N} trials given prior success count
  (plus one) of \farg{alpha} and prior failure count (plus one) of
  \farg{beta}}
%
\fitem{real}{beta\_binomial\_cdf}{ints \farg{n}, ints \farg{N}, reals
  \farg{alpha}, reals \farg{beta}}{The beta-binomial cumulative
  distribution function
  of \farg{n} successes in \farg{N} trials given prior success count
  (plus one) of \farg{alpha} and prior failure count (plus one) of
  \farg{beta}}
%
\fitem{real}{beta\_binomial\_cdf\_log}{ints \farg{n}, ints \farg{N}, reals
  \farg{alpha}, reals \farg{beta}}{The log of the beta-binomial cumulative
  distribution function
  of \farg{n} successes in \farg{N} trials given prior success count
  (plus one) of \farg{alpha} and prior failure count (plus one) of
  \farg{beta}}
%
\fitem{real}{beta\_binomial\_ccdf\_log}{ints \farg{n}, ints \farg{N}, reals
  \farg{alpha}, reals \farg{beta}}{The log of the beta-binomial complementary
   cumulative distribution function of \farg{n} successes in \farg{N} trials 
   given prior success count (plus one) of \farg{alpha} and prior failure count 
  (plus one) of \farg{beta}}
\end{description}
%
\begin{description}
\fitem{int}{beta\_binomial\_rng}{int \farg{N}, real \farg{alpha}, real 
   \farg{beta}}{Generate a beta-binomial variate with \farg{N} trials, prior 
   success count (plus one) of \farg{alpha}, and prior failure count (plus 
   one) of \farg{beta}; may only be used in generated quantities block}
\end{description}




\section{Hypergeometric Distribution}

\subsubsection{Probability Mass Function}

If $a \in \nats$, $b \in \nats$, and $N \in \setlist{0,\ldots,a+b}$,
then for $n \in \setlist{\max(0,N-b),\ldots,\min(a,N)}$, 
\[
\distro{Hypergeometric}(n|N,a,b)
=
\frac{\normalsize{a \choose n} {b \choose {N - n}}}
     {\normalsize{{a + b} \choose N}}.
\]


\pitem{n}{hypergeometric}{N,a,b}

\subsubsection{Stan Functions}

\begin{description}
%
  \fitem{real}{hypergeometric\_log}{int \farg{n}, int \farg{N}, int
    \farg{a}, int \farg{b}}{The log hypergeometric probability mass of
    \farg{n} successes in \farg{N} trials given total success count of
    \farg{a} and total failure count of \farg{b}}

%
\end{description}
%
\begin{description}
\fitem{int}{hypergeometric\_rng}{int \farg{N}, real \farg{a}, real 
   \farg{b}}{Generate a hypergeometric variate with \farg{N} trials, total 
    success count of \farg{a}, and total failure count of \farg{b}; may only 
    be used in generated quantities block}
\end{description}




\section{Categorical Distribution}

\subsubsection{Probability Mass Functions}

If $N \in \nats$, $N > 0$, and $\theta \in \mbox{$N$-simplex}$, then for $y \in
\setlist{1,\ldots,N}$, 
%
\[
\distro{Categorical}(y|\theta) = \theta_y.
\]
%
In addition, Stan provides a log-odds scaled categorical distribution, 
%
\[
\distro{CategoricalLogit}(y|\beta)
= \distro{Categorical}(y|\mbox{softmax}(\beta)).
\]
%
See \refsection{softmax} for the definition of the softmax function.


\pitem{y}{categorical}{theta}


\subsubsection{Stan Functions}

All of the categorical distributions are vectorized so that the
outcome \farg{y} can be a single integer (type \code{int}) or an array
of integers (type \code{int[]}).

\begin{description}
\fitem{real}{categorical\_log}{ints \farg{y}, vector \farg{theta}}{The
  log categorical probability mass function with outcome(s) \farg{y} in 
$1:N$ given $N$-simplex distribution parameter \farg{theta}.}
%
\fitem{real}{categorical\_logit\_log}{ints \farg{y}, vector
  \farg{beta}}{The log categorical probability mass function with
  outcome(s) \farg{y} in $1:N$ given log-odds of outcomes \farg{beta}.}
%
\end{description}
%
\begin{description}
\fitem{int}{categorical\_rng}{vector \farg{theta}}{Generate a
  categorical variate with $N$-simplex distribution parameter 
\farg{theta}; may only be used in generated quantities block}
\end{description}



\section{Ordered Logistic Distribution}

\subsubsection{Probability Mass Function}

If $K \in \nats$ with $K > 2$, $c \in \reals^{K-1}$ such that $c_k <
c_{k+1}$ for $k \in \setlist{1,\ldots,K-2}$, and $\eta \in \reals$, then for $k \in
\setlist{1,\ldots,K}$,
\[
\distro{OrderedLogistic}(k|\eta,c)
=
\left\{
\begin{array}{ll}
1 - \mbox{logit}^{-1}(\eta - c_1) & \mbox{if } k = 1,
\\[4pt]
\mbox{logit}^{-1}(\eta - c_{k-1}) - \mbox{logit}^{-1}(\eta -
c_{k})

& \mbox{if } 1 < k < K, \mbox{and}
\\[4pt]
\mbox{logit}^{-1}(\eta - c_{K-1}) - 0
& \mbox{if } k = K.
\end{array}
\right.
\]
%
The $k=1$ and $k=K$ edge cases can be subsumed into the general definition
by setting $c_0 = -\infty$ and $c_K = +\infty$ with
$\mbox{logit}^{-1}(-\infty) = 0$ and $\mbox{logit}^{-1}(\infty) = 1$.

\pitem{k}{ordered\_logistic}{eta,c}


\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{ordered\_logistic\_log}{int \farg{k}, real \farg{eta},
    vector \farg{c}}{The log ordered logistic probability mass of
    \farg{k} given linear predictor \farg{eta} and cutpoints
    \farg{c}.}
%
\fitem{int}{ordered\_logistic\_rng}{real \farg{eta}, vector \farg{c}}{Generate 
  an ordered logistic variate with linear predictor \farg{eta} and cutpoints
    \farg{c}; may only be used in generated quantities block}
\end{description}



\chapter{Unbounded Discrete Distributions}

\noindent
The unbounded discrete distributions have support over the natural
numbers (i.e., the non-negative integers).


\section{Negative Binomial Distribution}

\subsubsection{Probability Mass Function}

If $\alpha \in \posreals$ and $\beta \in \posreals$, then for $n \in
\nats$,
\[
\distro{NegativeBinomial}(n|\alpha,\beta)
 = 
{{n + \alpha - 1} \choose {\alpha - 1}}
\,
\left( \frac{\beta}{\beta+1} \right)^{\!\alpha}
\,
\left( \frac{1}{\beta + 1} \right)^{\!n} \!.
\]
\begin{eqnarray*}
\log \distro{NegativeBinomial}(n|\alpha,\beta)
& = & \log \Gamma(n + \alpha) 
  - \log \Gamma(n + 1)
  - \log \Gamma(\alpha)
\\[4pt]
& & 
  {} + \alpha \left(\log \beta - \log (\beta + 1) \right)
  - n \log (\beta + 1)
\end{eqnarray*}
\[
\frac{\partial}{\partial \alpha} 
\log \distro{NegativeBinomial}(n|\alpha,\beta)
= \Psi(n + \alpha)
- \Psi(\alpha)
+ \log \beta
- \log (\beta + 1)
\]
\[
\frac{\partial}{\partial \beta} 
\log \distro{NegativeBinomial}(n|\alpha,\beta)
= \frac{\alpha}{\beta} - \frac{\alpha + n}{\beta + 1}
\]
where $\Psi$ is the digamma function, defined as
\[
\Psi(x) = \frac{\partial}{\partial x} \log \Gamma(x).
\]

\pitem{n}{neg\_binomial}{alpha,beta}

\subsubsection{Stan Functions}

\begin{description}
%
 \fitem{real}{neg\_binomial\_log}{ints \farg{n}, reals
   \farg{alpha}, reals \farg{beta}}{The log negative binomial probability
   mass of \farg{n} given shape \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{neg\_binomial\_cdf}{ints \farg{n}, reals
   \farg{alpha}, reals \farg{beta}}{The negative binomial cumulative
   distribution function
   of \farg{n} given shape \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{neg\_binomial\_cdf\_log}{ints \farg{n}, reals
   \farg{alpha}, reals \farg{beta}}{The log of the negative binomial cumulative
   distribution function
   of \farg{n} given shape \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{neg\_binomial\_ccdf\_log}{ints \farg{n}, reals
   \farg{alpha}, reals \farg{beta}}{The log of the negative binomial 
   complementary cumulative distribution function of \farg{n} 
   given shape \farg{alpha} and inverse scale \farg{beta}}
%
\fitem{int}{neg\_binomial\_rng}{real \farg{alpha}, real \farg{beta}}{Generate a
  negative binomial variate with shape \farg{alpha} and inverse scale
  \farg{beta}; may only be used in generated quantities block}
\end{description}


\section{Poisson Distribution}

\subsubsection{Probability Mass Function}

If $\lambda \in \posreals$, then for $n \in \nats$,
\[
\distro{Poisson}(n|\lambda)
= 
\frac{1}{n!}
\,
\lambda^n 
\,
\exp(-\lambda).
\]

\pitem{n}{poisson}{lambda}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{poisson\_log}{ints \farg{n}, reals \farg{lambda}}{The
  log Poisson probability mass of \farg{n} given rate \farg{lambda}}
%
\fitem{real}{poisson\_cdf}{ints \farg{n}, reals \farg{lambda}}{The
  Poisson cumulative distribution function of \farg{n} given rate \farg{lambda}}
%
\fitem{real}{poisson\_cdf\_log}{ints \farg{n}, reals \farg{lambda}}{The log of the 
  Poisson cumulative distribution function of \farg{n} given rate \farg{lambda}}
%
\fitem{real}{poisson\_ccdf\_log}{ints \farg{n}, reals \farg{lambda}}{The log of the 
  Poisson complementary cumulative distribution function of \farg{n} given rate \farg{lambda}}
%
\fitem{int}{poisson\_rng}{real \farg{lambda}}{Generate a poisson variate with 
 rate \farg{lambda}; may only be used in generated quantities block}
\end{description}


\section{Poisson Distribution, Log Parameterization}


Stan also provides a parameterization of the Poisson using the log
rate $\alpha = \log \lambda$ as a parameter.  This is useful for
log-linear Poisson regressions so that the predictor does not need to
be exponentiated and passed into the standard Poisson probability
function.

\subsubsection{Probability Mass Function}

If $\alpha \in \reals$, then for $n \in \nats$,
\[
\distro{PoissonLog}(n|\alpha)
= 
\frac{1}{n!}
\,
\exp \left(n\alpha - \exp(\alpha) \right).
\]

\pitem{n}{poisson\_log}{alpha}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{poisson\_log\_log}{ints \farg{n}, reals \farg{alpha}}{The
  log Poisson probability mass of \farg{n} given log rate \farg{alpha}}
\end{description}




\chapter{Multivariate Discrete Distributions}

\noindent
The multivariate discrete distributions are over multiple integer
values, which are expressed in Stan as arrays.

\section{Multinomial Distribution}

\subsubsection{Probability Mass Function}

If $K \in \nats$, $N \in \nats$, and $\theta \in \mbox{$K$-simplex}$,
then for $y \in \nats^K$ such that $\sum_{k=1}^K y_k = N$,
%
\[
\distro{Multinomial}(y|\theta,N)
= {N \choose {y_1,\ldots,y_K}} 
\prod_{k=1}^K \theta_k^{y_k},
\]
where the multinomial coefficient is defined by
\[
{N \choose {y_1,\ldots,y_k}}
= \frac{N!}{\prod_{k=1}^K y_k!}.
\]

\pitem{y}{multinomial}{theta,N}

\subsubsection{Stan Functions}

\begin{description}
 \fitem{real}{multinomial\_log}{int[] \farg{y}, vector
    \farg{theta}, int \farg{N}}{The log multinomial probability mass function with
    outcome array \code{y} of size $K$ given the $K$-simplex
    distribution parameter \farg{theta} and (implicit) total count
    \code{N = sum(\farg{y})}}
%
\fitem{vector}{multinomial\_rng}{vector \farg{theta}, int \farg{N}}{Generate a
  multinomial variate with simplex distribution parameter \farg{theta} and 
  (implicit) total count $N$; may only be used in generated quantities block}
\end{description}



\part{Continuous Distributions}\label{continuous-prob-functions.part}



\chapter{Unbounded Continuous Distributions}

\noindent
The unbounded univariate continuous probability distributions have
support on all real numbers.


\section{Normal Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\sigma \in \posreals$, then for $y \in
\reals$,
\[
\distro{Normal}(y|\mu,\sigma)
=
\frac{1}{\sqrt{2 \pi} \ \sigma}
\exp\left( - \, \frac{1}{2}
           \left(  \frac{y - \mu}{\sigma} \right)^2
    \right)
\!.
\]

\pitem{y}{normal}{mu,sigma}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{normal\_log}{reals \farg{y}, reals \farg{mu}, reals
    \farg{sigma}}{The log of the normal density of \farg{y} given
    location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{normal\_cdf}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The cumulative normal distribution of \farg{y}
  given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{normal\_cdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The log of the cumulative normal distribution of \farg{y}
  given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{normal\_ccdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The log of the complementary cumulative normal distribution 
  of \farg{y} given location \farg{mu} and scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{normal\_rng}{real \farg{mu}, real \farg{sigma}}{Generate a normal
  variate with location \farg{mu} and scale \farg{sigma}; may only be used in
  generated quantities block}
\end{description}


\section{Exponentially Modified Normal Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$, $\sigma \in \posreals$, and $\lambda \in
\posreals$, then for $y \in \reals$,
\[
\distro{ExpModNormal}(y|\mu,\sigma,\lambda)
=
\frac{\lambda}{\sqrt{\pi}}
\
\exp \left(\frac{\lambda}{2} \left(2\mu + \lambda \sigma^2 - 2y\right)\right) \erfc\left(\frac{\mu + \lambda\sigma^2 - y}{\sqrt{2}\sigma}\right)
.
\]

\pitem{y}{exp\_mod\_normal}{mu,sigma,lambda}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{exp\_mod\_normal\_log}{reals \farg{y}, reals
    \farg{mu}, reals \farg{sigma}, \newline reals \farg{lambda}}{The
    log of the exponentially modified normal density of \farg{y} given
    location \farg{mu}, scale \farg{sigma}, and shape \farg{lambda}}
%
  \fitem{real}{exp\_mod\_normal\_cdf}{reals \farg{y}, reals \farg{mu},
    reals \farg{sigma}, reals \farg{lambda}}{The
    exponentially modified normal cumulative distribution function of \farg{y} 
    given location \farg{mu}, scale \farg{sigma}, and shape \farg{lambda}}
%
  \fitem{real}{exp\_mod\_normal\_cdf\_log}{reals \farg{y}, reals \farg{mu},
    reals \farg{sigma}, reals \farg{lambda}}{The log of the
    exponentially modified normal cumulative distribution function of \farg{y} 
    given location \farg{mu}, scale \farg{sigma}, and shape \farg{lambda}}
%
  \fitem{real}{exp\_mod\_normal\_ccdf\_log}{reals \farg{y}, reals \farg{mu},
    reals \farg{sigma}, reals \farg{lambda}}{The log of the
    exponentially modified normal complementary cumulative distribution 
    function of \farg{y} given location \farg{mu}, scale \farg{sigma}, and shape \farg{lambda}}
\end{description}
%
\begin{description}
\fitem{real}{exp\_mod\_normal\_rng}{real \farg{mu}, real \farg{sigma},
real \farg{lambda}}{Generate a exponentially modified normal variate 
with location \farg{mu}, scale \farg{sigma}, and shape \farg{lambda}; 
may only be used in generated quantities block}
\end{description}

\section{Skew Normal Distribution}

\subsubsection{Probabilty Density Function}

If $\mu \in \reals$, $\sigma \in \posreals$, and $\alpha \in \reals$,
then for $y \in \reals$,
\[
\distro{SkewNormal}(y|\mu,\sigma,\alpha)
=
\frac{1}{\sigma\sqrt{2\pi}}
\
\exp\left( - \, \frac{1}{2}
           \left(  \frac{y - \mu}{\sigma} \right)^2
    \right)
\
\left(1 + \erf\left( \alpha\left(\frac{y - \mu}{\sigma\sqrt{2}}\right)\right)\right)
.
\]

\pitem{y}{skew\_normal}{mu,sigma,alpha}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{skew\_normal\_log}{reals \farg{y}, reals \farg{mu}, reals
    \farg{sigma}, reals \farg{alpha}}{The log of the skew normal density 
	of \farg{y} given location \farg{mu}, scale \farg{sigma}, and 
	shape \farg{alpha}}
%
\fitem{real}{skew\_normal\_cdf}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}, reals \farg{alpha}}{The skew normal
  distribution function of \farg{y} given location \farg{mu}, scale
  \farg{sigma}, and shape \farg{alpha}}
%
\fitem{real}{skew\_normal\_cdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}, reals \farg{alpha}}{The log of the skew normal cumulative
  distribution function of \farg{y} given location \farg{mu}, scale
  \farg{sigma}, and shape \farg{alpha}}
%
\fitem{real}{skew\_normal\_ccdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}, reals \farg{alpha}}{The log of the skew normal complementary 
   cumulative distribution function of \farg{y} given location \farg{mu}, scale
  \farg{sigma}, and shape \farg{alpha}}
\end{description}
%
\begin{description}
\fitem{real}{skew\_normal\_rng}{real \farg{mu}, real \farg{sigma},
  real \farg{alpha}}{Generate a skew normal variate with location
  \farg{mu}, scale \farg{sigma}, and shape \farg{alpha}; may only be used in
  generated quantities block}
\end{description}


\section{Student-$t$ Distribution}

\subsubsection{Probability Density Function}

If $\nu \in \posreals$, $\mu \in \reals$, and $\sigma \in \posreals$,
then for $y \in \reals$,
\[
\distro{StudentT}(y|\nu,\mu,\sigma)
=
\frac{\Gamma\left((\nu + 1)/2\right)}
     {\Gamma(\nu/2)}
\
\frac{1}{\sqrt{\nu \pi} \ \sigma}
\
\left(
1 + \frac{1}{\nu} \left(\frac{y - \mu}{\sigma}\right)^2
\right)^{-(\nu + 1)/2}
\! .
\]

\pitem{y}{student\_t}{nu,mu,sigma}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{student\_t\_log}{reals \farg{y}, reals \farg{nu}, reals
    \farg{mu}, reals \farg{sigma}}{The log of the Student-$t$ density of \farg{y}
    given degrees of freedom \farg{nu}, location \farg{mu}, and scale
    \farg{sigma}}
%
  \fitem{real}{student\_t\_cdf}{reals \farg{y}, reals \farg{nu}, reals
    \farg{mu}, reals \farg{sigma}}{The Student-$t$ cumulative
    distribution function of \farg{y}
    given degrees of freedom \farg{nu}, location \farg{mu}, and scale
    \farg{sigma}}
%
  \fitem{real}{student\_t\_cdf\_log}{reals \farg{y}, reals \farg{nu}, reals
    \farg{mu}, reals \farg{sigma}}{The log of the Student-$t$ cumulative
    distribution function of \farg{y}
    given degrees of freedom \farg{nu}, location \farg{mu}, and scale
    \farg{sigma}}
%
  \fitem{real}{student\_t\_ccdf\_log}{reals \farg{y}, reals \farg{nu}, reals
    \farg{mu}, reals \farg{sigma}}{The log of the Student-$t$ complementary 
    cumulative distribution function of \farg{y} given degrees of freedom 
    \farg{nu}, location \farg{mu}, and scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{student\_t\_rng}{real \farg{nu}, real \farg{mu}, real
  \farg{sigma}}{Generate a Student-$t$ variate with degrees of freedom 
\farg{nu}, location \farg{mu}, and scale \farg{sigma}; may only be used in
  generated quantities block}
\end{description}



\section{Cauchy Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\sigma \in \posreals$, then for $y \in \reals$,
\[
\distro{Cauchy}(y|\mu,\sigma)
= 
\frac{1}{\pi \sigma}
\
\frac{1}{1 + \left((y - \mu)/\sigma\right)^2}
.
\]

\pitem{y}{cauchy}{mu,sigma}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{cauchy\_log}{reals \farg{y}, reals \farg{mu}, reals
 \farg{sigma}}{ The log of the Cauchy density of \farg{y} given location
 \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{cauchy\_cdf}{reals \farg{y}, reals \farg{mu}, reals
 \farg{sigma}}{ The Cauchy cumulative distribution function of \farg{y} given 
  location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{cauchy\_cdf\_log}{reals \farg{y}, reals \farg{mu}, reals
 \farg{sigma}}{ The log of the Cauchy cumulative distribution function 
	of \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{cauchy\_ccdf\_log}{reals \farg{y}, reals \farg{mu}, reals
 \farg{sigma}}{ The log of the Cauchy complementary cumulative distribution 
  function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{cauchy\_rng}{real \farg{mu}, real \farg{sigma}}{Generate a Cauchy
  variate with location \farg{mu} and scale \farg{sigma}; may only be used in
  generated quantities block}
\end{description}


\section{Double Exponential (Laplace) Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\sigma \in \posreals$, then for $y \in \reals$, 
\[
\distro{DoubleExponential}(y|\mu,\sigma)
= \frac{1}{2\sigma} 
  \exp \left( - \, \frac{|y - \mu|}{\sigma} \right)
.
\]

\pitem{y}{double\_exponential}{mu,sigma}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{double\_exponential\_log}{reals \farg{y}, reals \farg{mu},
reals \farg{sigma}}{ The log of the double exponential density of \farg{y} given
location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{double\_exponential\_cdf}{reals \farg{y}, reals \farg{mu},
reals \farg{sigma}}{ The double exponential cumulative distribution
function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{double\_exponential\_cdf\_log}{reals \farg{y}, reals \farg{mu},
reals \farg{sigma}}{ The log of the double exponential cumulative distribution
function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{double\_exponential\_ccdf\_log}{reals \farg{y}, reals \farg{mu},
reals \farg{sigma}}{ The log of the double exponential complementary cumulative distribution
function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{double\_exponential\_rng}{real \farg{mu}, real
  \farg{sigma}}{Generate a double exponential variate with location
  \farg{mu} and scale \farg{sigma}; may only be used in generated 
  quantities block}
\end{description}


\section{Logistic Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\sigma \in \posreals$, then for $y \in \reals$,
\[
\distro{Logistic}(y|\mu,\sigma)
=
\frac{1}{\sigma}
\
\exp\!\left( - \, \frac{y - \mu}{\sigma} \right)
\
\left(1 + \exp \!\left( - \, \frac{y - \mu}{\sigma} \right) \right)^{\!-2}
\! .
\]


\pitem{y}{logistic}{mu,sigma}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{logistic\_log}{reals \farg{y}, reals \farg{mu},
reals \farg{sigma}}{ The log of the logistic density of \farg{y} given
location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{logistic\_cdf}{reals \farg{y}, reals \farg{mu},
  reals \farg{sigma}}{ The logistic cumulative distribution function of 
  \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{logistic\_cdf\_log}{reals \farg{y}, reals \farg{mu},
  reals \farg{sigma}}{ The log of the logistic cumulative distribution 
  function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{logistic\_ccdf\_log}{reals \farg{y}, reals \farg{mu},
  reals \farg{sigma}}{ The log of the logistic complementary cumulative 
  distribution function of \farg{y} given location \farg{mu} and scale 
  \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{logistic\_rng}{real \farg{mu}, real
  \farg{sigma}}{Generate a logistic variate with location \farg{mu}
  and scale \farg{sigma}; may only be used in generated quantities block}
\end{description}


\section{Gumbel Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\beta \in \posreals$, then for $y \in \reals$,
\[
\distro{Gumbel}(y|\mu,\beta)
=
\frac{1}{\beta}
\
\exp\left(-\frac{y-\mu}{\beta}-\exp\left(-\frac{y-\mu}{\beta}\right)\right)
.
\]

\pitem{y}{gumbel}{mu,beta}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{gumbel\_log}{reals \farg{y}, reals \farg{mu}, reals
    \farg{beta}}{The log of the gumbel density of \farg{y} given location 
    \farg{mu} and scale \farg{beta}}
%
\fitem{real}{gumbel\_cdf}{reals \farg{y}, reals \farg{mu}, reals
  \farg{beta}}{The gumbel cumulative distribution function of \farg{y}
  given location \farg{mu} and scale \farg{beta}}
%
\fitem{real}{gumbel\_cdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{beta}}{The log of the gumbel cumulative distribution function of \farg{y}
  given location \farg{mu} and scale \farg{beta}}
%
\fitem{real}{gumbel\_ccdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{beta}}{The log of the gumbel complementary cumulative distribution 
   function of \farg{y} given location \farg{mu} and scale \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{gumbel\_rng}{real \farg{mu}, real
  \farg{beta}}{Generate a gumbel variate with location \farg{mu}
  and scale \farg{beta}; may only be used in generated quantities block}
\end{description}


\chapter{Positive Continuous Distributions}

\noindent
The positive continuous probability functions have support on the
positive real numbers.


\section{Lognormal Distribution}\label{lognormal.section}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\sigma \in \posreals$, then for $y \in
\posreals$, 
\[
\distro{LogNormal}(y|\mu,\sigma)
=
\frac{1}{\sqrt{2 \pi} \ \sigma}
\,
\frac{1}{y}
\
\exp \! \left(
       - \, \frac{1}{2}
       \, \left( \frac{\log y - \mu}{\sigma} \right)^2
     \right)
.
\]

\pitem{y}{lognormal}{mu,sigma}


\subsubsection{Stan Functions}

\begin{description}
 \fitem{real}{lognormal\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The log of the lognormal density of \farg{y} given location
  \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{lognormal\_cdf}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The cumulative lognormal distribution function of \farg{y}
  given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{lognormal\_cdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The log of the lognormal cumulative distribution fucntion 
   of \farg{y} given location \farg{mu} and scale \farg{sigma}}
%
\fitem{real}{lognormal\_ccdf\_log}{reals \farg{y}, reals \farg{mu}, reals
  \farg{sigma}}{The log of the lognormal complementary cumulative distribution 
  function of \farg{y} given location \farg{mu} and scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{lognormal\_rng}{real \farg{mu}, real
  \farg{beta}}{Generate a lognormal variate with location \farg{mu}
  and scale \farg{sigma}; may only be used in generated quantities block}
\end{description}


\section{Chi-Square Distribution}

\subsubsection{Probability Density Function}

If $\nu \in \posreals$, then for $y \in \posreals$,
\[
\distro{ChiSquare}(y|\nu)
=
\frac{2^{-\nu/2}}
    {\Gamma(\nu / 2)}
\,
y^{\nu/2 - 1}
\,
\exp \! \left( -\, \frac{1}{2} \, y \right)
.
\]

\pitem{y}{chi\_square}{nu}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{chi\_square\_log}{reals \farg{y}, reals \farg{nu}}{The
  log of the Chi-square density of \farg{y} given degrees of freedom
  \farg{nu}}
%
\fitem{real}{chi\_square\_cdf}{reals \farg{y}, reals \farg{nu}}{The
   Chi-square cumulative distribution function of \farg{y} given degrees 
   of freedom \farg{nu}}
%
\fitem{real}{chi\_square\_cdf\_log}{reals \farg{y}, reals \farg{nu}}{The 
   log of the Chi-square cumulative distribution function of 
   \farg{y} given degrees of freedom \farg{nu}}
%
\fitem{real}{chi\_square\_ccdf\_log}{reals \farg{y}, reals \farg{nu}}{The 
   log of the complementary Chi-square cumulative distribution 
   function of \farg{y} given degrees of freedom \farg{nu}}
\end{description}
%
\begin{description}
\fitem{real}{chi\_square\_rng}{real \farg{nu}}{Generate a Chi-square
  variate with degrees of freedom \farg{nu}; may only be used in
  generated quantities block}
\end{description}



\section{Inverse Chi-Square Distribution}

\subsubsection{Probability Density Function}

If $\nu \in \posreals$, then for $y \in \posreals$,
\[
\distro{InvChiSquare}(y|\nu)
= 
\frac{2^{-\nu/2}}
   {\Gamma(\nu / 2)}
\,
y^{-(\nu/2 - 1)}
\,
\exp\! \left( \! - \, \frac{1}{2} \, \frac{1}{y} \right)
.
\]

\pitem{y}{inv\_chi\_square}{nu}


\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{inv\_chi\_square\_log}{reals \farg{y}, reals
  \farg{nu}}{The log of the inverse Chi-square density of \farg{y} given
  degrees of freedom \farg{nu}}
%
\fitem{real}{inv\_chi\_square\_cdf}{reals \farg{y}, reals
  \farg{nu}}{The inverse Chi-squared cumulative distribution function of 
  \farg{y} given degrees of freedom \farg{nu}}
%
\fitem{real}{inv\_chi\_square\_cdf\_log}{reals \farg{y}, reals
  \farg{nu}}{The log of the inverse Chi-squared cumulative distribution 
   function of \farg{y} given degrees of freedom \farg{nu}}
%
\fitem{real}{inv\_chi\_square\_ccdf\_log}{reals \farg{y}, reals
  \farg{nu}}{The log of the inverse Chi-squared complementary cumulative 
  distribution function of \farg{y} given degrees of freedom \farg{nu}}
\end{description}
%
\begin{description}
\fitem{real}{inv\_chi\_square\_rng}{real \farg{nu}}{Generate an
  inverse Chi-squared variate with degrees of freedom \farg{nu}; 
may only be used in generated quantities block}
\end{description}


\section{Scaled Inverse Chi-Square Distribution}

\subsubsection{Probability Density Function}

If $\nu \in \posreals$ and $\sigma \in \posreals$, then for $y \in
\posreals$,
\[
\distro{ScaledInvChiSquare}(y|\nu,\sigma)
= 
\frac{(\nu / 2)^{\nu/2}}
     {\Gamma(\nu / 2)}
\,
\sigma^{\nu}
\,
y^{-(\nu/2 + 1)}
\,
\exp \! \left( \!
   - \, \frac{1}{2} \, \nu \, \sigma^2 \, \frac{1}{y}
\right)
.
\]


\pitem{y}{scaled\_inv\_chi\_square}{nu,sigma}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{scaled\_inv\_chi\_square\_log}{reals \farg{y}, reals
    \farg{nu}, reals \farg{sigma}}{The log of the scaled inverse Chi-square
    density of \farg{y} given degrees of freedom \farg{nu} and scale
    \farg{sigma}}
\end{description}
%
\begin{description}
  \fitem{real}{scaled\_inv\_chi\_square\_cdf}{reals \farg{y}, reals
    \farg{nu}, reals \farg{sigma}}{The scaled inverse Chi-square
    cumulative distribution function
    of \farg{y} given degrees of freedom \farg{nu} and scale
    \farg{sigma}}
%
  \fitem{real}{scaled\_inv\_chi\_square\_cdf\_log}{reals \farg{y}, reals
    \farg{nu}, reals \farg{sigma}}{The log of the scaled inverse Chi-square
    cumulative distribution function
    of \farg{y} given degrees of freedom \farg{nu} and scale
    \farg{sigma}}
%
  \fitem{real}{scaled\_inv\_chi\_square\_ccdf\_log}{reals \farg{y}, reals
    \farg{nu}, reals \farg{sigma}}{The log of the scaled inverse Chi-square
    complementary cumulative distribution function
    of \farg{y} given degrees of freedom \farg{nu} and scale
    \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{scaled\_inv\_chi\_square\_rng}{real \farg{nu}, real
  \farg{sigma}}{Generate a scaled inverse Chi-squared variate with degrees 
of freedom \farg{nu} and scale \farg{sigma}; may only be used in generated 
quantities block}
\end{description}


\section{Exponential Distribution}

\subsubsection{Probability Density Function}

If $\beta \in \posreals$, then for $y \in \posreals$,
\[
\distro{Exponential}(y|\beta)
= 
\beta \, 
\exp ( - \beta \, y )
.
\]

\pitem{y}{exponential}{beta}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{exponential\_log}{reals \farg{y}, reals \farg{beta}}{The
    log of the exponential density of \farg{y} given inverse scale \farg{beta}}
%
\fitem{real}{exponential\_cdf}{reals \farg{y}, reals \farg{beta}}{The
  exponential cumulative distribution function of \farg{y} given inverse scale
  \farg{beta}}
%
\fitem{real}{exponential\_cdf\_log}{reals \farg{y}, reals \farg{beta}}{The
  log of the exponential cumulative distribution function of \farg{y} given 
  inverse scale \farg{beta}}
%
\fitem{real}{exponential\_ccdf\_log}{reals \farg{y}, reals \farg{beta}}{The
  log of the exponential complementary cumulative distribution function 
  of \farg{y} given inverse scale \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{exponential\_rng}{real \farg{beta}}{Generate an
  exponential variate with inverse scale \farg{beta}; may only be used in 
  generated quantities block}
\end{description}


\section{Gamma Distribution}

\subsubsection{Probability Density Function}

If $\alpha \in \posreals$ and $\beta \in \posreals$, then for $y \in
\posreals$,
\[
\distro{Gamma}(y|\alpha,\beta)
=
\frac{\beta^{\alpha}}
     {\Gamma(\alpha)}
\,
y^{\alpha - 1}
\exp(-\beta \, y)
.
\]


\pitem{y}{gamma}{alpha,beta}

\subsubsection{Stan Functions}

\begin{description}
 \fitem{real}{gamma\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the gamma density of \farg{y} given shape
  \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{gamma\_cdf}{reals \farg{y}, reals \farg{alpha}, reals
   \farg{beta}}{The cumulative gamma distribution function of \farg{y} given shape
   \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{gamma\_cdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
   \farg{beta}}{The log of the cumulative gamma distribution function of \farg{y} given shape
   \farg{alpha} and inverse scale \farg{beta}}
%
 \fitem{real}{gamma\_ccdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
   \farg{beta}}{The log of the complementary cumulative gamma distribution function of 
   \farg{y} given shape \farg{alpha} and inverse scale \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{gamma\_rng}{real \farg{alpha}, real
  \farg{beta}}{Generate a gamma variate with shape
  \farg{alpha} and inverse scale \farg{beta}; may only be used in generated 
quantities block}
\end{description}


\section{Inverse Gamma Distribution}

\subsubsection{Probability Density Function}

If $\alpha \in \posreals$ and $\beta \in \posreals$, then for $y \in
\posreals$,
\[
\distro{InvGamma}(y|\alpha,\beta)
= 
\frac{\beta^{\alpha}}
     {\Gamma(\alpha)}
\
y^{-(\alpha + 1)}
\,
\exp \! \left( \! - \beta \, \frac{1}{y} \right)
.
\]

\pitem{y}{inv\_gamma}{alpha,beta}


\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{inv\_gamma\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the inverse gamma density of \farg{y} given shape
  \farg{alpha} and scale \farg{beta}}
%
\fitem{real}{inv\_gamma\_cdf}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The inverse gamma cumulative distribution function of \farg{y} 
  given shape \farg{alpha} and scale \farg{beta}}
%
\fitem{real}{inv\_gamma\_cdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the inverse gamma cumulative distribution function 
  of \farg{y} given shape \farg{alpha} and scale \farg{beta}}
%
\fitem{real}{inv\_gamma\_ccdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the inverse gamma complementary cumulative distribution 
  function of \farg{y} given shape \farg{alpha} and scale \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{inv\_gamma\_rng}{real \farg{alpha}, real
  \farg{beta}}{Generate an inverse gamma variate with shape
  \farg{alpha} and scale \farg{beta}; may only be used in generated 
quantities block}
\end{description}


\section{Weibull Distribution}

\subsubsection{Probability Density Function}

If $\alpha \in \posreals$ and $\sigma \in [0,\infty)$, then for $y \in
\posreals$, 
\[
\distro{Weibull}(y|\alpha,\sigma)
= 
\frac{\alpha}{\sigma}
\,
\left( \frac{y}{\sigma} \right)^{\alpha - 1}
\,
\exp \! \left( \! - \left( \frac{y}{\sigma} \right)^{\alpha}  \right)
.
\]

\pitem{y}{weibull}{alpha,sigma}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{weibull\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{sigma}}{The log of the Weibull density of \farg{y} given shape
  \farg{alpha} and scale \farg{sigma}}
%
\fitem{real}{weibull\_cdf}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{sigma}}{The Weibull cumulative distribution function of \farg{y} given
  shape \farg{alpha} and scale \farg{sigma}}
%
\fitem{real}{weibull\_cdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{sigma}}{The log of the Weibull cumulative distribution function of 
  \farg{y} given shape \farg{alpha} and scale \farg{sigma}}
%
\fitem{real}{weibull\_ccdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{sigma}}{The log of the Weibull complementary cumulative 
  distribution function of \farg{y} given shape \farg{alpha} and scale 
  \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{weibull\_rng}{real \farg{alpha}, real
  \farg{sigma}}{Generate a weibull variate with shape
  \farg{alpha} and scale \farg{sigma}; may only be used in generated 
quantities block}
\end{description}

\chapter{Non-negative Continuous Distributions}
\noindent
The non-negative continuous probability functions have support on the
non-negative real numbers.

\section{Rayleigh Distribution}

\subsubsection{Probability Density Function}
 If $\sigma \in \posreals$, then for $y \in [0,\infty)$,
\[
\distro{Rayleigh}(y|\sigma)
=
\frac{y}{\sigma^2} \exp(-y^2 / 2\sigma^2)
\!.
\]

\pitem{y}{rayleigh}{sigma}

\subsubsection{Stan Functions}
\begin{description}
\fitem{real}{rayleigh\_log}{reals \farg{y}, reals \farg{sigma}}{The log of the Rayleigh
 ensity of \farg{y} given scale \farg{sigma}}
%
\fitem{real}{rayleigh\_cdf}{real \farg{y}, real
\farg{sigma}}{The Rayleigh cumulative distribution of \farg{y} given scale \farg{sigma}}
%
\fitem{real}{rayleigh\_cdf\_log}{real \farg{y}, real \farg{sigma}}{The log of the
 Rayleigh cumulative distribution of \farg{y} given scale \farg{sigma}}
%
\fitem{real}{rayleigh\_ccdf\_log}{real \farg{y}, real
\farg{sigma}}{The log of the Rayleigh complementary cumulative distribution 
 of \farg{y} given scale \farg{sigma}}
\end{description}
%
\begin{description}
\fitem{real}{rayleigh\_rng}{real
  \farg{sigma}}{Generate a Rayleigh variate with scale
  \farg{sigma}; may only be used in generated 
quantities block}
\end{description}

\chapter{Positive Lower-Bounded Probabilities}

\noindent
The positive lower-bounded probabilities have support on real values
above some positive minimum value.


\section{Pareto Distribution}

\subsubsection{Probability Density Function}

If $y_0 \in \posreals$ and $\alpha \in \posreals$, then for
$y \in \posreals$,
\[
\distro{Pareto}(y|y_0,\alpha)
=
\alpha 
\ y_0
\, \left( \frac{1}{y} \right)^{\!\alpha+1}
\! .
\]

\pitem{y}{pareto}{y\_min,alpha}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{pareto\_log}{reals \farg{y}, reals \farg{y\_min}, reals
    \farg{alpha}}{The log of the Pareto density of \farg{y} given
    positive minimum value \farg{y\_min} and shape \farg{alpha}}
%
  \fitem{real}{pareto\_cdf}{reals \farg{y}, reals \farg{y\_min}, reals
    \farg{alpha}}{The Pareto cumulative distribution function of \farg{y} given
    positive minimum value \farg{y\_min} and shape \farg{alpha}}
%
  \fitem{real}{pareto\_cdf\_log}{reals \farg{y}, reals \farg{y\_min}, reals
    \farg{alpha}}{The log of the Pareto cumulative distribution function of 
    \farg{y} given positive minimum value \farg{y\_min} and shape \farg{alpha}}
%
  \fitem{real}{pareto\_ccdf\_log}{reals \farg{y}, reals \farg{y\_min}, reals
    \farg{alpha}}{The log of the Pareto complementary cumulative distribution
    function of \farg{y} given positive minimum value \farg{y\_min} and shape 
    \farg{alpha}}
\end{description}
%
\begin{description}
\fitem{real}{pareto\_rng}{real \farg{y\_min}, real
  \farg{alpha}}{Generate a Pareto variate with positive minimum value 
  \farg{y\_min} and shape \farg{alpha}; may only be used in generated 
  quantities block}
\end{description}


\chapter{Continuous Distributions on $[0,1]$}

\noindent
The continuous distributions with outcomes in the interval $[0,1]$ are
used to characterized bounded quantities, including probabilities.


\section{Beta Distribution}

\subsubsection{Probability Density Function}

If $\alpha \in \posreals$ and $\beta \in \posreals$, then for $\theta
\in (0,1)$,
\[
\distro{Beta}(\theta|\alpha,\beta)
=
\frac{1}{\Betafun(\alpha,\beta)}
\,
\theta^{\alpha - 1}
\,
(1 - \theta)^{\beta - 1}
,
\] 
where the beta function $\Betafun()$ is as defined in
\refsection{betafun}.  If $\theta = 0$ or $\theta = 1$, then
the log probability is $-\infty$.

\pitem{theta}{beta}{alpha,beta}

\subsubsection{Stan Functions}

\begin{description}
%
  \fitem{real}{beta\_log}{reals \farg{theta}, reals \farg{alpha}, reals
    \farg{beta}}{The log of the beta density of \code{theta} in $[0,1]$
    given positive prior successes (plus one)
    \farg{alpha} and prior failures (plus one) \farg{beta}}
%
  \fitem{real}{beta\_cdf}{reals \farg{theta}, reals \farg{alpha}, reals
    \farg{beta}}{The beta cumulative distribution function of \code{theta} 
    in $[0,1]$ given positive prior successes (plus one)
    \farg{alpha} and prior failures (plus one) \farg{beta}}
%
  \fitem{real}{beta\_cdf\_log}{reals \farg{theta}, reals \farg{alpha}, reals
    \farg{beta}}{The log of the beta cumulative distribution function of 
    \code{theta} in $[0,1]$ given positive prior successes (plus one)
    \farg{alpha} and prior failures (plus one) \farg{beta}}
%
  \fitem{real}{beta\_ccdf\_log}{reals \farg{theta}, reals \farg{alpha}, reals
    \farg{beta}}{The log of the beta complementary cumulative distribution 
    function of \code{theta} in $[0,1]$ given positive prior successes (plus one)
    \farg{alpha} and prior failures (plus one) \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{beta\_rng}{real \farg{alpha}, real
  \farg{beta}}{Generate a beta variate with positive prior successes (plus one)
    \farg{alpha} and prior failures (plus one) \farg{beta}; may only
    be used in generated quantities block}
\end{description}


\chapter{Circular Distributions}

\noindent
Circular distributions are defined for finite values \farg{y} in any interval of length $2\pi$.


\section{Von Mises Distribution}

\subsubsection{Probability Density Function}

If $\mu \in \reals$ and $\kappa \in \posreals$, then for $y \in
\reals$,
\[
\distro{VonMises}(y|\mu,\kappa)
=
\frac{\exp(\kappa\cos(y-\mu))}{2\pi I_0(\kappa)}
\!.
\]

\pitem{y}{von\_mises}{mu,kappa}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{von\_mises\_log}{reals \farg{y}, reals \farg{mu}, reals
    \farg{kappa}}{The log of the von mises density of \farg{y} given
    location \farg{mu} and scale \farg{kappa}}
\end{description}


\chapter{Bounded Continuous Probabilities}

\noindent
The bounded continuous probabilities have support on a finite interval
of real numbers.



\section{Uniform Distribution}

\subsubsection{Probability Density Function}

If $\alpha \in \reals$ and $\beta \in (\alpha,\infty)$, then for $y
\in [\alpha,\beta]$,
\[
\distro{Uniform}(y|\alpha,\beta)
= 
\frac{1}{\beta - \alpha}
.
\]

\pitem{y}{uniform}{alpha,beta}

\subsubsection{Stan Functions}

\begin{description}
\fitem{real}{uniform\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the uniform density of \farg{y} given lower bound
  \farg{alpha} and upper bound \farg{beta}}
%
\fitem{real}{uniform\_cdf}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The uniform cumulative distribution function of \farg{y} given 
  lower bound \farg{alpha} and upper bound \farg{beta}}
%
\fitem{real}{uniform\_cdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the uniform cumulative distribution function of 
  \farg{y} given lower bound \farg{alpha} and upper bound \farg{beta}}
%
\fitem{real}{uniform\_ccdf\_log}{reals \farg{y}, reals \farg{alpha}, reals
  \farg{beta}}{The log of the uniform complementary cumulative distribution 
  function of \farg{y} given lower bound \farg{alpha} and upper bound 
  \farg{beta}}
\end{description}
%
\begin{description}
\fitem{real}{uniform\_rng}{real \farg{alpha}, real
  \farg{beta}}{Generate a uniform variate with lower bound
  \farg{alpha} and upper bound \farg{beta}; may only
    be used in generated quantities block}
\end{description}



\chapter{Distributions over Unbounded Vectors}

\noindent
The unbounded vector probability distributions have support on all of
$\reals^K$ for some fixed $K$.


\section{Multivariate Normal Distribution}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\mu \in \reals^K$, and $\Sigma \in \reals^{K \times
  K}$ is symmetric and positive definite, then for $y \in \reals^K$,
\[
\distro{MultiNormal}(y|\mu,\Sigma)
=
\frac{1}{\left( 2 \pi \right)^{K/2}}
\
\frac{1}{\sqrt{|\Sigma|}}
\
\exp \! \left( \!
- 
\frac{1}{2}
(y - \mu)^{\top} \, \Sigma^{-1} \, (y - \mu)
\right)
\! ,
\]
%
where $|\Sigma|$ is the absolute determinant of $\Sigma$.

\pitem{y}{multi\_normal}{mu,Sigma}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{multi\_normal\_log}{vector \farg{y}, vector \farg{mu},
  matrix \farg{Sigma}}{The log of the multivariate normal density of vector \farg{y}
 given location \farg{mu} and covariance matrix \farg{Sigma}}
%
\end{description}
%
\begin{description}
\fitem{vector}{multi\_normal\_rng}{vector \farg{mu}, matrix
  \farg{Sigma}}{Generate a multivariate normal variate with location
  \farg{mu} and covariance matrix \farg{Sigma}; may only be used in 
generated quantities block}
\end{description}


\section{Multivariate Normal Distribution, Precision Parameterization}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\mu \in \reals^K$, and $\Omega \in \reals^{K \times
  K}$ is symmetric and positive definite, then for $y \in \reals^K$,
%
\[
\distro{MultiNormalPrecision}(y|\mu,\Omega)
= \distro{MultiNormal}(y|\mu,\Sigma^{-1})
\]

\pitem{y}{multi\_norm\_prec}{mu,Omega}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{multi\_normal\_prec\_log}{vector \farg{y}, vector
  \farg{mu}, matrix \farg{Omega}}{The log of the multivariate normal density of vector
  \farg{y} given location \farg{mu} and positive definite precision
  matrix \farg{Omega}}
%
\end{description}



\section{Multivariate Normal Distribution, Cholesky Parameterization}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\mu \in \reals^K$, and $L \in \reals^{K \times K}$ is lower
triangular and such that $LL^{\top}$ is positive definite, then for $y
\in \reals^K$,
\[
\distro{MultiNormalCholesky}(y|\mu,L)
=
\distro{MultiNormal}(y|\mu,LL^{\top}).
\]


\pitem{y}{multi\_normal\_cholesky}{mu,L}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{multi\_normal\_cholesky\_log}{vector \farg{y}, vector
  \farg{mu}, matrix \farg{L}}{The log of the multivariate normal density of vector
  \farg{y} given location \farg{mu} and lower-triangular Cholesky
  factor of the covariance matrix \farg{L}}
%
\end{description}



\section{Multivariate Student-$t$ Distribution}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\nu \in \posreals$, $\mu \in \reals^K$, and $\Sigma
\in \reals^{K \times K}$ is symmetric and positive definite, then for
$y \in \reals^K$,
\[
\begin{array}{l}
\distro{MultiStudentT}(y|\nu,\mu,\Sigma)
\\[8pt]
\displaystyle
\hspace*{8pt}
=
\frac{1}{\pi^{K/2}}
\
\frac{1}{\nu^{K/2}}
\
\frac{\Gamma\!x\left((\nu + K)/2\right)}
     {\Gamma(\nu/2)}
\
\frac{1}{\sqrt{\left| \Sigma \right|}}
\
\left(
1 + \frac{1}{\nu} \, \left(y - \mu\right)^{\top} \, \Sigma^{-1} \, \left(y - \mu\right)
\right)^{-(\nu + K)/2}
\! .
\end{array}
\]
\vspace*{4pt}

\pitem{y}{multi\_student\_t}{nu,mu,Sigma}


\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{multi\_student\_t\_log}{vector \farg{y}, real \farg{nu},
  vector \farg{mu}, matrix \farg{Sigma}}{The log of the multivariate Student-$t$
  density of vector \farg{y} given degrees of freedom \farg{nu},
  location \farg{mu}, and scale matrix \farg{Sigma}}
%
\end{description}
%
\begin{description}
\fitem{vector}{multi\_student\_t\_rng}{real \farg{nu}, vector \farg{mu}, matrix
  \farg{Sigma}}{Generate a multivariate Student-$t$ variate with degrees
  of freedom \farg{nu}, location \farg{mu}, and scale matrix \farg{Sigma}; 
may only be used in generated quantities block}
\end{description}


\section{Gaussian Dynamic Linear Models}
\label{sec:guass-dynam-line}

A Gaussian Dynamic Linear model is defined as follows,
For $t \in 1, \dots, T$,
\[
  \begin{aligned}[t]
    y_{t} &\sim N(F' \theta_{t}, V) \\
    \theta_{t} &\sim N(G \theta_{t - 1}, W) \\
    \theta_{0} &\sim N(m_{0}, C_{0}) 
  \end{aligned}
\]
where $y$ is $n \times T$ matrix where rows are variables and columns
are observations. These functions calculate the log-likelihood of the
observations marginalizing over the latent states ($p(y | F, G, V, W,
m_{0}, C_{0})$).  This log-likelihood is system is calculated using
the the Kalman Filter.  If $V$ is diagonal, then a more efficient
algorithm which sequentially processes observations and avoids a
matrix inversions can be used \citep[Sec~6.4]{DurbinKoopman:2001}.

\pitem{y}{gaussian\_dlm\_obs}{F,G,V,W,m0,C0}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{gaussian\_dlm\_obs\_log}{vector \farg{y}, matrix \farg{F},
  matrix \farg{G}, matrix \farg{V}, \\ \hspace*{132pt} matrix \farg{W}, vector
  \farg{m0}, matrix \farg{C0}\vspace*{8pt}} {The log of the density of the
  Gaussian Dynamic Linear model with observation matrix \farg{y} in
  which rows are variables and columns are observations, design
  matrix \farg{F}, transition matrix \farg{G}, observation
  covariance matrix \farg{V}, system covariance matrix \farg{W}, and
  the initial state is distributed normal with mean \farg{m0} and
  covariance \farg{C0}.}
% 
%
\fitem{real}{gaussian\_dlm\_obs\_log}{vector \farg{y}, matrix \farg{F},
  matrix \farg{G}, vector \farg{V}, \\ \hspace*{132pt} matrix \farg{W}, vector \farg{m0},
  matrix \farg{C0}\vspace*{8pt}} {The log of the density of the Gaussian Dynamic
  Linear model with observation matrix \farg{y} in which rows are
  variables and columns are observations, design matrix \farg{F},
  transition matrix \farg{G}, observation covariance matrix with
  diagonal \farg{V}, system covariance matrix \farg{W}, and the
  initial state is distributed normal with mean \farg{m0} and
  covariance \farg{C0}.}
%
\end{description}


\chapter{Simplex Distributions}

\noindent
The simplex probabilities have support on the unit $K$-simplex for a
specified $K$.  A $K$-dimensional vector $\theta$ is a unit
$K$-simplex if $\theta_k \geq 0$ for $k \in \setlist{1,\ldots,K}$ and
$\sum_{k = 1}^K \theta_k = 1$.


\section{Dirichlet Distribution}

\subsubsection{Probability Density Function}

If $K \in \nats$ and $\alpha \in (\posreals)^{K}$, then for
$\theta \in \mbox{$K$-simplex}$, 
\[
\distro{Dirichlet}(\theta|\alpha)
= 
\frac{\Gamma \! \left( \sum_{k=1}^K \alpha_k \right)}
     {\prod_{k=1}^K \Gamma(\alpha_k)}
\
\prod_{k=1}^K \theta_k^{\alpha_k - 1}
.
\]

\pitem{theta}{dirichlet}{alpha}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{dirichlet\_log}{vector \farg{theta}, vector
    \farg{alpha}}{ The log of the Dirichlet density for simplex
    \farg{theta} given prior counts (plus one) \farg{alpha}}
\end{description}
%
\begin{description}
\fitem{vector}{dirichlet\_rng}{vector \farg{alpha}}{Generate a
  Dirichlet variate with prior counts (plus one) \farg{alpha}; 
may only be used in generated quantities block}
\end{description}


\chapter{Correlation Matrix Distributions}

\noindent
The correlation matrix distributions have support on the (Cholesky
factors of) correlation matrices.  A Cholesky factor $L$ for a $K
\times K$ covariance matrix of dimensions $K$ has rows of unit length
so that the diagonal of $L L^{\top}$ is the unit $K$-vector.


\section{LKJ Correlation Distribution}

\subsubsection{Probability Density Function}

For $\eta > 0$, if $\Sigma$ a positive-definite, symmetric matrix with
unit diagonal (i.e., a correlation matrix), then
%
\[
\distro{LkjCorr}(\Sigma|\eta)
\propto \det \left( \Sigma \right)^{(\eta - 1)}.
\]
%
The shape parameter $\eta$ can be interpreted like the shape parameter
of a symmetric beta distribution. If $\eta = 1$, then the density is
uniform over all correlation matrices of a given order. If $\eta > 1$,
the identity matrix is the modal correlation matrix, especially as
$\eta$ becomes large. For $0 < \eta < 1$, the density has a trough at
the identity matrix. See \citep{LewandowskiKurowickaJoe:2009} for
definitions.

\pitem{y}{lkj\_corr\_log}{eta}

\subsubsection{Stan Functions}

\begin{description}
%
  \fitem{real}{lkj\_corr\_log}{matrix \farg{y}, real
    \farg{eta}}{The log of the LKJ density for the correlation matrix
    \farg{y} given nonnegative shape \farg{eta}.}
%
\end{description}
\begin{description}
\fitem{matrix}{lkj\_corr\_rng}{int \farg{K}, real \farg{eta}}{Generate a
  LKJ random correlation matrix of order \farg{K} with shape \farg{eta};
  may only be used in generated quantities block}
\end{description}


% \section{Cholesky LKJ Correlation Distribution}

% \subsubsection{Probability Density Function}

% For $\eta > 0$, if $L$ is the Cholesky factor of a positive-definite
% matrix with unit diagonal (i.e., a correlation matrix), then
% \[
% \distro{LkjCholesky}(L|\eta) 
% \propto \det(L L^\top)^{(\eta - 1)} 
% = \det(L)^{(2 \eta - 2)}.
% \]
% See the previous section for details on interpreting the shape
% parameter $\eta$.

% \pitem{L}{lkj\_corr\_cholesky}{eta}

% \subsubsection{Stan Functions}

% \begin{description}
% %
%   \fitem{real}{lkj\_corr\_cholesky\_log}{matrix \farg{L}, real
%     \farg{eta}}{The log of the LKJ density for the lower-triangular
%     Cholesky factor \farg{L} of a correlation matrix given shape
%     \farg{eta}.}
% %
% \end{description}
% \begin{description}
% \fitem{matrix}{lkj\_corr\_cholesky\_rng}{int \farg{K}, real \farg{eta}}{
%   Generate a random Cholesky factor of a LKJ random correlation matrix
%   of order \farg{K} with shape \farg{eta}; may only be used in 
%   generated quantities block}
% \end{description}




\chapter{Covariance Matrix Distributions}

\noindent
The covariance matrix distributions have support on symmetric,
positive-definite $K \times K$ matrices.


\section{Wishart Distribution}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\nu \in (K-1,\infty)$, and $S \in \reals^{K \times K}$ is symmetric
and positive definite, then for symmetric and positive-definite $W \in
\reals^{K \times K}$,
\[
\distro{Wishart}(W|\nu,S)
=
\frac{1}{2^{\nu K / 2}}
\
\frac{1}{\Gamma_K \! \left( \frac{\nu}{2} \right)}
\
\left| S \right|^{-\nu/2}
\
\left| W \right|^{(\nu - K - 1)/2}
\
\exp \! \left(\frac{1}{2} \ \mbox{tr}\left( S^{-1} W \right) \right)
\! ,
\]
%
where $\mbox{tr}()$ is the matrix trace function, and $\Gamma_K()$ is
the multivariate Gamma function,
\[
\Gamma_K(x) = 
\frac{1}{\pi^{K(K-1)/4}}
\
\prod_{k=1}^K \Gamma \left( x + \frac{1 - k}{2} \right)
\!.
\]

\pitem{W}{wishart}{nu,Sigma}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{wishart\_log}{matrix \farg{W}, real \farg{nu}, matrix
 \farg{Sigma}}{The log of the Wishart density for positive-definite matrix
 \farg{W} given degrees of freedom \farg{nu} and scale matrix
 \farg{Sigma}}
%
\end{description}
%
\begin{description}
\fitem{matrix}{wishart\_rng}{real \farg{nu}, matrix \farg{Sigma}}{Generate a
  Wishart variate with degrees of freedom \farg{nu} and scale matrix
 \farg{Sigma}; may only be used in generated quantities block}
\end{description}


\section{Inverse Wishart Distribution}

\subsubsection{Probability Density Function}

If $K \in \nats$, $\nu \in (K-1,\infty)$, and $S \in \reals^{K \times
  K}$ is symmetric and positive definite, then for symmetric and
positive-definite $W \in \reals^{K \times K}$,
\[
\distro{InvWishart}(W|\nu,S)
= 
\frac{1}{2^{\nu K / 2}}
\
\frac{1}{\Gamma_K \! \left( \frac{\nu}{2} \right)}
\
\left| S \right|^{\nu/2}
\
\left| W \right|^{-(\nu - K - 1)/2}
\
\exp \! \left( 
- \frac{1}{2}
\
\mbox{tr}(SW^{-1})
\right)
\! .
\]

\pitem{W}{inv\_wishart}{nu,Sigma}

\subsubsection{Stan Functions}

\begin{description}
%
\fitem{real}{inv\_wishart\_log}{matrix \farg{W}, real \farg{nu}, matrix
 \farg{Sigma}}{The log of the inverse Wishart density for positive-definite matrix
 \farg{W} given degrees of freedom \farg{nu} and scale matrix
 \farg{Sigma}}
%
\end{description}
%
\begin{description}
\fitem{matrix}{inv\_wishart\_rng}{real \farg{nu}, matrix
  \farg{Sigma}}{Generate an inverse Wishart variate with degrees of 
freedom \farg{nu} and scale matrix
 \farg{Sigma}; may only be used in generated quantities block}
\end{description}

\section{LKJ Covariance Distribution}

\pitem{W}{lkj\_cov\_log}{mu,sigma,eta}

\subsubsection{Stan Functions}

\begin{description}
  \fitem{real}{lkj\_cov\_log}{matrix \farg{W}, vector \farg{mu},
    vector \farg{sigma}, real \farg{eta}}{The log of the LKJ density
    for covariance matrix \farg{W} is the sum of log of the lognormal
    density of the standard deviations given location vector \farg{mu}
    and scale vector \farg{sigma} and the log of the lkj\_corr density
    of the correlation matrix given shape \farg{eta}.  See the next
    section for details on the lkj\_corr density.}
\end{description}




