\appendix
\chapter{Summary of distributions}

\section{Distributions for data}

\subsection*{Binomial distribution}
If $X|\theta\sim Bin(k,\theta)$ then it has probability function
\[
f(x|\theta)=\begin{pmatrix}k\\x\end{pmatrix}\theta^x(1-\theta)^{k-x}
\,,\quad x=0,1,\ldots,k,
\]
where $k$ is a positive integer and $0<\theta<1$. Also, $E(X)=k\theta$
and $Var(X)=k\theta(1-\theta)$.

\subsection*{Exponential distribution}
If $X|\lambda\sim Exp(\lambda)$ then it has density
\[
f(x|\lambda)=\lambda e^{-\lambda x}\,,\quad x>0
\]
where $\lambda>0$. Also, $E(X)=1/\lambda$ and $Var(X)=1/\lambda^2$.

\subsection*{Gamma distribution}
If $X|\alpha,\lambda\sim Ga(\alpha,\lambda)$ then it has density
\[
f(x|\alpha,\lambda)=\frac{\lambda^\alpha x^{\alpha-1}e^{-\lambda x}}{\Gamma(\alpha)}\,,
\quad x>0,
\]
where $\alpha>0$ and $\lambda>0$. Also, $E(X)=\alpha/\lambda$ and
$Var(X)=\alpha/\lambda^2$.

\subsection*{Inverse Gaussian distribution}
If $X|\mu,\lambda\sim IG(\mu,\lambda)$ then it has density
\[
f(x|\mu,\lambda)=\frac{\sqrt\lambda}{\sqrt{2\pi x^3}}
\exp\left\{-\frac{\lambda(x-\mu)^2}{2\mu^2 x}\right\}\,,
\quad x>0,
\]
where $\mu>0$ and $\lambda>0$. Also, $E(X)=\mu$ and
$Var(X)=\mu^3/\lambda$.

\subsection*{Laplace distribution}
If $X|\mu,\sigma\sim La(\mu,\sigma^2)$ then it has density
\[
f(x|\mu,\sigma)=\frac{1}{\sqrt{2}\,\sigma}
\exp\left\{-\frac{\sqrt{2}|x-\mu|}{\sigma}\right\}\,,
\quad x>0,
\]
where $\mu\in\mathbb{R}$ and $\sigma>0$. Also, $E(X)=\mu$ and
$Var(X)=\sigma^2$.

\subsection*{Log-normal distribution}
If $X|\mu,\sigma\sim LN(\mu,\sigma^2)$ then it has density
\[
f(x|\mu,\sigma)=
\frac{1}{x\sigma\sqrt{2\pi}}
\exp\left\{-\frac{1}{2\sigma^2}(\log x-\mu)^2\right\},\quad x>0
\]
where $\mu\in\mathbb{R}$ and $\sigma>0$.  Also,
$E(X)=e^{\mu+\sigma^2/2}$,
$Var(X)=(e^{\sigma^2}-1)e^{2\mu+\sigma^2}$. Further $E(\log
X)=\mu$ and $Var(\log X)=\sigma^2$.

\subsection*{Negative binomial distribution}

If $X|\theta\sim NegBin(k,\theta)$ then it has probability function
\[
f(x|\theta)=\binom{x-1}{k-1}\theta^k(1-\theta)^{x-k},\quad x=k,k+1,\ldots~,
\]
where $k$ is a positive integer and $0<\theta<1$. Also $E(X)=k/\theta$
and $Var(X)=k(1-\theta)/\theta^2$.

\subsection*{Normal distribution}
If $X|\mu,\tau\sim N(\mu,1/\tau)$ then it has density
\[
f(x|\mu,\tau)=\left(\frac{\tau}{2\pi}\right)^{1/2}
\exp\left\{-\frac{\tau}{2}(x-\mu)^2\right\},\quad x\in\mathbb{R}
\]
where $\mu\in\mathbb{R}$ and $\tau>0$.  Also, $E(X)=\mu$ and
$Var(X)=1/\tau$. The distribution has the following quantiles
\begin{center}
\begin{tabular}{c|ccccc}
$ x $  & 1.2816 & 1.6449 & 1.9600 & 2.3263 & 2.5758 \\ \hline
$ \Pr(X<x) $ & 0.9 & 0.95 & 0.975 & 0.99 & 0.995
\end{tabular}
\end{center}

\subsection*{Pareto distribution}
If $X|\theta,\alpha\sim Pa(\theta,\alpha)$ then it has density
\[
f(x|\alpha,\theta)
=\frac{\alpha\theta^\alpha}{x^{\alpha+1}},\quad x>\theta
\]
where $\alpha>0$ and $\theta>0$. Also $E(X)=\alpha\theta/(\alpha-1)$,
$\alpha>1$ and $Var(X)=\alpha\theta^2/\{(\alpha-1)^2(\alpha-2)\}$,
$\alpha>2$.

\subsection*{Poisson distribution}
If $X|\theta\sim Po(\theta)$ then it has probability function
\[
f(x|\theta)=\bigfrac{\theta^xe^{-\theta}}{x!}\,,
\quad x=0,1,\ldots,
\]
where $\theta>0$. Also, $E(X)=\theta$ and $Var(X)=\theta$.

\subsection*{Rayleigh distribution}
If $X|\theta\sim R(\theta)$ then it has density
\[
f(x|\theta)=2x\theta e^{-\theta x^2},\quad x>0,
\]
where $\theta>0$. Also $E(X)=\sqrt{\pi/(4\theta)}$ and
$Var(X)=(4-\pi)/(4\theta)$.

\subsection*{Uniform distribution}
If $X|\phi,\theta\sim U(\phi,\theta)$ then it has density
\[
f(x|\phi,\theta)=\frac{1}{\theta-\phi}\,,\quad \phi<x<\theta,
\]
where $\phi<\theta$. Also, $E(X)=(\phi+\theta)/2$ and
$Var(X)=(\theta-\phi)^2/12$.

\subsection*{von Mises distribution}
If $X|\mu,\lambda\sim vM(\mu,\lambda)$ then it has density
\[
f(x|\mu,\lambda)
=\frac{1}{2\pi I_0(\lambda)} \exp\{\lambda\cos{(x-\mu)}\}
,\quad 0\leq x<2\pi
\]
where $0\leq\mu<2\pi$ and $\lambda>0$. Also $I_0(\cdot)$ is the
modified Bessel function of order zero.

\subsection*{Weibull distribution}
If $X|\beta,\lambda\sim Wei(\beta,\lambda)$ then it has density
\[
f(x|\beta,\lambda)=\beta\lambda^\beta x^{\beta-1}e^{-\lambda^\beta x^\beta}\,,
\quad x>0,
\]
where $\beta>0$ and $\lambda>0$. Also,
$E(X)=\Gamma(1+1/\beta)/\lambda$ and
$Var(X)=\Gamma(1+2/\beta)/\lambda^2-E(X)^2$.

\newpage
\section{Distributions for prior beliefs}

\subsection*{Beta distribution}
If $\theta\sim Beta(g,h)$ then it has density
\[
\pi(\theta)=\frac{\theta^{g-1}(1-\theta)^{h-1}}{B(g,h)}\,,
\quad 0<\theta<1,
\]
where $g>0$ and $h>0$. Also, $E(\theta)=g/(g+h)$ and
$Var(\theta)=gh/\{(g+h)^2(g+h+1)\}$.

\subsection*{Exponential distribution}
If $\theta\sim Exp(h)$ then it has density
\[
\pi(\theta)=h e^{-h\theta}\,,\quad \theta>0,
\]
where $h>0$. Also, $E(\theta)=1/h$ and $Var(\theta)=1/h^2$.

\subsection*{Gamma distribution}
If $\theta\sim Ga(g,h)$ then it has density
\[
\pi(\theta)=\frac{h^g \theta^{g-1}e^{-h\theta}}{\Gamma(g)}\,,
\quad \theta>0,
\]
where $g>0$ and $h>0$. Also, $E(\theta)=g/h$ and $Var(\theta)=g/h^2$.

\subsection*{Generalised $\boldsymbol{t}$ distribution}
\label{page:gt}
If $\mu\sim t_a(b,c)$ then it has density
\[
\pi(\mu)=\frac{\Gamma\left(\frac{a+1}{2}\right)}
{\sqrt{ac\pi}\,\Gamma\left(\frac{a}{2}\right)}
\left\{1+\frac{(\mu-b)^2}{ac}\right\}^{-\frac{a+1}{2}},\quad
\mu\in\mathbb{R},
\]
where $b\in\mathbb{R}$, $a>0$ and $c>0$.  Also, $E(\mu)=b$ and
$Var(\mu)=ac/(a-2)$ if $a\geq 2$.

\subsection*{Inverse Chi distribution}
\label{page:invchi}
If $\sigma\sim\textit{Inv-Chi}(a,b)$ then it has density
\[
\pi(\sigma|a,b)=\frac{2b^a\sigma^{-2a-1}e^{-b/\sigma^2}}{\Gamma(a)},\quad
\sigma>0,
\]
where $a>0$, $b>0$ and $\Gamma(a)$ is the gamma function. Also
$E(\sigma)=\sqrt{b}\,\Gamma(a-1/2)/\Gamma(a)$ and
$Var(\sigma)=b/(a-1)-E(\sigma)^2$ if $a>1$.  The name of the
distribution comes from the fact that $1/\sigma^2\sim Ga(a,b)\equiv
\chi^2_{2a}/(2b)$.

\subsection*{Log-normal distribution}
If $\theta\sim LN(b,c^2)$ then it has density
\[
\pi(\theta)=\frac{1}{\sqrt{2\pi}\,c\,\theta}
\exp\left\{-\frac{1}{2c^2}(\log\theta-b)^2\right\},\quad \theta>0
\]
where $b\in\mathbb{R}$ and $c>0$.  Also,
$E(\theta)=e^{b+c^2/2}$,
$Var(\theta)=(e^{c^2}-1)e^{2b+c^2}$. Further $\log\theta\sim
N(b,c^2)$ and so $E(\log\theta)=b$ and $Var(\log\theta)=c^2$.

\subsection*{Normal distribution}
If $\mu\sim N(b,1/d)$ then it has density
\[
\pi(\mu)=\left(\frac{d}{2\pi}\right)^{1/2}
\exp\left\{-\frac{d}{2}(\mu-b)^2\right\},\quad \mu\in\mathbb{R},
\]
where $b\in\mathbb{R}$ and $c>0$.  Also, $E(\mu)=b$ and
$Var(\mu)=1/d$.

\subsection*{Normal-gamma distribution}
If $\mutau\sim NGa(b,c,g,h)$ then it has density
\[
\pi(\mu,\tau)\propto\tau^{g-\frac{1}{2}}\exp\left\{-\frac{\tau}{2}
\left[c(\mu-b)^2+2h\right]\right\},\quad \mu\in\mathbb{R}, ~\tau>0
\]
where $b\in\mathbb{R}$ and $c,g,h>0$.  Also, $\mu|\tau\sim
N\left(b,\dfrac{1}{c\tau}\right)$, $\tau\sim Ga(g,h)$ and has marginal
distribution $\mu\sim t_{2g}\left(b,\dfrac{h}{gc}\right)$.

\subsection*{Uniform distribution}
If $\theta\sim U(a,b)$ then it has density
\[
\pi(\theta)=\frac{1}{b-a}\,,\quad a<\theta<b,
\]
where $a<b$.
Also, $E(\theta)=(a+b)/2$ and $Var(\theta)=(b-a)^2/12$.

\begin{comment}
\newpage

\section{Revision of joint distributions}
\label{sec:reviewjoint}
This section reviews some ideas and results for joint distributions
that were covered in statistics modules in Stages~1 and~2.

The way in which two random continuous variables $X_1$ and $X_2$
jointly vary can de described by their (joint) probability function
\[
F_{X_1,X_2}(x_1,x_2)=Pr(X_1\leq x_1,\,X_2\leq x_2)
\]
and its derivative, the (joint) density function
\[
f_{X_1,X_2}(x_1,x_2)=\frac{\partial^2}{\partial x_1\,\partial x_2}\,F_{X_1,X_2}(x_1,x_2).
\]
The way in which $X_1$ varies (regardless of the value of $X_2$) can
be examined via its \textit{marginal distribution}.  This marginal
distribution has density
\[
f_{X_1}(x_1)=\int_{-\infty}^\infty f_{X_1,X_2}(x_1,x_2)\,dx_2.
\]
Similarly the way in which $X_2$ varies (regardless of the value of
$X_1$) is described by its marginal distribution, which has density
\[
f_{X_2}(x_2)=\int_{-\infty}^\infty f_{X_1,X_2}(x_1,x_2)\,dx_1.
\]

The density of a 1--1 transformation of $\Xvec=(X_1,X_2)^T$ can be
determined as follows. If $Y_1=g_1(X_1,X_2)$ and $Y_2=g_2(X_1,X_2)$
have a single valued inverse $X_1=g_1^{-1}(Y_1,Y_2)$ and
$X_2=g_2^{-1}(Y_1,Y_2)$ then the joint density of $\Yvec=(Y_1,Y_2)^T$
is
\begin{equation}
\label{eq:trans2}
f_{\Yvec}(y_1,y_2)=f_{\Xvec}\left\{
g_1^{-1}(y_1,y_2),g_2^{-1}(y_1,y_2)\right\}\,|\det J|
\end{equation}
where the Jacobian of the transformation is the determinant
\[
\det J= \begin{vmatrix} 
\frac{\partial x_1}{\partial y_1} & \frac{\partial x_1}{\partial y_2}\\ 
\noalign{\medskip}
\frac{\partial x_2}{\partial y_1} & \frac{\partial x_2}{\partial y_2} 
\end{vmatrix}
\]
evaluated at $x_1=g_1^{-1}(y_1,y_2)$ and $x_2=g_2^{-1}(y_1,y_2)$.

The bivariate distribution you will be most familar with is the
\textit{bivariate normal distribution}.

\subsection{Bivariate normal distribution}
The random variables $X_1$ and $X_2$ are said to have a bivariate
normal distribution if their joint density is
\begin{equation}
f(x_1,x_2) = \frac{1}{2 \pi \sigma_1 \sigma_2 \sqrt{(1-\rho^2)}}\,
\exp\left\{-\frac{Q(x_1,x_2)}{2(1-\rho^2)} \right\},
\qquad x_1\in\R, x_2\in\R
\label{eq:mas2304bvn}
\end{equation}
where 
\[
Q(x_1,x_2) = \left( \frac{x_1-\mu_1}{\sigma_1} \right)^2 - \frac{2 \rho
  (x_1-\mu_1)(x_2-\mu_2)}{\sigma_1 \sigma_2} + \left(
  \frac{x_2-\mu_2}{\sigma_2} \right)^2 
\]
and $\mu_1\in\R$, $\mu_2\in\R$, $\sigma_1>0$, $\sigma_2>0$ and
$\rho\in(0,1)$.

This density can be written in a more condensed form by using vectors
and matrices. Let $\xvec=(x_1,x_2)^T$ then
\begin{equation}
f(\xvec) = (2\pi)^{-1}|\Sigma|^{-1/2}
\exp\left\{-\frac{1}{2}\,(\vec{x}-\vec{\mu})^T\Sigma^{-1}(\vec{x}-\vec{\mu})\right\},
\qquad\xvec\in\R^2
\label{eq:bvn}
\end{equation}
where 
\[
\vec{\mu} = \begin{pmatrix}\mu_1 \\ \mu_2 \end{pmatrix}
\qquad\text{and}\qquad
\Sigma =\begin{pmatrix}\sigma_1^2&\rho\sigma_1\sigma_2\\
                      \rho\sigma_1\sigma_2&\sigma_2^2\end{pmatrix}
\]
and the mean vector $\muvec\in\R^2$ and the covariance matrix~$\Sigma$
is a symmetric positive definite matrix. If $\Xvec=(X_1,X_2)^T$ then
we write
\[
\Xvec\sim N_2(\vec{\mu},\,\Sigma).
\]
Figure~\ref{fig:bivnorm} shows the density of the bivariate standard
normal density, with $\rho=0.5$ (and $\mu_1=\mu_2=0$,
$\sigma_1=\sigma_2=1$).
\begin{figure}[t!]
\begin{center}
\includegraphics[width=0.9\textwidth]{bivnorm}
\vspace*{-1.5cm}
\caption{The bivariate standard normal density, with $\rho=0.5$.}
\label{fig:bivnorm}
\end{center}
\end{figure}

It can be shown that the marginal distributions are
\[
X_1\sim N(\mu_1,\sigma_1^2)
\qquad\text{and}\qquad
X_2\sim N(\mu_2,\sigma_2^2)
\]
and that
\begin{center}
\begin{tabular}{lll}
$E(X_1)=\mu_1$,\quad~ & $Var(X_1)=\sigma_1^2$,\quad~ & $Corr(X_1,X_2)=\rho$, \\
$E(X_2)=\mu_2$, & $Var(X_2)=\sigma_2^2$. \\
\end{tabular}
\end{center}
Also, the contours of this density, described by
$\{(x_1,x_2):~f(x_1,x_2)=k\}$ for various values of $k$, are ellipses.
This is straightforward to see when $\rho=0$:
\begin{align*}
f(x_1,x_2)=k\quad&\Leftrightarrow\quad
\left( \frac{x_1-\mu_1}{\sigma_1} \right)^2 + \left(
  \frac{x_2-\mu_2}{\sigma_2} \right)^2=k'
\end{align*}
and this is the equation of an ellipse centred at $(\mu_1,\mu_2)^T$.
Notice that when $\sigma_1=\sigma_2=\sigma$, the equation becomes one
of a circle (with radius $k'\sigma^2$). When $\rho\neq 0$ the contours
remain ellipses but the axes of the ellipse are no longer the $x$-axis
and $y$-axis: they are a rotation of these axes which point in the
directions of the eigenvectors of~$\Sigma$. When $\sigma_1=\sigma_2=1$
these eigenvectors are $(1,1)^T$ and $(1,-1)^T$.
%\enlargethispage*{5mm}
Figure~\ref{fig:normalcontours} shows the contours for the
standardised bivariate normal density ($\mu_1=\mu_2=0$,
$\sigma_1=\sigma_2=1$), with $\rho=0.5$.  The figure also shows the
major and minor axes for the ellipse and the marginal $N(0,1)$
densities.

\begin{figure}[t!]
\begin{center}
\includegraphics[width=0.6\textwidth]{normalcontours}
%\includegraphics[width=0.9\textwidth]{normalcontours}
\caption{Contours of the standardised bivariate normal density, with
  $\rho=0.5$, and the marginal densities.}
\label{fig:normalcontours}
\end{center}
\end{figure} 

\end{comment}
