Definition 1 (Binomial distribution) A discrete random variable \(X\) has the binomial distribution with number of trials \(n \in {\mathopen{}\left\{1, 2, \dots\right\}\mathclose{}}\) and event probability \(\pi\in [0, 1]\), written \(X \sim {\operatorname{Bin}\mathopen{}\left(n, \pi\right)\mathclose{}}\)[1], if:
where \(\binom{n}{x} = \frac{n!}{x!\,(n - x)!}\) is the number of ways to choose \(x\) of the \(n\) trials.
RemarkRemark
Remark. Casella and Berger [2, Sec. 3.2] defines the binomial distribution the same way. With \(n = 1\), Equation 1 is the Bernoulli PMF: \({\operatorname{Bin}\mathopen{}\left(1, \pi\right)\mathclose{}}\) and \(\operatorname{Ber}(\pi)\) are the same distribution.
Example 2 (Two heads in three flips) Let \(X \sim {\operatorname{Bin}\mathopen{}\left(3, 1/2\right)\mathclose{}}\) be the number of heads in three flips of a fair coin. By Equation 1:
The three outcomes with two heads are \(HHT\), \(HTH\), and \(THH\), each with probability \(1/8\).
ExmExample 3 (Draws without replacement are not binomial)
Example 3 (Draws without replacement are not binomial) An urn holds two red balls and two blue balls. Draw two balls without replacement, and let \(X\) be the number of red balls drawn. Each draw is red with probability \(1/2\), but \(X \not\sim {\operatorname{Bin}\mathopen{}\left(2, 1/2\right)\mathclose{}}\), because the draws are not independent:
\[
\begin{aligned}
\mathbb{P}(X = 2)
&= \mathbb{P}(\text{first red}) \cdot\mathbb{P}(\text{second red} \mid \text{first red})
&& \text{(multiplication rule)} \\
&= \frac{2}{4} \cdot\frac{1}{3}
&& \text{(one red ball is left among three)} \\
&= \frac{1}{6}
&& \text{(multiply)}
\end{aligned}
\]
whereas, by Equation 1, a \({\operatorname{Bin}\mathopen{}\left(2, 1/2\right)\mathclose{}}\) random variable has
\[
\begin{aligned}
\mathbb{P}(X = 2)
&= \binom{2}{2} \mathopen{}\left(\frac{1}{2}\right)\mathclose{}^2 \mathopen{}\left(\frac{1}{2}\right)\mathclose{}^0
&& \text{(binomial PMF with } n = 2,\ \pi= 1/2,\ x = 2 \text{)} \\
&= \frac{1}{4}
&& \text{(evaluate)}
\end{aligned}
\]
LemTheorem 1 (A sum of IID Bernoulli variables is binomial)
Theorem 1 (A sum of IID Bernoulli variables is binomial) If \(X_1, \ldots, X_n\) are IID\(\operatorname{Ber}(\pi)\) random variables, then their sum \(S = \sum_{i=1}^nX_i\) has the \({\operatorname{Bin}\mathopen{}\left(n, \pi\right)\mathclose{}}\) distribution.
ProofProof
Proof. Each \(X_i\) is \(0\) or \(1\), so \(S\) takes values in \({\mathopen{}\left\{0, 1, \dots, n\right\}\mathclose{}}\). Let \(x \in {\mathopen{}\left\{0, 1, \dots, n\right\}\mathclose{}}\) be a value of \(S\), and let \(A_x\) be the set of sequences \((s_1, \ldots, s_n) \in {\mathopen{}\left\{0, 1\right\}\mathclose{}}^n\) with exactly \(x\) ones. The event \({\mathopen{}\left\{S = x\right\}\mathclose{}}\) is the disjoint union of the events \({\mathopen{}\left\{X_1 = s_1, \ldots, X_n = s_n\right\}\mathclose{}}\) over \((s_1, \ldots, s_n) \in A_x\). For one such sequence:
Example 4 (Counting treatment responders) Suppose five patients each respond to a treatment with probability \(0.2\), independently of one another, and let \(X_i = 1\) if patient \(i\) responds and \(X_i = 0\) otherwise. By Theorem 1, the number of responders \(S = \sum_{i=1}^5 X_i\) is \({\operatorname{Bin}\mathopen{}\left(5, 0.2\right)\mathclose{}}\), so the probability that nobody responds is:
Proof. The mean and variance of \(X\) depend only on its distribution, so by Theorem 1 we can compute them for \(S = \sum_{i=1}^nX_i\), where \(X_1, \ldots, X_n\) are IID \(\operatorname{Ber}(\pi)\). For the mean, apply linearity of expectation\(n - 1\) times, then the Bernoulli mean:
\[
\begin{aligned}
{\mathbb{E}\mathopen{}\left[S\right]\mathclose{}}
&= {\mathbb{E}\mathopen{}\left[\sum_{i=1}^nX_i\right]\mathclose{}}
&& \text{(definition of } S \text{)} \\
&= \sum_{i=1}^n{\mathbb{E}\mathopen{}\left[X_i\right]\mathclose{}}
&& \text{(linearity of expectation)} \\
&= \sum_{i=1}^n\pi
&& \text{(Bernoulli mean)} \\
&= n\pi
&& \text{(sum of } n \text{ copies of } \pi\text{)}
\end{aligned}
\]
Definition 2 (Poisson distribution) A random variable \(Y\) has the Poisson distribution with mean parameter \(\mu> 0\), written \(Y \sim \operatorname{Pois}(\mu)\)[3], if:
Proof. For \(y < 0\), both sides are \(0\) (the sum is empty). For any \(y \ge 0\), the event \(\{Y \le y\}\) is the disjoint union of events \(\{Y = j\}\) for all non-negative integers \(j \le \mathopen{}\left\lfloor y\right\rfloor\mathclose{}\). Applying the Poisson PMF (Equation 2) and factoring out the common term \(e^{-\mu}\):
\[
\begin{aligned}
\mathbb{P}(Y \le y)
&= \sum_{j=0}^{\mathopen{}\left\lfloor y\right\rfloor\mathclose{}} \mathbb{P}(Y = j) && (\text{disjoint union of events } Y = j) \\
&= \sum_{j=0}^{\mathopen{}\left\lfloor y\right\rfloor\mathclose{}} \frac{\mu^j e^{-\mu}}{j!} && (\text{definition of Poisson PMF}) \\
&= e^{-\mu} \sum_{j=0}^{\mathopen{}\left\lfloor y\right\rfloor\mathclose{}} \frac{\mu^j}{j!} && (\text{factoring out } e^{-\mu} \text{ constant wrt } j)
\end{aligned}
\]
Example 6 (Computing Poisson cumulative probabilities) For a Poisson random variable \(X \sim \operatorname{Pois}(\mu= 2)\), the probability of observing at most 2 events is computed as:
For \(x \in {\mathopen{}\left\{1, 2, \dots\right\}\mathclose{}}\) with \(x < \mu\), \(\mathbb{P}(X=x) > \mathbb{P}(X = x-1)\)
For \(x = \mu\) (possible only when \(\mu\) is an integer), \(\mathbb{P}(X=x) = \mathbb{P}(X = x-1)\)
For \(x \in {\mathopen{}\left\{1, 2, \dots\right\}\mathclose{}}\) with \(x > \mu\), \(\mathbb{P}(X=x) < \mathbb{P}(X = x-1)\)
If \(\mu\) is not an integer, \(\arg \max_{x} \mathbb{P}(X=x) = \mathopen{}\left\lfloor\mu\right\rfloor\mathclose{}\); if \(\mu\) is an integer, the maximum is attained at both \(x = \mu- 1\) and \(x = \mu\)
ProofProof
Proof. Ratio of consecutive probabilities. For \(x \in {\mathopen{}\left\{1, 2, \dots\right\}\mathclose{}}\):
This ratio is greater than, equal to, or less than 1 as \(x\) is less than, equal to, or greater than \(\mu\), which gives the three comparisons. So \(\mathbb{P}(X = x)\) increases while \(x < \mu\) and decreases once \(x > \mu\). If \(\mu\) is not an integer, the last increase is at \(x = \mathopen{}\left\lfloor\mu\right\rfloor\mathclose{}\), which is therefore the unique mode. If \(\mu\) is an integer, \(\mathbb{P}(X = \mu) = \mathbb{P}(X = \mu- 1)\), and both are modes.
Example 7 (Mode of a Poisson distribution) For \(X \sim \operatorname{Pois}(2.5)\), \(\mathbb{P}(X = 2) = \frac{2.5}{2}\mathbb{P}(X = 1) > \mathbb{P}(X = 1)\) and \(\mathbb{P}(X = 3) = \frac{2.5}{3}\mathbb{P}(X = 2) < \mathbb{P}(X = 2)\), so the mode is \(\mathopen{}\left\lfloor 2.5\right\rfloor\mathclose{} = 2\). For \(X \sim \operatorname{Pois}(2)\), \(\mathbb{P}(X = 2) = \frac{2}{2}\mathbb{P}(X = 1)\), so \(1\) and \(2\) are both modes, each with probability \(2 e^{-2} \approx 0.271\).
Definition 3 (Exposure magnitude) For many count outcomes, there is some sense of an exposure magnitude, such as population size or duration of observation, which multiplicatively rescales the expected (mean) count.
Exercise 3 What are some examples of exposure magnitudes?
SolutionSolution
Solution.
Table 3: Examples of exposure units
outcome
exposure units
disease incidence
number of individuals exposed; time at risk
car accidents
miles driven
worksite accidents
person-hours worked
population size
size of habitat
RemarkRemark
Remark. Exposure units are similar to the number of trials in a binomial distribution, but in non-binomial count outcomes, there can be more than one event per unit of exposure.
We can use \(t\) to represent continuous-valued exposures/observation durations, and \(n\) to represent discrete-valued exposures.
Definition 4 (Event rate) For a count \(Y\) observed over a fixed, known exposure magnitude\(t > 0\), the event rate, denoted \({\lambda}\), is the mean of \(Y\) divided by the exposure magnitude:
Remark. The event rate is a transformation of the mean: it removes the exposure magnitude from the mean, so counts observed over different exposures can be compared on one scale. Regression models for counts use the same decomposition, with the rate depending on covariates and the exposure magnitude known (see rme’s count-regression chapter).
LemTheorem 6 (Transformation function from event rate to mean)
Theorem 6 (Transformation function from event rate to mean) If a count \(Y\) is observed over exposure magnitude \(t > 0\) with event rate \({\lambda}\), then its mean \(\mu\stackrel{\text{def}}{=}{\mathbb{E}\mathopen{}\left[Y\right]\mathclose{}}\) is:
\[
\begin{aligned}
{\lambda}&\stackrel{\text{def}}{=}\frac{{\mathbb{E}\mathopen{}\left[Y\right]\mathclose{}}}{t} && (\text{definition of event rate}) \\
{\mathbb{E}\mathopen{}\left[Y\right]\mathclose{}} &= {\lambda}\cdot t && (\text{multiply both sides by } t > 0) \\
\mu&= {\lambda}\cdot t && (\mu\stackrel{\text{def}}{=}{\mathbb{E}\mathopen{}\left[Y\right]\mathclose{}})
\end{aligned}
\]
ExmExample 8 (Calculating expected counts from event rates)
Example 8 (Calculating expected counts from event rates) Suppose a city records a disease event rate of \({\lambda}= 0.05\) cases per person-year. For a subpopulation with an exposure magnitude of \(t = 100\) person-years, the expected count of cases is, by Theorem 6:
\[
\begin{aligned}
\mu&= {\lambda}\cdot t && (\text{transformation from event rate to mean}) \\
&= 0.05 \times 100 && (\text{substitute } {\lambda}= 0.05 \text{ and } t = 100) \\
&= 5 \text{ cases} && (\text{evaluate expected count})
\end{aligned}
\]
LemTheorem 7 (No exposure means no expected events)
Theorem 7 (No exposure means no expected events) For each exposure magnitude \(t \ge 0\), let \(Y_t\) be the count observed over exposure \(t\). If the mean count is proportional to the exposure magnitude, \({\mathbb{E}\mathopen{}\left[Y_t\right]\mathclose{}} = {\lambda}\cdot t\) for all \(t \ge 0\) with one finite rate \({\lambda}\), then there are no expected events without exposure:
Proof. \[
\begin{aligned}
{\mathbb{E}\mathopen{}\left[Y_0\right]\mathclose{}}
&= {\lambda}\cdot 0 && (\text{evaluate } {\mathbb{E}\mathopen{}\left[Y_t\right]\mathclose{}} = {\lambda}t \text{ at } t = 0) \\
&= 0 && (\text{multiplication by zero; } {\lambda}\text{ is finite})
\end{aligned}
\]
RemarkRemark
Remark. The hypothesis carries the content here. Definition 4 alone cannot give \({\mathbb{E}\mathopen{}\left[Y_0\right]\mathclose{}} = 0\), since \({\lambda}= {\mathbb{E}\mathopen{}\left[Y\right]\mathclose{}}/t\) is undefined at \(t = 0\); the result holds for a model that assumes one rate \({\lambda}\) shared across exposure magnitudes, including \(t = 0\).
Example 9 (Zero exposure time) If a subject is observed for \(t = 0\) person-years, no follow-up time has elapsed, so under a constant-rate model the expected number of incident events is \({\mathbb{E}\mathopen{}\left[Y_0\right]\mathclose{}} = 0\).
Important
A mean proportional to exposure, \({\mathbb{E}\mathopen{}\left[Y_t\right]\mathclose{}} = {\lambda}t\), has no term that stays nonzero at \(t = 0\): a model of this form says that with no exposure, no events are expected. A mean with an added constant, such as \({\mathbb{E}\mathopen{}\left[Y_t\right]\mathclose{}} = c + {\lambda}t\) with \(c > 0\), would expect \(c\) events even with no exposure. Regression models for counts keep the proportional form when they add covariates (see rme’s count-regression chapter).
LemTheorem 8 (Exposure is additive on the log scale)
Theorem 8 (Exposure is additive on the log scale) If \(\mu= {\lambda}\cdot t\) with \({\lambda}> 0\) and \(t > 0\), then:
ExmExample 10 (Log-linear representation of expected counts)
Example 10 (Log-linear representation of expected counts) If a clinic sees an event rate of \({\lambda}= 0.02\) events/day and \(t = 30\) days of observation:
Definition 5 (Offset) In a model whose linear component contains a term with no unknown coefficient, that term is called an offset: it shifts the linear component by a known amount. In a count model with exposure magnitude \(t\), the offset is the known term \(\log{t}\) in the log-scale decomposition of the mean (8),
\[\log{\mu} = \log{{\lambda}} + \log{t}.\]
RemarkRemark
Remark. The offset needs no covariates: with a single exposure \(t\) and an unknown rate \({\lambda}\), \(\log{t}\) is already an offset. Regression models for counts keep the same term and add covariate terms beside it (see rme’s count-regression chapter).
ExmExample 11 (The offset for a clinic’s event count)
Example 11 (The offset for a clinic’s event count) In Example 10, the clinic was observed for \(t = 30\) days, so the offset is \(\log{30} \approx 3.401\). Only \(\log{{\lambda}}\) is unknown before the data are seen; the offset is fixed by the length of observation. A clinic observed for \(t = 60\) days has offset \(\log{60} \approx 4.094\), which raises \(\log{\mu}\) by \(\log{2} \approx 0.693\) at the same event rate.
LemTheorem 9 (Sum of independent Poisson random variables)
Theorem 9 (Sum of independent Poisson random variables) If \(X\) and \(Y\) are independent Poisson random variables with means \(\mu_X\) and \(\mu_Y\), their sum, \(Z=X+Y\), is also a Poisson random variable, with mean \(\mu_Z = \mu_X + \mu_Y\).
ProofProof
Proof. The event \(\{Z = z\}\) is the disjoint union of the events \(\{X = k, Y = z - k\}\) for \(k = 0, 1, \ldots, z\) (since \(X\) and \(Y\) are non-negative integers), so:
ExmExample 12 (Aggregating independent region counts)
Example 12 (Aggregating independent region counts) Suppose Region A records \(X \sim \operatorname{Pois}(\mu_X = 12)\) cases and Region B records \(Y \sim \operatorname{Pois}(\mu_Y = 18)\) cases independently. By Theorem 9, the combined total count \(Z = X + Y\) follows a Poisson distribution:
\[
\begin{aligned}
Z &\sim \operatorname{Pois}(\mu_X + \mu_Y) && (\text{sum of independent Poissons}) \\
&= \operatorname{Pois}(12 + 18) && (\text{substitute region means}) \\
&= \operatorname{Pois}(30) && (\text{evaluate sum})
\end{aligned}
\]
Definition 6 (Negative binomial distribution) A random variable \(Y\) has the negative binomial distribution with mean \(\mu> 0\) and overdispersion parameter \(\rho> 0\), written \(Y \sim \operatorname{NegBin}(\mu, \rho)\)[4], if, for \(y \in {\mathopen{}\left\{0, 1, 2, \dots\right\}\mathclose{}}\):
where \(\Gamma\) is the gamma function, which satisfies \(\Gamma(x) = (x-1)!\) for positive integers \(x\).
LemTheorem 10 (The negative binomial converges to the Poisson)
Theorem 10 (The negative binomial converges to the Poisson) Let the population mean be \(\mu> 0\), and let \(Y_\rho\sim \operatorname{NegBin}(\mu, \rho)\). Then for each \(y \in {\mathopen{}\left\{0, 1, 2, \dots\right\}\mathclose{}}\), as \(\rho\rightarrow \infty\), the negative binomial PMF converges to the Poisson PMF (Equation 2):
Proof. Choose a value \(y\) of \(Y_\rho\). In Definition 6, the first factor \(\mu^y / y!\) does not depend on \(\rho\). For the second factor, \(\Gamma(\rho+ y) = \Gamma(\rho) \prod_{k=0}^{y-1} (\rho+ k)\), by applying \(\Gamma(x + 1) = x\,\Gamma(x)\)\(y\) times (for \(y = 0\), the product is empty and equals 1), so:
For the third factor, write \(x \stackrel{\text{def}}{=}\mu/\rho\), so \(x \rightarrow 0\) as \(\rho\rightarrow \infty\), and \(\rho= \mu/x\):
\[
\begin{aligned}
\log\mathopen{}\left(\mathopen{}\left(1 + \frac{\mu}{\rho}\right)\mathclose{}^{-\rho}\right)\mathclose{}
&= -\rho\log\mathopen{}\left(1 + \frac{\mu}{\rho}\right)\mathclose{}
&& (\text{log of a power}) \\
&= -\mu\cdot \frac{\log(1 + x)}{x}
&& (\text{substitute } \rho= \mu/x) \\
&\rightarrow -\mu\cdot 1
&& (\textstyle\lim_{x \rightarrow 0} \log(1 + x)/x = 1 \text{, the derivative of } \log(1 + x) \text{ at } x = 0) \\
&= -\mu
&& (\text{simplify})
\end{aligned}
\]
so, since the exponential function is continuous, \(\mathopen{}\left(1 + \mu/\rho\right)\mathclose{}^{-\rho} \rightarrow {\operatorname{exp}\mathopen{}\left\{-\mu\right\}\mathclose{}}\). Each of the three factors has a limit, so their product does too:
\[
\begin{aligned}
\lim_{\rho\rightarrow \infty} \mathbb{P}(Y_\rho= y)
&= \frac{\mu^y}{y!} \cdot 1 \cdot {\operatorname{exp}\mathopen{}\left\{-\mu\right\}\mathclose{}}
&& (\text{limit of a product of convergent factors}) \\
&= \frac{\mu^{y} e^{-\mu}}{y!}
&& (\text{rearrange})
\end{aligned}
\]
which is the \(\operatorname{Pois}(\mu)\) PMF.
LemTheorem 11 (Mean and variance of the negative binomial distribution)
Theorem 11 (Mean and variance of the negative binomial distribution) If \(Y \sim \operatorname{NegBin}(\mu, \rho)\), then:
Proof. The negative binomial distribution is a gamma mixture of Poisson distributions: if \(\Lambda\) has the gamma density \(g({\lambda}) = \frac{(\rho/\mu)^\rho}{\Gamma(\rho)} {\lambda}^{\rho- 1} e^{-\rho{\lambda}/\mu}\) for \({\lambda}> 0\), which has mean \(\mu\) and variance \(\mu^2/\rho\)[2], and \(Y \mid \Lambda= {\lambda}\sim \operatorname{Pois}({\lambda})\), then \(Y \sim \operatorname{NegBin}(\mu, \rho)\). To check this, integrate the joint density over \({\lambda}\):
Definition 7 (Laplace distribution) A random variable \(Y\) has the Laplace distribution with location parameter \(\mu\in \mathbb{R}\) and scale parameter \(b > 0\), written \(Y \sim {\operatorname{Laplace}\mathopen{}\left(\mu, b\right)\mathclose{}}\)[5], if \(Y\) is continuous with density:
\[\mathbb{p}(Y=y) \stackrel{\text{def}}{=}\frac{1}{2b} \text{e}^{-\frac{\mathopen{}\left|y - \mu\right|\mathclose{}}{b}}, \quad y \in \mathbb{R} \tag{6}\]
RemarkRemark
Remark. The normal density has the squared distance \((y - \mu)^2\) in its exponent. The Laplace density has the absolute distance \(\mathopen{}\left|y - \mu\right|\mathclose{}\) instead. Both densities are symmetric about \(\mu\), but the Laplace density has a sharp peak at \(\mu\) and decays more slowly in the tails.
Example 14 (Laplace density values) Let \(Y \sim {\operatorname{Laplace}\mathopen{}\left(3, 2\right)\mathclose{}}\), so \(\mu= 3\) and \(b = 2\) (Definition 7). At the location, \(\mathopen{}\left|y - \mu\right|\mathclose{} = 0\), so the density is \(\frac{1}{2b}\). At a point \(y = 5\), the distance is
The density at \(\mu+ b\) is the density at \(\mu\) times \(\text{e}^{-1}\), and the same holds at \(\mu- b\), because the density depends only on the distance from \(\mu\).
LemTheorem 12 (Mean and variance of the Laplace distribution)
Theorem 12 (Mean and variance of the Laplace distribution) If \(Y \sim {\operatorname{Laplace}\mathopen{}\left(\mu, b\right)\mathclose{}}\) (Definition 7), then
Proof. Write \(U = Y - \mu\). By Equation 6, \(U\) has density \(\frac{1}{2b}\text{e}^{-\mathopen{}\left|u\right|\mathclose{}/b}\), which is symmetric about \(0\).
For the mean, the integrand \(u \cdot \frac{1}{2b}\text{e}^{-\mathopen{}\left|u\right|\mathclose{}/b}\) is an odd function, so its integral over \(\mathbb{R}\) is \(0\). Therefore \({\mathbb{E}\mathopen{}\left[U\right]\mathclose{}} = 0\), and
because \({\mathbb{E}\mathopen{}\left[U\right]\mathclose{}} = 0\). The integrand \(u^2 \cdot \frac{1}{2b}\text{e}^{-\mathopen{}\left|u\right|\mathclose{}/b}\) is even, so
\[
\begin{aligned}
{\mathbb{E}\mathopen{}\left[U^2\right]\mathclose{}}
&= 2 \int_0^\infty u^2 \frac{1}{2b} \text{e}^{-u/b} \, du
&& \text{(even integrand)} \\
&= \frac{1}{b} \int_0^\infty u^2 \text{e}^{-u/b} \, du
&& \text{(multiplying the constants)} \\
&= \frac{1}{b} \mathopen{}\left(2b \int_0^\infty u \text{e}^{-u/b} \, du\right)\mathclose{}
&& \text{(integration by parts; the boundary terms are $0$)} \\
&= \frac{1}{b} \mathopen{}\left(2b \cdot b^2\right)\mathclose{}
&& \text{(integration by parts again; the boundary terms are $0$)} \\
&= 2b^2.
&& \text{(multiplying the constants)}
\end{aligned}
\]
ExmExample 15 (Laplace and normal tails with the same mean and variance)
Example 15 (Laplace and normal tails with the same mean and variance) A Laplace variable \(Y \sim {\operatorname{Laplace}\mathopen{}\left(0, b\right)\mathclose{}}\) has variance \(2b^2\) (Theorem 12). Choosing \(b = 1/\sqrt{2}\) gives variance \(1\), the same mean and variance as a standard normal. Figure 3 compares the two densities. The Laplace density is higher at the center and in the far tails, and lower in between.
Show code
b <-1/sqrt(2)grid <-seq(-4, 4, length.out =801)dlaplace <-function(y, mu =0, b =1) exp(-abs(y - mu) / b) / (2* b)densities <- tibble::tibble(y =rep(grid, times =2),distribution =rep(c("Laplace", "Normal"), each =length(grid)),density =c(dlaplace(grid, b = b), dnorm(grid)))ggplot2::ggplot(densities) + ggplot2::aes(x = y, y = density, colour = distribution) + ggplot2::geom_line() + ggplot2::labs(colour =NULL)
Figure 3: Laplace and standard normal densities with the same mean (0) and variance (1)
The probability of landing more than \(3\) standard deviations from the mean shows the difference in the tails. For the Laplace distribution, \(\mathbb{P}(\mathopen{}\left|Y\right|\mathclose{} > t) = \text{e}^{-t/b}\), because each tail has probability \(\frac{1}{2}\text{e}^{-t/b}\) by integrating Equation 6.
t <-3c(Laplace =exp(-t / b),Normal =2*pnorm(-t))#> Laplace Normal #> 0.014369596 0.002699796
The Laplace distribution puts about 5.3 times as much probability beyond \(3\) standard deviations as the normal distribution does.
Definition 8 (Weibull distribution) A non-negative random variable \(T\) has the Weibull distribution with shape \(\alpha> 0\) and rate \({\lambda}> 0\)[6] if its survival function is:
\[\mathbb{S}(t) \stackrel{\text{def}}{=}\text{e}^{-{\lambda}t^\alpha}, \quad t \ge 0\]
Proof. The CDF of \(T\) is \(F(t) = 1 - \mathbb{S}(t)\) (survival function and CDF), which is \(0\) for \(t < 0\) and \(1 - \text{e}^{-{\lambda}t^\alpha}\) for \(t \ge 0\). This \(F\) is continuous everywhere, with a continuous derivative everywhere except possibly \(t = 0\), so
\[
\begin{aligned}
f &= F' \\
&= -\mathbb{S}'
\end{aligned}
\]
Proof. For the mean, use the survival-function formula for the mean and substitute \(u = {\lambda}t^\alpha\), so that \(t = (u/{\lambda})^{1/\alpha}\) and \(dt = \frac{1}{\alpha}{\lambda}^{-1/\alpha} u^{1/\alpha- 1}\,du\):
\[
\begin{aligned}
{\mathbb{E}\mathopen{}\left[T\right]\mathclose{}}
&= \int_0^\infty \text{e}^{-{\lambda}t^\alpha}\,dt
&& (\text{expectation via the survival function}) \\
&= \frac{1}{\alpha}{\lambda}^{-1/\alpha} \int_0^\infty u^{1/\alpha- 1} \text{e}^{-u}\,du
&& (\text{substitute } u = {\lambda}t^\alpha) \\
&= \frac{1}{\alpha}{\lambda}^{-1/\alpha}\,\Gamma(1/\alpha)
&& (\text{definition of the gamma function}) \\
&= \Gamma(1 + 1/\alpha)\,{\lambda}^{-1/\alpha}
&& (\Gamma(1 + a) = a\,\Gamma(a))
\end{aligned}
\]
CorCorollary 1 (The Weibull with shape 1 is the exponential)
Corollary 1 (The Weibull with shape 1 is the exponential) If \(T\) has the Weibull distribution with shape \(\alpha= 1\) and rate \({\lambda}\), then \(T\) has the exponential distribution with rate \({\lambda}\).
ProofProof
Proof. By Theorem 13 with \(\alpha= 1\), for \(t > 0\):
and \(f(t) = 0\) for \(t < 0\), since \(T\) is non-negative. This density matches the exponential density at every \(t \ne 0\). Changing a density at the single point \(t = 0\) does not change its integral over any set, so \(T\) has the exponential distribution with rate \({\lambda}\).
CorCorollary 2 (The Weibull shape sets the direction of the hazard)
Corollary 2 (The Weibull shape sets the direction of the hazard) If \(T\) has the Weibull distribution with shape \(\alpha\) and rate \({\lambda}\), then on \(t > 0\) its hazard \(\mathbb{h}(t)\) is:
strictly increasing if \(\alpha> 1\)
constant if \(\alpha= 1\)
strictly decreasing if \(\alpha< 1\)
ProofProof
Proof. By Theorem 13, \(\mathbb{h}(t) = \alpha{\lambda}t^{\alpha-1}\) for \(t > 0\), so:
For \(t > 0\), the factors \(\alpha\), \({\lambda}\), and \(t^{\alpha-2}\) are all positive, so \(\frac{d}{dt}\mathbb{h}(t)\) has the sign of \(\alpha- 1\): positive for \(\alpha> 1\), zero for \(\alpha= 1\), and negative for \(\alpha< 1\). A function with a positive (negative) derivative on an interval is strictly increasing (decreasing) there, and one with a zero derivative is constant.
RemarkRemark
Remark. The exponential distribution’s hazard is constant, so the Weibull’s choice of an increasing, constant, or decreasing hazard (Corollary 2) provides more flexibility than the exponential.
matching the exponential distribution’s constant hazard and mean. With \(\alpha= 2\) and \({\lambda}= 1\), \(\mathbb{h}(t) = 2t\) increases with \(t\), and
DefDefinition 9 (Multivariate normal distribution (multivariate Gaussian distribution))
Definition 9 (Multivariate normal distribution (multivariate Gaussian distribution)) A \(p \times 1\) random vector \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}= {(X_1, \ldots, X_p)}^{\top}\) has the multivariate normal distribution (or multivariate Gaussian distribution) with mean parameter \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} \in \mathbb{R}^p\) and variance parameter \(\mathbf{\Sigma}\), a \(p \times p\)positive definite matrix, written \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\), if \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\) has joint density:
where \(\det(\mathbf{\Sigma})\) is the determinant of \(\mathbf{\Sigma}\) and \(\mathbf{\Sigma}^{-1}\) is its inverse.
RemarkRemark
Remark. A joint density of \(p\) random variables is the \(p\)-variable analogue of a joint density of two: a non-negative function on \(\mathbb{R}^p\) whose integral over any region \(A \subseteq \mathbb{R}^p\) is \(\Pr(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\in A)\).
The density is well defined because \(\mathbf{\Sigma}\) is positive definite:
LemTheorem 15 (The multivariate normal density integrates to 1)
Theorem 15 (The multivariate normal density integrates to 1) If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\) (Definition 9), then the density in Definition 9 integrates to 1 over \(\mathbb{R}^p\).
LemTheorem 16 (The mean and variance of the multivariate normal distribution)
Theorem 16 (The mean and variance of the multivariate normal distribution) If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\) (Definition 9), then \(\mathbb{E}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\) (the expectation of a random vector), and \({\operatorname{Var}\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\right)\mathclose{}} = \mathbf{\Sigma}\) (the variance of a random vector).
RemarkRemark
Remark. The proof changes variables in a \(p\)-dimensional integral, which these notes do not develop; see [7]. As with the univariate normal distribution, these facts are where the parameters’ names come from. They also show why \(\mathbf{\Sigma}\) must at least be positive semidefinite; requiring it to be positive definite rules out cases like a variance matrix that is not positive definite, which has no joint density.
ExmExample 17 (The univariate normal is the case \(p = 1\))
Example 17 (The univariate normal is the case \(p = 1\)) With \(p = 1\), \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} = (\mu)\), and \(\mathbf{\Sigma} = (\sigma^2)\) for \(\sigma^2> 0\), \(\det(\mathbf{\Sigma}) = \sigma^2\) (determinant, \(p = 1\)) and \(\mathbf{\Sigma}^{-1} = (1/\sigma^2)\), so:
which is the normal density\({\operatorname{N}\mathopen{}\left(\mu, \sigma^2\right)\mathclose{}}\).
LemLemma 1 (The quadratic form in the multivariate normal density is non-negative)
Lemma 1 (The quadratic form in the multivariate normal density is non-negative) If \(\mathbf{\Sigma}\) is a \(p \times p\) positive definite matrix and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}, \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} \in \mathbb{R}^p\), then
with equality if and only if \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\).
ProofProof
Proof. \(\mathbf{\Sigma}^{-1}\) is positive definite (positive definite inverse). If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\neq \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\), then \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} \neq \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\), so the quadratic form is positive by the definition of positive definite. If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\), then \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\), and the quadratic form is \(0\).
Definition 10 (Mahalanobis distance) For a \(p \times p\) positive definite matrix \(\mathbf{\Sigma}\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}, \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} \in \mathbb{R}^p\), the Mahalanobis distance from \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\) to \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\) with respect to \(\mathbf{\Sigma}\) is:
Remark. The square root is defined by Lemma 1. See also [8].
CorCorollary 3 (The multivariate normal density decreases with Mahalanobis distance)
Corollary 3 (The multivariate normal density decreases with Mahalanobis distance) If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\), then:
where \(\Delta\) is the Mahalanobis distance to \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\) with respect to \(\mathbf{\Sigma}\) (Definition 10). So the density is highest at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\), decreases as \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) increases, and is the same at every \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\) with the same \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\).
ProofProof
Proof. Substitute Definition 10 into Definition 9. The function \(\delta\mapsto \text{e}^{-\delta^2/2}\) decreases on \(\delta\ge 0\), and by Lemma 1, \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = 0\) only at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\).
ExmExample 18 (Mahalanobis distance for diagonal variance matrices)
Example 18 (Mahalanobis distance for diagonal variance matrices) If \(\mathbf{\Sigma}\) is diagonal with diagonal elements \(\sigma^2_1, \ldots, \sigma^2_p\), all positive, then \(\mathbf{\Sigma}^{-1}\) is diagonal with diagonal elements \(1/\sigma^2_1, \ldots, 1/\sigma^2_p\) (multiplying the two gives \(\mathbf{I}_p\); matrix inverse), so:
If \(\mathbf{\Sigma} = \mathbf{I}_p\), then \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})^2 = \sum_{i=1}^p(x_i - \mu_i)^2\), so the Mahalanobis distance is the ordinary (Euclidean) distance.
If \(\mathbf{\Sigma} = \sigma^2\mathbf{I}_p\), then \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) is the Euclidean distance divided by \(\sigma\).
In general, each coordinate’s difference is measured in units of that coordinate’s standard deviation.
LemTheorem 17 (A multivariate normal vector with diagonal variance has independent normal components)
Theorem 17 (A multivariate normal vector with diagonal variance has independent normal components) If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\) and \(\mathbf{\Sigma}\) is diagonal with diagonal elements \(\sigma^2_1, \ldots, \sigma^2_p\), then:
the joint density of \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\) is the product of the normal densities\({\operatorname{N}\mathopen{}\left(\mu_i, \sigma^2_i\right)\mathclose{}}\), \(i = 1, \ldots, p\),
each \(X_i \sim {\operatorname{N}\mathopen{}\left(\mu_i, \sigma^2_i\right)\mathclose{}}\), and
Proof. By the determinant of a diagonal matrix, \(\det(\mathbf{\Sigma}) = \prod_{i=1}^p \sigma^2_i\), so \(\det(\mathbf{\Sigma})^{1/2} = \prod_{i=1}^p \sigma_i\). Using Example 18 for the quadratic form:
which is the product of the \({\operatorname{N}\mathopen{}\left(\mu_i, \sigma^2_i\right)\mathclose{}}\) densities. Integrating out every coordinate except \(x_i\), each other factor integrates to 1 (the normal density integrates to 1), leaving the \({\operatorname{N}\mathopen{}\left(\mu_i, \sigma^2_i\right)\mathclose{}}\) density as the density of \(X_i\) (marginal density from a joint density, with \(p\) variables). So the joint density is the product of the marginal densities, and the components are independent by the factorization theorem for densities, extended to \(p\) variables as its remark describes.
CorCorollary 4 (For a multivariate normal vector, uncorrelated components are independent)
Corollary 4 (For a multivariate normal vector, uncorrelated components are independent) If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\sim \operatorname{N}_p\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}, \mathbf{\Sigma}\right)\mathclose{}\), then \(X_1, \ldots, X_p\) are independent if and only if \(\mathbf{\Sigma}\) is diagonal, that is, if and only if \({\operatorname{Cov}\mathopen{}\left(X_i, X_j\right)\mathclose{}} = 0\) for every \(i \neq j\).
ProofProof
Proof. By Theorem 16, \({\operatorname{Var}\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{X}}\vphantom{X}}\right)\mathclose{}} = \mathbf{\Sigma}\), whose \((i,j)\)-th element is \({\operatorname{Cov}\mathopen{}\left(X_i, X_j\right)\mathclose{}}\) (elements of the variance matrix). If \(\mathbf{\Sigma}\) is diagonal, the components are independent by Theorem 17. If the components are independent, then:
each pair \(X_i, X_j\) with \(i \neq j\) is independent,
each \(X_i\) is continuous, with the density left after integrating out the other coordinates of the joint density (marginal density from a joint density, with \(p\) variables), and
\({\mathbb{E}\mathopen{}\left[X_i^2\right]\mathclose{}} < \infty\), because \({\operatorname{Var}\mathopen{}\left(X_i\right)\mathclose{}}\), the \((i,i)\)-th element of \(\mathbf{\Sigma}\), is defined, and a variance is defined only when \({\mathbb{E}\mathopen{}\left[X_i^2\right]\mathclose{}} < \infty\).
LemTheorem 18 (Mahalanobis distance in eigenvector coordinates)
Theorem 18 (Mahalanobis distance in eigenvector coordinates) Let \(\mathbf{\Sigma}\) be positive definite, with eigendecomposition\(\mathbf{\Sigma} = \mathbf{Q}\mathbf{\Lambda}{\mathbf{Q}}^{\top}\), where \(\mathbf{Q}\) has columns \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_1, \ldots, \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_p\) and \(\mathbf{\Lambda}\) has diagonal elements \(\lambda_1, \ldots, \lambda_p\). Then:
Proof. Let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}} = {\mathbf{Q}}^{\top}(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}})\), whose \(i\)-th element is \(y_i = {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_i}^{\top}(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}})\). By the inverse of a positive definite matrix, \(\mathbf{\Sigma}^{-1} = \mathbf{Q}\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top}\), with every \(\lambda_i > 0\). So:
Remark. \(y_i\) is the coordinate of \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\) along the eigenvector \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_i\). So the set of points at Mahalanobis distance \(\delta\) from \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\), where the multivariate normal density is constant (Corollary 3), is an ellipse (\(p = 2\)) or ellipsoid centered at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}}\), with axes along the eigenvectors of \(\mathbf{\Sigma}\) and half-length \(\delta\sqrt{\lambda_i}\) along \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_i\).
ExmExample 19 (Elliptical contours of a bivariate normal density)
Example 19 (Elliptical contours of a bivariate normal density) Let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\mu}}\vphantom{\mu}} = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) and \(\mathbf{\Sigma} = \begin{pmatrix}2 & 1 \\ 1 & 2\end{pmatrix}\), which has eigenvalues \(3\) and \(1\), with eigenvectors \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_1 = \frac{1}{\sqrt{2}}{(1, 1)}^{\top}\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_2 = \frac{1}{\sqrt{2}}{(1, -1)}^{\top}\) (an eigendecomposition example). By Theorem 18:
the point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_2\) has \(x_1 + x_2 = 0\) and \(x_1 - x_2 = \sqrt{2}\), so
So the contour \(\Delta(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = 1\) of the \(\operatorname{N}_2\mathopen{}\left(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}, \mathbf{\Sigma}\right)\mathclose{}\) density is an ellipse stretched along \({(1, 1)}^{\top}\), with half-length \(\sqrt{3}\), and squeezed along \({(1, -1)}^{\top}\), with half-length \(1\): \(X_1\) and \(X_2\) are positively correlated (Figure 4).
Show code
# The covariance matrix of the example and its eigendecomposition.mh_entries <-c(2, 1, 1, 2)mh_covmat <-matrix(mh_entries, nrow =2)mh_eig <-eigen(mh_covmat)mh_values <- mh_eig$valuesmh_expected <-c(3, 1)mh_matches <-all.equal(mh_values, mh_expected)stopifnot(mh_matches)# The Mahalanobis distance of each grid point from the mean zero.mh_axis <-seq(-3.5, 3.5, length.out =200)mh_grid <- tidyr::expand_grid(x1 = mh_axis, x2 = mh_axis)mh_points <-as.matrix(mh_grid)mh_inverse <-solve(mh_covmat)mh_quad <- (mh_points %*% mh_inverse) * mh_pointsmh_sums <-rowSums(mh_quad)mh_dist <-sqrt(mh_sums)mh_grid <- dplyr::mutate(mh_grid, mahal = mh_dist)# The points of the example: sqrt(3) q1 and q2, each at distance 1.mh_long <-sqrt(3/2)mh_short <-1/sqrt(2)mh_marks_x1 <-c(mh_long, mh_short)mh_marks_x2 <-c(mh_long, -mh_short)mh_marks <- tibble::tibble(x1 = mh_marks_x1, x2 = mh_marks_x2)mh_contour_aes <- ggplot2::aes(z = mahal, colour = ggplot2::after_stat(level))mh_breaks <-c(1, 2)mh_contours <- ggplot2::geom_contour(mh_contour_aes, breaks = mh_breaks)mh_dots <- ggplot2::geom_point(data = mh_marks, size =2.5)mh_colours <- ggplot2::scale_colour_viridis_c(name ="Mahalanobis distance",end =0.7,breaks = mh_breaks,guide ="legend")mh_plot <- mh_grid |> ggplot2::ggplot() + ggplot2::aes(x1, x2) + mh_contours + mh_dots + mh_colours + ggplot2::coord_fixed(expand =FALSE) + ggplot2::labs(x ="x1", y ="x2") + ggplot2::theme(legend.position ="bottom")mh_is_html <- knitr::is_html_output()if (mh_is_html) { mh_legend <-list(orientation ="h",x =0.5,xanchor ="center",y =-0.25 ) mh_widget <- plotly::ggplotly(mh_plot) |> plotly::layout(legend = mh_legend) |> plotly::config(displaylogo =FALSE, responsive =TRUE) htmltools::div(role ="img",`aria-label`= fig_alt_mahal_eigen, mh_widget )} else { mh_plot}
Figure 4: The contours of the Mahalanobis distance at \(1\) and \(2\) for the example. The dots are the points \(\sqrt{3}\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_1\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_2\) of the example on the inner ellipse.
Figure 5: The Mahalanobis distance is a surface over the plane, a cone whose horizontal slices are the ellipses of Figure 4. The red lines are the contours at \(1\) and \(2\), and the dots are the points \(\sqrt{3}\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_1\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{q}}\vphantom{q}}_2\) of the example on the inner one.
Definition 11 (Mixture density) Let \({\mathbb{p}_1}, \ldots, {\mathbb{p}_K}\) be densities on \(\mathbb{R}\), and let \(w_1, \ldots, w_K\) be numbers with:
\(w_c \ge 0\) for every \(c\), and
\(\sum_{c=1}^{K} w_c = 1\).
The mixture of \({\mathbb{p}_1}, \ldots, {\mathbb{p}_K}\) with mixing weights\(w_1, \ldots, w_K\) is the function [9]:
Definition 12 (Mixture component) The densities \({\mathbb{p}_1}, \ldots, {\mathbb{p}_K}\) in a mixture (Definition 11) are its components.
LemTheorem 19 (A mixture is the density of a two-stage random variable)
Theorem 19 (A mixture is the density of a two-stage random variable) Let \(C\) be a discrete random variable and \(X\) a continuous random variable with joint density-mass function
\[\mathbb{p}(C = c,\, X = x) = w_c \, {\mathbb{p}_c}(x), \quad c \in {\mathopen{}\left\{1, \ldots, K\right\}\mathclose{}},\]
with \({\mathbb{p}_c}\) and \(w_c\) as in Definition 11. Then:
\(\mathbb{P}(C = c) = w_c\),
for each \(c\) with \(w_c > 0\), the conditional density of \(X\) given \(C = c\) is \({\mathbb{p}_c}\), and
the mixture \({\mathbb{p}_{\text{mix}}}\) is a density of \(X\).
\[
\begin{aligned}
\mathbb{p}(X = x \mid C = c) &= w_c \, {\mathbb{p}_c}(x) / w_c \\
&= {\mathbb{p}_c}(x).
\end{aligned}
\]
For the last claim, the events \({\mathopen{}\left\{C = 1\right\}\mathclose{}}, \ldots, {\mathopen{}\left\{C = K\right\}\mathclose{}}\) are mutually exclusive, and their union is the whole sample space. So for any interval \(B\):
\[
\begin{aligned}
\Pr(X \in B)
&= \sum_{c=1}^{K} \Pr(C = c,\, X \in B)
&& \text{(additivity over the events } {\mathopen{}\left\{C = c\right\}\mathclose{}} \text{)} \\
&= \sum_{c=1}^{K} \int_B w_c \, {\mathbb{p}_c}(x)\,dx
&& \text{(definition of a joint density-mass function)} \\
&= \int_B \sum_{c=1}^{K} w_c \, {\mathbb{p}_c}(x)\,dx
&& \text{(a finite sum of integrals is the integral of the sum)} \\
&= \int_B {\mathbb{p}_{\text{mix}}}(x)\,dx
&& \text{(definition of a mixture)}
\end{aligned}
\]
And \({\mathbb{p}_{\text{mix}}} \ge 0\), as a sum of non-negative terms, so \({\mathbb{p}_{\text{mix}}}\) is a density of \(X\).
RemarkRemark
Remark. Theorem 19 describes how to generate a draw from a mixture: first draw a component label \(C\) with \(\mathbb{P}(C = c) = w_c\), then draw \(X\) from the component density \({\mathbb{p}_C}\). In applications, \(C\) is often an unobserved subpopulation, such as a disease subtype. Mixtures of multivariate densities, such as mixtures of multivariate normal densities (Gaussian mixture models), work the same way, with \(p\)-variable densities in place of densities on \(\mathbb{R}\).
LemTheorem 20 (The mean of a mixture is the weighted mean of the component means)
Theorem 20 (The mean of a mixture is the weighted mean of the component means) If \(X\) has density \({\mathbb{p}_{\text{mix}}}\) (Definition 11), and each component \({\mathbb{p}_c}\) has a defined mean \(\mu_c = \int_{-\infty}^{\infty} x \, {\mathbb{p}_c}(x)\,dx\), then:
Proof. The integral defining \({\mathbb{E}\mathopen{}\left[X\right]\mathclose{}}\) converges absolutely, because \(\int_{-\infty}^\infty \mathopen{}\left|x\right|\mathclose{} \, {\mathbb{p}_{\text{mix}}}(x)\,dx = \sum_{c=1}^{K} w_c \int_{-\infty}^\infty \mathopen{}\left|x\right|\mathclose{} \, {\mathbb{p}_c}(x)\,dx\), a finite sum of finite numbers. Then:
\[
\begin{aligned}
{\mathbb{E}\mathopen{}\left[X\right]\mathclose{}}
&= \int_{-\infty}^{\infty} x \, {\mathbb{p}_{\text{mix}}}(x)\,dx
&& \text{(definition of expectation)} \\
&= \int_{-\infty}^{\infty} x \sum_{c=1}^{K} w_c \, {\mathbb{p}_c}(x)\,dx
&& \text{(definition of a mixture)} \\
&= \sum_{c=1}^{K} w_c \int_{-\infty}^{\infty} x \, {\mathbb{p}_c}(x)\,dx
&& \text{(a finite sum of integrals is the integral of the sum)} \\
&= \sum_{c=1}^{K} w_c \, \mu_c
&& \text{(definition of } \mu_c \text{)}
\end{aligned}
\]
LemTheorem 21 (Which component did an observation come from?)
Theorem 21 (Which component did an observation come from?) Under the conditions of Theorem 19, for each \(x\) with \({\mathbb{p}_{\text{mix}}}(x) > 0\):
\[
\mathbb{P}(C = c \mid X = x) = \frac{w_c \, {\mathbb{p}_c}(x)}{\sum_{k=1}^{K} w_k \, {\mathbb{p}_k}(x)}
\]
\[
\begin{aligned}
\mathbb{P}(C = c \mid X = x)
&= \frac{\mathbb{p}(C = c,\, X = x)}{\mathbb{p}(X = x)}
&& \text{(definition of the conditional PMF)} \\
&= \frac{w_c \, {\mathbb{p}_c}(x)}{\sum_{k=1}^{K} w_k \, {\mathbb{p}_k}(x)}
&& \text{(substitute the joint density-mass function and } {\mathbb{p}_{\text{mix}}} \text{)}
\end{aligned}
\]
RemarkRemark
Remark. Theorem 21 has the form of Bayes’ theorem, with densities in place of some probabilities: the prior probability \(w_c\) of component \(c\) is multiplied by the component density \({\mathbb{p}_c}(x)\) at the observation and divided by the overall density \({\mathbb{p}_{\text{mix}}}(x)\), which plays the role of the law of total probability.
DefDefinition 13 (Responsibility of a mixture component)
Definition 13 (Responsibility of a mixture component) In the setting of Theorem 21, the conditional probability \(\mathbb{P}(C = c \mid X = x)\) is called, in machine learning, the responsibility of component \(c\) for \(x\).
Example 20 (A two-component normal mixture) Let \({\mathbb{p}_1}\) be the \({\operatorname{N}\mathopen{}\left(0, 1\right)\mathclose{}}\) density and \({\mathbb{p}_2}\) the \({\operatorname{N}\mathopen{}\left(6, 1\right)\mathclose{}}\) density, with mixing weights \(w_1 = 0.3\) and \(w_2 = 0.7\), and let \(X\) have density \({\mathbb{p}_{\text{mix}}} = 0.3\,{\mathbb{p}_1} + 0.7\,{\mathbb{p}_2}\).
Density.\({\mathbb{p}_{\text{mix}}}\) has peaks near the two component means, \({\mathbb{p}_{\text{mix}}}(0) \approx 0.120\) and \({\mathbb{p}_{\text{mix}}}(6) \approx 0.279\), with a trough between them, \({\mathbb{p}_{\text{mix}}}(3) \approx 0.004\). The density at the mean, \({\mathbb{p}_{\text{mix}}}(4.2) \approx 0.055\), is less than half its value at either peak.
Responsibilities. By Theorem 21, at \(x = 3\), halfway between the component means, \({\mathbb{p}_1}(3) = {\mathbb{p}_2}(3)\) by the symmetry of the normal density, so:
the prior weight: an observation equally far from both components carries no information about which component it came from. At \(x = 4.2\), the same formula gives \(\mathbb{P}(C = 2 \mid X = 4.2) \approx 0.9997\).
RemarkRemark
Remark. Example 20 shows that the mean of a mixture can fall where observations are rare, so a single normal distribution fitted to such data would describe them poorly.
ExmExample 21 (The negative binomial as a continuous mixture)
Example 21 (The negative binomial as a continuous mixture) The negative binomial distribution is a mixture of Poisson distributions with a continuum of components, one for each mean \({\lambda}> 0\): its PMF is \(\mathbb{P}(Y = y) = \int_0^\infty g({\lambda})\,\frac{{\lambda}^y e^{-{\lambda}}}{y!}\,d{\lambda}\), where the gamma density \(g\) plays the role of the mixing weights and the integral replaces the sum in Definition 11 (see the proof of Theorem 11).