% !TEX root = main.tex
%=====================================================================
\chapter{General linear models}\label{chap:bivariate_analysis}
\startcontents[chapters]
\chapcontents

%-------------------------------------------------
\section{The chi-squared distribution}\label{sec:chi-squared}

If $Z_1,Z_2,\ldots,Z_n$ are independent standard normal %$N(0,1)$
variables, the sum-of-squares
$\displaystyle\sum_{i=1}^n Z_i^2$
has the \emph{chi-squared distribution} with $n$ degrees of freedom, which plays a central role in statistics.

%--------------------------------------------------
\subsection{The gamma distribution}
%--------------------------------------------------
\begin{definition}\label{def:gamma_distribution}
The \emph{gamma distribution} with parameters $k>0$ and $\theta>0$ is defined by the PDF
\[
f(x) = \begin{cases}
	\displaystyle\frac{1}{\Gamma(k)\theta^k}\,x^{k-1} e^{-x/\theta} & \text{for $x>0$}, \\
	0																& \text{otherwise.}
\end{cases}
\]
where $\Gamma(k)$ is the so-called \emph{gamma function},
\[
\Gamma(k) = \int_0^{\infty} t^{k-1}e^{-t}\,dt.
\]
%which is defined for all $k>0$.
\end{definition}

Note that if $X\sim\text{Exponential}(\theta)$ where $\theta$ is a scale parameter, then $X\sim\text{Gamma}(1,\theta)$.

\begin{lemma}
The MGF of the $\text{Gamma}(k,\theta)$ distribution is $M(t) = \displaystyle\frac{1}{(1-\theta t)^k}$, defined for $t<\displaystyle\frac{1}{\theta}$.
%for $t<\theta^{-1}$.
\end{lemma}

\begin{proof} % leave as exercise
Let $X\sim\text{Gamma}(k,\theta)$. Then
\begin{align*}
M_X(t) = \expe(e^{tX})
	& = \int_0^\infty e^{tx} \frac{1}{\Gamma(k)\theta^k}\,x^{k-1} e^{-x/\theta}\,dx \\
	& = \int_0^\infty \frac{1}{\Gamma(k)\theta^k}\,x^{k-1} e^{-x(1-\theta t)/\theta}\,dx
\end{align*}
Changing the variable of integration, let $y=x(1-\theta t)/t$ where $t<1/\theta$. Then $x=\theta y/(1-\theta t)$ so
\begin{align*}
M_X(t)
	& = \int_0^\infty \frac{\theta/(1-\theta t)}{\Gamma(k)\theta^k}\left(\frac{\theta y}{1-\theta t}\right)^{k-1} e^{-y}\,dy \\
	& = \left(\frac{1}{1-\theta t}\right)^{k} \int_0^\infty \frac{1}{\Gamma(k)}y^{k-1} e^{-y}\,dy \\
	& = \left(\frac{1}{1-\theta t}\right)^{k} \qquad\text{for } t < \frac{1}{\theta}.
\end{align*}
\end{proof}

% corollary: mean and variance
\begin{corollary}
If $X\sim\text{Gamma}(k,\theta)$, then $\expe(X) = k\theta$ and $\var(X) = k\theta^2$.
\end{corollary}
% proof
\begin{proof}
\begin{align*}
M'(t)	& = (-k)(1-\theta t)^{-k-1}(-\theta) \\
M''(t)	& = (-k)(-k-1)(1-\theta t)^{-k-2}(-\theta)^2
\end{align*}
Hence,
\begin{align*}
\expe(X)	& = M'(0) = k\theta, \\
\var(X)		& = M''(0)- M'(0)^2 = k(k+1)\theta^2 - k^2\theta^2 = k\theta^2.
\end{align*}
\end{proof}

We now derive two useful properties of the gamma disribution.
% lemma: sum of two independent
\begin{lemma}\label{lem:properties_of_gamma_distribution}
\ben
\it If $X\sim\text{Gamma}(k,\theta)$ and $a\in\R$ is a constant, then $aX\sim\text{Gamma}(k,a\theta)$.
\it If $X_1\sim\text{Gamma}(k_1,\theta)$ and $X_2\sim\text{Gamma}(k_2,\theta)$ are independent, then $X_1+X_2\sim\text{Gamma}(k_1+k_2,\theta)$.
\een
\end{lemma}
\begin{proof}
\ben
\it
\[
M_{aX}(t) = \expe(e^{t(aX)}) = \expe(e^{(at)X}) = M_X(at) = \frac{1}{\big(1-\theta (at)\big)^k} = \frac{1}{\big(1-(a\theta)t\big)^k}
\]
whidh is the MGF of the $\text{Gamma}(k,a\theta)$ distribution.
\it
The $MGFs$ of $X_1$ and $X_2$ are:
\[
M_{X_1}(t) = \frac{1}{(1-\theta t)^{k_1}}
\quad\text{and}\quad
M_{X_2}(t) = \frac{1}{(1-\theta t)^{k_2}},
\]
and since $X_1$ and $X_2$ are independent,
\[
M_{X_1+X_2}(t)
=	M_{X_1}(t)M_{X_2}(t)
= \frac{1}{(1-\theta t)^{k_1+k_2}}
\]
which is the MGF of the $\text{Gamma}(k_1+k_2,\theta)$ distribution.
\een
\end{proof}

%-----------------------------
\subsection{The $\chi^2$ distribution}

% defn: chi-squared distribution
\begin{definition}\label{defn:chisquared_dist}
The $\chi^2_{n}$ distribution is defined by the PDF
\[
f(x) = \begin{cases}
	\displaystyle\frac{1}{\Gamma(n/2)2^{n/2}}\,x^{n/2-1} e^{-x/2} & \text{for $x>0$}, \\
	0																	& \text{otherwise,}
\end{cases}
\]
where the parameter $n$ is called the \emph{degrees of freedom}.
\end{definition}

The $\chi^2_{n}$ distribution is a special case of the $\Gamma(k,\theta)$ distribution, with $k=n/2$ and $\theta=2$. Thus if $X\sim\chi^2_{n}$, it follows that
\bit
\it $M_X(t) = (1-2t)^{-n/2}$ for $t<1/2$;
\it $\expe(X) = n$ and $\var(X)=2n$.
\eit

% corollary
We also have the following corollary of Lemma~\ref{lem:properties_of_gamma_distribution}.
\begin{corollary}\label{cor:sum_of_two_independent_chisquared}
If $X_1\sim\chi^2_{m}$ and $X_2\sim\chi^2_{n}$ are independent, then $X_1+X_2\sim\chi^2_{m+n}$.
\end{corollary}

Next we show that the square of a standard normal variable has $\chi^2_1$ distribution.
% lemma
\begin{lemma}\label{lem:standard_normal_squared}
If $Z\sim N(0,1)$ then $Z^2\sim\chi^2_{1}$.
\end{lemma}
\begin{proof}
Let $U=Z^2$. Then the CDF of $U$ (for $u\geq 0$) is
\[
F(u) = \prob(U\leq u) = \prob(-\sqrt{u}\leq Z \leq \sqrt{u})
\]
which (by symmetry) we can write as
\[
F(u) = \int_{0}^{\sqrt{u}}\frac{1}{\sqrt{2\pi}} e^{-u^2/2}\,du
\]
for $u\geq 0$ (and zero otherwise). Now change the variable of integration by writing $y=u^2$:
\[
F(u) = \int_{0}^{\sqrt{y}}\frac{1}{\sqrt{2\pi}}\frac{1}{\sqrt{y}} e^{-y/2}\,dy \quad(v\geq 0).
\]
Hence the PDF $f(u) = F'(u)$ is
\[
f(u) = \frac{1}{\sqrt{2\pi}} u^{1/2} e^{-u/2}
\]
for $u\geq 0$ (and zero otherwise). Since $\Gamma(1/2)=\sqrt{\pi}$, this is the PDF of the $\chi^2_1$ distribution.
\end{proof}

% corollary
Corollary~\ref{cor:sum_of_two_independent_chisquared} and Lemma~\ref{lem:standard_normal_squared} combine to yield the following.
\begin{corollary}
If $Z_1,Z_2,\ldots,Z_n$ are independent standard normal variables, then $\displaystyle\sum_{i=1}^n Z_i^2\sim\chi^2_n$.
\end{corollary}

%--------------------------------------------------
\subsection{The non-central chi-squared distribution}
%--------------------------------------------------
\begin{definition}
Let $X_1,X_2,\ldots,X_n$ be independent random variables with $X_i\sim N(\mu_i,1)$. The distribution of the sum-of-squares
\[
W=\sum_{i=1}^n X_i^2
\]
is called the \emph{non-central chi-squared distribution}, with $n$ degrees of freedom and non-centrality parameter
\[
\lambda = \sum_{i=1}^n \mu_i^2.
\]
\end{definition}
We write this as $W\sim\chi^2_n(\lambda)$, in which case
\[
\expe(W)=n+\lambda \quad\text{and}\quad \var(W)=2(n+2\lambda).
\]

When $\lambda=0$, all $\mu_i$ must be zero and the $\chi^2_n(\lambda)$ distribution reduces to the ordinary $\chi^2_n$ distribution. Any non-zero mean $\mu_i$ increases the value of $\lambda$, and hence increases $\expe(W)$ and $\var(W)$ compared to those of the ordinary $\chi^2_n$ distribution.

%--------------------------------------------------
\subsubsection{One-sample test of variance}
%--------------------------------------------------
Let $X_1,X_2,\ldots,X_n$ be a random sample from the $N(\mu,\sigma^2)$ distribution, and consider the null hypothesis $H_0:\sigma^2=\sigma_0^2$ against a suitable alternative, where $\sigma_0>0$ is fixed. If $\mu$ is known, we use the test statistic
\[
T = \sum_{i=1}^n \left(\frac{X_i-\mu}{\sigma_0}\right)^2 \sim \chi^2_n \quad\text{under $H_0$.}
\]
If $\mu$ is unknown, we replace it by the sample mean $\bar{X}$, in which case $T\sim\chi^2_{n-1}$.

%Under the alternative hypothesis $H_1:\sigma^2\neq\sigma^2_0$,
%\[
%T(\mathbf{X}) = \left(\frac{\sigma}{\sigma_0}\right)^2\sum_{i=1}^n\left(\frac{X_i-\mu}{\sigma}\right)^2
%\]
%Because the $\chi^2_n$ distribution is a special case of the $\text{Gamma}(k,\theta)$ distribution with $k=n/2$ and $\theta=2$, it follows by Lemma\ref{lem:properties_of_gamma_distribution} that $T\sim\text{Gamma}(n/2, 2(\sigma/\sigma_0)^2)$, for which $\expe(T)=n(\sigma/\sigma_0)^2$ and $\var(T)=2n(\sigma/\sigma_0)^4$. Thus,
%\bit
%\it for $H_1:\sigma<\sigma_0$, the probability mass shifts to the left, so we need a lower-tail test;
%\it for $H_1:\sigma>\sigma_0$, the probability mass shifts to the right, so we need an upper-tail test.
%\eit.

\begin{exercise} %[One-sample test of variance]
A quality control supervisor at a paint factory knows that the exact amount each tin contains will vary due to certain uncontrollable factors that affect the amount of fill. The mean fill is important, but equally important is the variation of each fill. If the variance $\sigma^2$ of the fill is large, some tins will contain too much and others too little. A regulatory agency specifies that the variance of the amount of fill in 250ml tins should be less than $3$. To determine whether or not the process is meeting this specification, the supervisor randomly selects 10 tins and measures the contents of each tin. The mean fill over the sample is found to be $250.78$, and the sample variance is $s^2 = 1.03$. Does the data indicate that the factory is operating within the regulatory limits?
\begin{answer}
We wish to test the null hypothesis $H_0:\sigma^2 = 3$ against the alternative $H_1:\sigma^2 < 3$. We assume that the distribution of the fill amounts is approximately normal, and consider the test statistic
\[
T = \sum_{i=1}^{n} \left(\frac{X_i-\bar{X}}{\sigma}\right)^2 = \frac{(n-1)s^2}{\sigma^2},
\]
where $s^2$ is the sample variance of the fill amounts. Taking $n=10$, the distribution of our test statistic under the null hypothesis $H_0:\sigma^2 = 3$ is
\[
T \sim \chi^2_9.
\]
\bit
\it From tables, the critical value for a lower-tailed test at $\alpha=0.05$ is $T_{0.95} = 3.326$.
\it The observed value of the test statistic (under the null hypothesis) is
\[
T = \frac{(n-1)s^2}{\sigma^2} = \frac{9\times 1.03}{3} = 3.09.
\]
\eit
The test statistic lies in the rejection region, so the supervisor can reject $H_0:\sigma^2=3$ and conclude that the variance of the fill amounts is less than $3$. The supervisor can be confident that the factory is operating within the desired limits of variability.
\end{answer}
\end{exercise}
%%--------------------------------------------------
%\subsubsection{One-sample tests}
%%--------------------------------------------------
%Let $X\sim N(\mu,\sigma^2)$.
%
%\ben
%\it % \mu unknown, \sigma^2 known
%If $\mu$ is unknown but $\sigma^2$ is known, a test statistic for $H_0:\mu=\mu_0$ against a suitable alternative is the standardized sum
%\[
%Z(\mathbf{X}) = \frac{1}{\sqrt{n}}\sum_{i=1}^n\left(\frac{X_i-\mu_0}{\sigma}\right) \quad\sim N(0,1) \text{ under $H_0:\mu=\mu_0$.}
%\]
%\bit
%If $\sigma^2$ also unknown, we replace it by the sample variance $s^2$, in which case $Z\sim t_{n-1}$ under $H_0$.
%\eit
%
%If $\mu\neq\mu_0$, then $X -\mu_0\sim N(\mu-\mu_0,\sigma^2)$, so
%\[
%Z(\mathbf{X})
%%	= \frac{1}{\sqrt{n}}\sum_{i=1}^n\left(\frac{X_i-\mu_0}{\sigma}\right)
%	= \frac{1}{\sqrt{n}}\sum_{i=1}^n\left(\frac{X_i-\mu}{\sigma} + \frac{\mu-\mu_0}{\sigma}\right)
%\]
%in which case $Z\sim N(\mu-\mu_0,1)$.
%
%Another test statistic for $H_0:\mu=\mu_0$ is the standardized \emph{sum-of-squares},
%\[
%T(\mathbf{X}) = \sum_{i=1}^n\left(\frac{X_i-\mu_0}{\sigma}\right)^2  \quad\sim\chi^2_n \text{ under $H_0:\mu=\mu_0$.}
%\]
%
%\bit
%\it If $\mu\neq\mu_0$, $T\sim\chi^2_n(\lambda)$ where $\lambda= n(\mu-\mu_0)^2$.
%\eit
%
%\it % \mu known, \sigma^2 unknown
%If $\mu$ is known but $\sigma^2$ is unknown, the standardized sum-of-squares can also be used as a test statistic for $H_0:\sigma^2=\sigma^2_0$ against a suitable alternative,
%\[
%T(\mathbf{X}) = \sum_{i=1}^n\left(\frac{X_i-\mu}{\sigma_0}\right)^2  \quad\sim\chi^2_n \text{ under $H_0:\sigma^2=\sigma^2_0$.}
%\]
%\bit
%\it If $\mu$ is also unknown we replace it by the sample mean $\bar{X}$, in which case $T\sim\chi^2_{n-1}$ under $H_0$.
%\eit
%
%Under the alternative $H_1:\sigma^2\neq\sigma^2_0$,
%\[
%T(\mathbf{X})
%%	= \sum_{i=1}^n\left(\frac{X_i-\mu}{\sigma_0}\right)^2
%	= \left(\frac{\sigma}{\sigma_0}\right)^2\sum_{i=1}^n\left(\frac{X_i-\mu}{\sigma}\right)^2
%\]
%in which case $T\sim\text{Gamma}(n/2, 2(\sigma/\sigma_0)^2)$, for which $\expe(T)=n(\sigma/\sigma_0)^2$ and $\var(T)=2n(\sigma/\sigma_0)^4$.
%
%%\begin{remark}
%%If $\sigma^2$ unknown, we replace it by the sample variance $s^2$, in which case $Z\sim t_{n-1}$ under $H_0$.
%%If $\mu$ is unknown, we replace it by the sample mean $\bar{X}$, in which case $T\sim\chi^2_{n-1}$ under $H_0$.
%%\end{remark}
%
%%--------------------------------------------------
%\subsubsection{Two-sample tests}
%%--------------------------------------------------
%Let $X\sim N(\mu_1,\sigma^2)$ and $Y\sim N(\mu_2,\sigma^2)$
%

%====================================================================
\subsection{The $F$ distribution}
%====================================================================
\begin{definition}
Let $T_1$ and $T_2$ be independent random variables with $T_1\sim\chi^2_m$ and $T_2\sim\chi^2_n$. The distribution of the ratio
\[
F = \frac{T_1/m}{T_2/n}.
\]
is called the \emph{$F$-distribution with $m$ and $n$ degrees of freedom}, and denoted by $F\sim F_{m,n}$.
\end{definition}

%--------------------------------------------------
\subsubsection{Two-sample tests of variance}
%--------------------------------------------------
Let $X_1,X_2,\ldots,X_m$ be a random sample from the $N(\mu_1,\sigma_1^2)$ distribution, let $Y_1,Y_2,\ldots,Y_n$ be an independent random sample from the $N(\mu_2,\sigma_2^2)$ distribution, and consider the null hypothesis $H_0:\sigma_1^2 = \sigma_2^2$ against a suitable alternative.

%If $\mu_1$ and $\mu_2$ are known, we use the ratio of the sample mean estimatorss of variance:

\ben
\it % known means
If $\mu_1$ and $\mu_2$ are known, we use the ratio of the sample mean estimators of variance as a test statistic,
\[
F 	= \frac{\hat{\sigma}_1^2}{\hat{\sigma}_2^2}
	= \frac{\displaystyle\frac{1}{m}\sum_{i=1}^m (X_i-\mu_1)^2}{\displaystyle\frac{1}{n}\sum_{j=1}^n (Y_i-\mu_2)^2}
	= \frac{
		\displaystyle\sigma_1^2\left[\frac{1}{m}\sum_{i=1}^m \left(\frac{X_i-\mu_1}{\sigma_1}\right)^2\right]
	}{
		\displaystyle\sigma_2^2\left[\frac{1}{n}\sum_{j=1}^n \left(\frac{Y_j-\mu_2}{\sigma_2}\right)^2\right]
	}.
\]
Under $H_0:\sigma_1^2 = \sigma_2^2$, this statistic has the $F_{m,n}$ distribution.
\it % unknown means
If $\mu_1$ and $\mu_2$ are unknown, we use the ratio of the sample variances as a test statistic,
\[
F 	= \frac{s_1^2}{s_2^2}
	= \frac{\displaystyle\frac{1}{m-1}\sum_{i=1}^m (X_i-\bar{X})^2}{\displaystyle\frac{1}{n-1}\sum_{j=1}^n (Y_i-\bar{Y})^2}
	= \frac{
		\displaystyle\sigma_1^2\left[\frac{1}{m-1}\sum_{i=1}^m \left(\frac{X_i-\bar{X}}{\sigma_1}\right)^2\right]
	}{
		\displaystyle\sigma_2^2\left[\frac{1}{n-1}\sum_{j=1}^n \left(\frac{Y_j-\bar{Y}}{\sigma_2}\right)^2\right]
	}.
\]
Under $H_0:\sigma_1^2 = \sigma_2^2$, this ratio has the $F_{m-1,n-1}$ distribution.
\een

\bit
\it For $H_1:\sigma_1<\sigma_2$, the probability mass shifts to the left so we need a lower-tail test;
\it for $H_1:\sigma_1>\sigma_2$, the probability mass shifts to the right so we need an upper-tail test.
\eit.

Note that statistical tables usually only give upper-tail percentage points: if necessary, we can convert between the two using the fact that if $F\sim F_{m,n}$, then $1/F\sim F_{n,m}$.

\begin{exercise}%[two-sample test of variance]
A researcher wants to compare the metabolic rates of white mice subjected to different drugs. The weights of the mice may affect their metabolic rates, so the researcher wishes to obtain mice that are relatively homogeneous with respect to weight. Five hundred mice will be needed to complete the study. Currently, 18 mice from supplier 1 and another 13 mice from supplier 2 are available for comparison. The researcher weighs these mice and finds that the sample standard deviations are $s_1=0.2021$ and $s_2=0.0982$ respectively. Is there sufficient evidence to indicate a significant difference in the variability of the weight of mice obtained from the two suppliers at the $\alpha=0.1$ level?
\begin{answer}
Let $\sigma^2_1$ and $\sigma^2_2$ be the population variances for mice from Supplier 1 and Supplier 2 respectively. The null hypothesis is $H_0:\sigma^2_1=\sigma^2_2$, and our test statistic is the ratio of the sample variances,
\[
F = \frac{s^2_1}{s^2_2}
\]
\bit
\it We reject $H_0$ if the observed $F$-ratio exceeds the tabulated value $F_{1-\alpha/2}=F_{0.95} = 2.38$.
\it The observed value is $F=(0.2021)^2/(0.0982)^2=4.24$.
\eit
The observed value lies in the rejection region, so we reject the null hypothesis and conclude that the weights of mice from Supplier 2 tend to be more homogeneous that the weights of mice from Supplier 1.
\end{answer}
\end{exercise}

%-------------------------------------------------
\section{Analysis of variance}\label{sec:anova}

Analysis-of-variance (ANOVA) is a way of testing hypotheses about means by looking at sample variances. Consider a population consisting of $k$ groups. We assume that all observations are independent and normally distributed with the same variance, but whose means might be different depending on the group to which they belong.

\medskip
Let $\mu_i$ denote the mean of the $i$th group. We wish to test the null hypothesis that all group means are equal, against the alternative that they are not:
\begin{align*}
& H_0:\ \mu_1=\mu_2=\ldots=\mu_k, \\
& H_1:\ \mu_i\neq\mu_j \text{ for some } i\neq j.
\end{align*}

\medskip
Suppose we obtain an independent random sample of observations from each group:
\bit
\it $(Y_{11}, Y_{12}, \ldots, Y_{1n_1})$ where $Y_{1j}\sim N(\mu_1,\sigma^2)$,
\it $(Y_{21}, Y_{22}, \ldots, Y_{2n_2})$ where $Y_{2j}\sim N(\mu_2,\sigma^2)$,
\it[] $\ldots$
\it $(Y_{k1}, Y_{k2}, \ldots, Y_{kn_k})$ where $Y_{kj}\sim N(\mu_k,\sigma^2)$.
\eit

%\bit
%\it Groups are indexed by $i=1,2,\ldots,k$.
%\it Observations within the $i$th group are indexed by $j=1,2,\ldots,n_i$.
%\it We assume that all observations are independent and have equal variance.
%\eit

%====================================================================
\subsection{The test statistic}
%====================================================================

\bit
\it Let $N=\sum_{i=1}^k n_i$ be the total number of observations.
\it Let $\bar{Y}_i = \frac{1}{n_i}\sum_{j=1}^{n_i} Y_{ij}$ be the sample mean of the $i$th group.% (for $i=1,2,\ldots k$).
\it Let $\bar{Y} = \frac{1}{N}\sum_{i=1}^k\sum_{j=1}^{n_i} Y_{ij}$ be the overall sample mean.
\eit

The total deviation of a single observation from the overall sample mean can be divided into two components:
\[
\begin{array}{ccccc}
(Y_{ij}-\bar{Y})		& = & (Y_{ij}-\bar{Y}_i)			& + & (\bar{Y}_i-\bar{Y})  \\[1ex]
\text{Total deviation} 	& 	& \text{Unexplained deviation}	& 	& \text{Explained deviation}
\end{array}
\]

To test the null hypothesis $H_0:\mu_1=\mu_2=\ldots=\mu_k$, we define the following sums-of-squares:

%Under $H_0$, we have independent estimates of $\sigma^2$:
%\bit
%\it Between groups: $\frac{1}{k-1}\sum_{i=1}^{k}(\bar{Y}_{i\cdot} - \bar{Y}_{..})^2$
%\it Within groups: $\frac{1}{n_i-1}\sum_{j=1}^{n_i}(Y_{ij} - \bar{Y}_{i\cdot})^2$
%\eit
%
%
%
%
\[
\begin{array}{lll}
SST	& = \displaystyle\sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y})^2.
\qquad\qquad & \text{The \textbf{total} sum-of-squares.} \\
SSG	& = \displaystyle\sum_{i=1}^k n_i (\bar{Y}_i-\bar{Y})^2.
\qquad & \text{The \textbf{between-groups} sum-of-squares.} \\
SSE	& = \displaystyle\sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_i)^2.
\qquad & \text{The \textbf{error} sum-of-squares.} \\
\end{array}
\]

The following lemma is easily proved.
\begin{lemma}
$SST = SSG + SSE$.
\end{lemma}
%\begin{proof}
%Exercise.
%\begin{align*}
%S_T
%	& = \sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{\cdot\cdot})^2 \\
%	& = \sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{i\cdot}+\bar{Y}_{i\cdot}-\bar{Y}_{\cdot\cdot})^2 \\
%	& = \sum_{i=1}^k\sum_{j=1}^{n_i} \big[(Y_{ij}-\bar{Y}_{i\cdot})^2 + 2(Y_{ij}-\bar{Y}_{i\cdot})(\bar{Y}_{i\cdot}-\bar{Y}_{\cdot\cdot})+ (\bar{Y}_{i\cdot}-\bar{Y}_{\cdot\cdot})^2\big] \\
%	& = \sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{i\cdot})^2 + \sum_{i=1}^k n_i(\bar{Y}_{i\cdot}-\bar{Y}_{\cdot\cdot})^2 \\
%	& = S_E + S_G.
%\end{align*}
%\end{proof}

%\bit
%\it $S_T$ is the total squared deviation,
%\it $S_G$ is the squared deviation explained by group membership,
%\it $S_E$ is the residual squared deviation.
%\it Note that $SST = SSG + SSE$.
%\it[]
%\it If the ratio $SS_G/SS_E$ is large, we might be inclined to reject the null hypothesis that all group means are equal.
%\eit
Intuitively, if the ratio $SSG/SSE$ is large, we might be inclined to reject the null hypothesis that all group means are equal.

% lemma: distribution of SS_E
\begin{lemma}[The distribution of $SSE$]
\[
%\frac{SS_E}{\sigma^2} =
\frac{1}{\sigma^2}\sum_{i=1}^k\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2 \sim \chi^2_{N-k}.
\]
\end{lemma}

\begin{proof}
For the $i$th group we have $Y_{ij}\sim N(\mu_i,\sigma^2)$ so by independence,
\[
\frac{1}{\sigma^2}\sum_{j=1}^{n_i}(Y_{ij}-\mu_i)^2 \sim \chi^2_{n_i}.
\]
Replacing the unknown expectation $\mu_i$ by the sample mean $\bar{Y}_i$, we obtain
\[
\frac{1}{\sigma^2}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2 \sim \chi^2_{n_i-1}.
\]
By Corollary~\ref{cor:sum_of_two_independent_chisquared}, if $U\sim\chi^2_m$ and $V\sim\chi^2_n$ then $U+V\sim\chi^2_{m+n}$, so
\[
\frac{1}{\sigma^2}\sum_{i=1}^k\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2 \sim \chi^2_{N-k}.
\]
%as required.
\end{proof}

% lemma: distribution of SS_G
\begin{lemma}[The distribution of $SSG$]\label{lem:ssg}
Let $\mu$ be the expected value of the $Y_{ij}$ across the entire population. Then
\[
\frac{1}{\sigma^2}\sum_{i=1}^k n_i (\bar{Y}_i - \bar{Y})^2 \sim \chi^2_{k-1}(\lambda)
\quad\text{where}\quad\lambda = \sum_{i=1}^k n_i(\mu_i-\mu)^2.
\]
\end{lemma}

% proof
\begin{proof}
For the $i$th group we have $\bar{Y}_i \sim N(\mu_i,\sigma^2/n_i)$, so
\[
\sqrt{n_i}\left(\frac{\bar{Y}_i - \mu}{\sigma}\right) \sim N(\mu_i-\mu,1)
\]
Because all observations are independent of each other the $\bar{Y}_i$ are also independent, so
\[
\sum_{i=1}^k n_i\left(\frac{\bar{Y}_i - \mu}{\sigma}\right)^2 \sim \chi^2_{k}(\lambda)
\quad\text{where}\quad \lambda = \sum_{i=1}^k(\mu_i-\mu)^2.
\]
Finally, replacing the unknown expectation $\mu$ by the sample mean $\bar{Y}$, we obtain
\[
\frac{1}{\sigma^2}\sum_{i=1}^k n_i (\bar{Y}_i - \bar{Y})^2 \sim \chi^2_{k-1}(\lambda).
\]
%as required.
\end{proof}

% remark
\begin{remark}
Under the null hypothesis, each group mean $\mu_i$ is equal to the population mean $\mu$, in which case $\lambda=0$ and hence $SS_G/\sigma^2 \sim \chi^2_{k-1}$. Otherwise we must have $SS_G/\sigma^2 \sim \chi^2_{k-1}(\lambda)$ where $\lambda>0$, in which case $SS_G/\sigma^2$ is likely to be larger than it would be if $H_0$ is true.
\end{remark}

\begin{theorem}[Test Statistic for ANOVA]
Let
\[
s^2_G = \frac{1}{k-1}\sum_{i=1}^k n_i (\bar{Y}_i-\bar{Y})^2
\quad\text{and}\quad
s^2_E = \frac{1}{N-k}\sum_{i=1}^k\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_i)^2,
\]
and define the test statistic $F = s^2_G/s^2_E$. Under the null hypothesis $H_0:\mu_1=\mu_2=\ldots=\mu_k$, %this has the $F_{k-1,N-k}$ distribution.
\[
%F = \displaystyle\frac{s^2_G}{s^2_E} \sim F_{k-1,N-k}.
%F = s^2_G/s^2_E \sim F_{k-1,N-k}.
F \sim F_{k-1,N-k}.
\]
\end{theorem}

\begin{remark}
%By Lemma~\ref{lem:ssg}, if $H_0$ does not hold then $SSG/\sigma^2\sim\chi^2(\lambda)$ where $\lambda>0$, so $F$ is likely to be larger than it would be if $H_0$ is true.
By the previous remark, we see that an upper-tail test is required: $H_0$ is rejected whenever $F > F_{\alpha}$, where $F_{\alpha}$ is the upper-tail critical value of the $F_{k-1,N-k}$ distribution at significance level $\alpha$.
\end{remark}

The various statistics computed during a one-way analysis of variance are usually reported in tabular form:
\begin{center}
\begin{tabular}{|l|c|c|c|c|} \hline
Source 			& \qquad df\qquad\mbox{}& \qquad SS\qquad\mbox{}& \qquad MS\qquad\mbox{}& \qquad F\qquad\mbox{}	\\ \hline
Between Groups	& $k-1$					& $SSG$					& $s^2_G$				& $F = s^2_G/s^2_E$		\\ \hline
Error 			& $N-k$					& $SSE$					& $s^2_E$				&						\\ \hline
Total			& $N-1$					& $SST$					& 						& 						\\ \hline
\end{tabular}\par
\end{center}

\begin{example}
The data below are the yields (per hectare) of eight types of wheat, recorded over four independent trials.
\[
\begin{array}{|c|cccc|}\hline
\text{Type}	& \multicolumn{4}{c|}{\text{Yield}} \\ \hline
1 &  182 & 214 & 216 & 231 \\
2 &  196 & 202 & 208 & 224 \\
3 &  203 & 212 & 221 & 242 \\
4 &  198 & 203 & 207 & 222 \\
5 &  171 & 192 & 197 & 204 \\
6 &  194 & 218 & 223 & 232 \\
7 &  208 & 216 & 218 & 239 \\
8 &  183 & 188 & 193 & 198 \\ \hline
\end{array}
\]
Perform an analysis-of-variance to determine whether there are significant differences among the mean yields of the eight types.
\end{example}

\begin{solution}
%\[
%\begin{array}{|c|cccc|r|r|}\hline
%\text{Type} (i)	& \multicolumn{4}{c|}{\text{Yield}} & \sum_j X_{ij} &  \sum_j X_{ij}^2 \\ \hline
%1 				&  182 & 214 & 216 & 231 	&  843 &  178937 \\
%2 				&  196 & 202 & 208 & 224 	&  830 &  172660 \\
%3 				&  203 & 212 & 221 & 242 	&  878 &  193558 \\
%4 				&  198 & 203 & 207 & 222 	&  830 &  172546 \\
%5 				&  171 & 192 & 197 & 204 	&  764 &  146530 \\
%6 				&  194 & 218 & 223 & 232 	&  867 &  188713 \\
%7 				&  208 & 216 & 218 & 239 	&  881 &  194565 \\
%8 				&  183 & 188 & 193 & 198 	&  762 &  145286 \\ \hline
%\text{Overall}	&      &     &     &    		& 6655 & 1392795 \\ \hline
%\end{array}
%\]
Tedious calculations yield the following sums-of-squares:
\[
SST = 8762.9688,\quad SSG = 3848.71875 \text{\quad and\quad} SSE = 4914.2.
\]

%The sums of squares are computed as follows:
%\begin{align*}
%S_T
%	& = \sum_{i=1}^k \sum_{j=1}^{n_i} (X_{ij}-\bar{X}_{\cdot\cdot})^2 \\
%	& = \sum_{i=1}^k \sum_{j=1}^{n_i} X_{ij}^2 - \frac{1}{N}\left(\sum_{i=1}^k\sum_{j=1}^{n_i} X_{ij}\right)^2 \\
%	& = (182^2 + 214^2 + \ldots + 762^2) - \frac{6655^2}{32} \\
%	& = 1392795 - 1384032.03125 = 8762.96875 \\
%\end{align*}
%
%\begin{align*}
%S_G
%	& = \sum_{i=1}^k n_i(\bar{X}_{i\cdot}-\bar{X}_{\cdot\cdot})^2 \\
%	& = \sum_{i=1}^k \frac{1}{n_i}\left(\sum_{j=1}^{n_i} X_{ij}\right)^2
%			- \frac{1}{N}\left(\sum_{i=1}^k\sum_{j=1}^{n_i} X_{ij}\right)^2 \\
%	& \left(\frac{843^2}{4} + \frac{830^2}{4} +\ldots+ \frac{762^2}{4}\right) - \frac{6655^2}{32} \\
%	& = 1387880.75 - 1384032.03125 = 3848.71875.
%\end{align*}
%\begin{align*}
%S_E
%	& = \sum_{i=1}^k \sum_{j=1}^{n_i} (X_{ij}-\bar{X}_{i\cdot})^2  \\
%	& = \sum_{i=1}^k \sum_{j=1}^{n_i} X^2_{ij} - \sum_{i=1}^k \frac{1}{n_i}\left(\sum_{j=1}^{n_i} X_{ij}\right)^2 \\
%	& = (182^2 + 214^2 + \ldots + 762^2) - \left(\frac{843^2}{4} + \frac{830^2}{4} +\ldots+ \frac{762^2}{4}\right) \\
%	& = 1392795 - 1387880.75 = 4914.25 \\
%\end{align*}
%Check: $S_G + S_E = 3848.77 + 4914.20 = 8762.9 = S_0$.

The ANOVA table is:
\begin{center}
\begin{tabular}{|l|c|c|c|c|} \hline
Source			& df	& SS		& MS		& F 			\\ \hline
Between-Groups	& 7		& 3848.72	& 549.8170	& 2.6852		\\ \hline
Error			& 24	& 4914.25	& 204.7604 	& 			\\ \hline
Total			& 31	& 8762.97 	& 			&			\\ \hline
\end{tabular}\par
\end{center}

From tables of the $F_{7,24}$ distribution,
\bit
\it The 95th percentile is $F_{0.05} = 2.42$.
\it The 99th percentile is $F_{0.01} = 3.50$.
\eit
The observed value of the test statistic lies between these two values: we would reject the null hypothesis at $\alpha=0.05$, but not at $\alpha=0.01$.
\end{solution}

%-------------------------------------------------
\section{Linear regression I}\label{sec:slr1}

%-----------------------------
%\subsection{}
We wish to investigates how one random variable $X$ influences the behaviour of another random variable $Y$.

\bit
\it $X$ is called the \emph{explanatory variable}, or the \emph{independent} variable.
\it $Y$ is called the \emph{response variable}, or the \emph{dependent} variable.
\eit

Suppose we observe that $X$ takes the value $x$. Unless $Y$ is completely determined by $X$, we cannot predict its value with certainty, so we focus on the problem of estimating its conditional expectation $E(Y|X=x)$. This leads us to represent $Y$ as the sum of two random variables:
\[
Y = \mu(X) + \epsilon
\]
where
\bit
\it $\mu(x) = \expe(Y|X=x)$ is called the \emph{regression function}, and
\it $\epsilon = Y - \expe(Y|X)$ is called the \emph{error variable} (whose distribution may depend on $X$).
\eit

% lemma
%By the law of total expectation, the expected value of the error variable is zero.
\begin{lemma}
The expected value of the error variable is zero.
%$\expe(\epsilon) = 0$.
\end{lemma}
\begin{proof}
By the law of total expectation,
\[
\expe(\epsilon) = \expe\big[Y - \expe(Y|X)\big] = \expe(Y) - \expe\big[\expe(Y|X)\big] = \expe(Y)-\expe(Y) = 0.
\]
\end{proof}

% lemma
%The law of total variance divides the variance of $Y$ into a component attributed to the explanatory variable $X$, and a component attributed to the error variable $\epsilon$.
The following lemma shows that the variance of $Y$ can be divided into a component attributed to the explanatory variable $X$, and a component attributed to the error variable $\epsilon$.
\begin{lemma}
%$\var(Y) = \var(\mu) + \expe\big[\var(\epsilon|X)\big]$.
If the error variable $\epsilon$ is independent of the explanatory variable $X$,
\[\var(Y) = \var(\mu) + \var(\epsilon).
\]
\end{lemma}
\begin{proof}
$\epsilon = Y - \expe(Y|X)$, so (by the definition of conditional variance),
\[
\var(Y|X) = \expe\big(\big[Y-\expe(Y|X)\big]^2|X\big) = \expe(\epsilon^2|X) = \var(\epsilon|X) = \var(\epsilon).
\]
By the law of total variance,
\begin{align*}
\var(Y)
	& = \var\big[\expe(Y|X)\big] + \expe\big[\var(Y|X)\big] \\
	& = \var\big[\mu(X)\big] + \expe\big[\var(\epsilon)\big]
	& = \var\big[\mu(X)\big] + \var(\epsilon).
\end{align*}
\end{proof}

\begin{remark}
\bit
\it $\var(\mu) = \var\big[\expe(Y|X)\big]$ is the \emph{explained} variance.
%\it $\expe\big[\var(\epsilon|X)\big] = \expe\big[\var(Y|X)\big]$ is the \emph{unexplained} variance.
\it $\var(\epsilon) = \var(Y|X)$ is the \emph{unexplained} variance.
\eit
\end{remark}

%-----------------------------
\subsection{Linear models}

\begin{definition}
A regression function $\mu(x)=\expe(Y|X=x)$ is called a \emph{linear model} if it is linear in its parameters:
\end{definition}
%For example,
\bit
\it $\mu(x) = \alpha + \beta x + \gamma x^2$ is a linear model.
\it $\mu(x) = \alpha e^{\beta x}$ is not a linear model.
\eit

\begin{definition}
A \emph{simple} linear model is a model of the form $\mu(x) = \alpha + \beta x$.
\end{definition}

The simple linear model yields
\[
Y = \alpha + \beta X + \epsilon \quad\text{where}\quad \epsilon\sim N(0,\sigma^2).
\]
\fbox{\begin{minipage}{\linewidth}\centering We assume that the error variable $\epsilon$ is \emph{independent} of the explanatory variable $X$.\end{minipage}}

\bigskip
If we observe that $X=x$, we see that $Y\sim N(\alpha+\beta x, \sigma^2)$ and in particular,
\[
\expe(Y|X=x) = \alpha + \beta x
\quad\text{and}\quad
\var(Y|X=x) = \sigma^2.
\]

%-----------------------------
\subsection{Parameter estimation}
Let $(X_1,Y_1),(X_2,Y_2),\ldots,(X_n,Y_n)$ be a random sample of observations from the joint distribution of $X$ and $Y$.
% theorem: mle of alpha and beta
\begin{theorem}
The maximum likelihood estimators of $\alpha$ and $\beta$ are given by
\[
\hat{\alpha} = \bar{Y}-\hat{\beta}\bar{X}
\text{\qquad and\qquad}
\hat{\beta} = \frac{\sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\sum_{i=1}^n (X_i-\bar{X})^2}
\text{\qquad respectively.}
\]
\end{theorem}

% proof
\begin{proof}
Let $\{(x_1,y_1),(x_2,y_2),\ldots,(x_n,y_n)\}$ be a realisation of the sample. The likelihood function is:
\begin{align*}
L(\alpha,\beta,\sigma^2)
	& = \prod_{i=1}^n \frac{1}{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{1}{2}\left(\frac{y_i-(\alpha+\beta x_i)}{\sigma}\right)^2\right] \\
	& = \left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^n \exp\left[-\frac{1}{2\sigma^2}\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2\right].
\end{align*}
The log-likelihood function is:
\[
\ell(\alpha,\beta,\sigma^2)
	= - \frac{n}{2}\log(2\pi\sigma^2) - \frac{1}{2\sigma^2}\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2.
\]

The MLE estimates of $\alpha$ and $\beta$ are those values that minimise the sum of squared errors:
\[
H(\alpha,\beta) = \sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2
\]
\bit
\it To minimize $H(\alpha,\beta)$ is known as the \emph{method of least squares}.
\eit

% partial derivatives
The partial derivatives of $H(\alpha,\beta)$ with respect to $\alpha$ and $\beta$ are
\begin{align*}
\frac{\partial H}{\partial\alpha}
	& = 2\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big] (-1) \\
\frac{\partial H}{\partial\beta}
	& = 2\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big] (-x_i) \\
\end{align*}

To find the MLEs of $\alpha$ and $\beta$, we set the partial derivatives to equal zero.
% alpha
\begin{align*}
\frac{\partial H}{\partial\alpha} = 0
	& \ \Rightarrow\  \sum_{i=1}^n y_i- n\alpha -\beta\sum_{i=1}^n x_i = 0 \\
	& \ \Rightarrow\  n\alpha  = \sum_{i=1}^n y_i- \beta\sum_{i=1}^n x_i \\
	& \ \Rightarrow\  \alpha = \bar{y}-\beta\bar{x}.
\end{align*}

% beta
\begin{align*}
\frac{\partial H}{\partial\beta} =0
	& \ \Rightarrow\  \sum_{i=1}^n x_i y_i - \alpha\sum_{i=1}^n x_i -\beta\sum_{i=1}^n x_i^2 = 0 \\
	& \ \Rightarrow\  \sum_{i=1}^n x_i y_i - (\bar{y}-\beta\bar{x})\sum_{i=1}^n x_i -\beta\sum_{i=1}^n x_i^2 = 0 \\
	& \ \Rightarrow\  \sum_{i=1}^n x_i(y_i-\bar{y}) - \beta\sum_{i=1}^n x_i(x_i-\bar{x}) = 0 \\
	& \ \Rightarrow\  \sum_{i=1}^n (x_i-\bar{x})(y_i-\bar{y}) - \beta\sum_{i=1}^n (x_i-\bar{x})^2 = 0 \\
	& \ \Rightarrow\  \beta = \frac{\sum_{i=1}^n (x_i-\bar{x})(y_i-\bar{y})}{\sum_{i=1}^n (x_i-\bar{x})^2}
\end{align*}

The maximum-likelihood estimators of $\alpha$ and $\beta$ are therefore
\[
\hat{\alpha} = \bar{Y}-\hat{\beta}\bar{X}
\text{\quad and\quad}
\hat{\beta} = \frac{\sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\sum_{i=1}^n (X_i-\bar{X})^2}.
\]
\end{proof}

%-----------------------------
\subsection{Residual variance}

\begin{definition}
%Let $(x_1,x_2,\ldots,x_n)$ be a realisation of the marginal sample $(X_1,X_2,\ldots,X_n)$.
%Given $X=x$,

\ben
\it $\hat{y} = \hat{\alpha} + \hat{\beta}X$ is called the \emph{predicted value of $Y$} at $X$.
\it $\hat{\epsilon} = Y - \hat{y}$ is called the \emph{residual variable} at $X$.
\een
\end{definition}

% theorem: mle of alpha and beta
\begin{theorem}
The maximum likelihood estimator of the error variance $\sigma^2$ is the sample mean of the squared residuals,
\[
\hat{\sigma}^2 = \frac{1}{n}\sum_{i=1}^n \hat{\epsilon}_i^2
\text{\quad where\quad}
\hat{\epsilon}_i = Y_i-(\hat{\alpha}+\hat{\beta} X_i).
\]
\end{theorem}

% proof
\begin{proof}
Recall the log-likelihood function:
\[
\ell(\alpha,\beta,\sigma^2)
	= \frac{n}{2}\log(2\pi\sigma^2) + \frac{1}{2\sigma^2}\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2.
\]
The first partial derivative of $\ell(\alpha,\beta,\sigma^2)$ with respect to $\sigma^2$ is
\[
\frac{\partial\ell}{\partial(\sigma^2)}
	= \frac{n}{2\sigma^2} - \frac{1}{2(\sigma^2)^2}\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2.
\]
Setting this equal to zero,
\[
\sigma^2 = \frac{1}{n}\sum_{i=1}^n \big[y_i-(\alpha+\beta x_i)\big]^2.
\]
Substituting our estimates for $\alpha$ and $\beta$, we obtain the MLE
\[
\hat{\sigma^2} = \frac{1}{n}\sum_{i=1}^n \hat{\epsilon}_i^2 \text{\quad where\quad} \hat{\epsilon}_i = Y_i-(\hat{\alpha}+\hat{\beta} x_i)
\]
as required.

\end{proof}

\begin{remark}[Residual Analysis]
Our model assumes that $\epsilon\sim N(0,\sigma^2)$ and that $\epsilon$ is independent of $X$. To test whether these assumptions hold, we plot the points $(x_i,\hat{\epsilon}_i)$ on a scatter diagram. If the assumptions do indeed hold, the points should be evenly spread about the horizontal axis, and the extent of their spread should not depend on the $x$-coordinate.
This is an example of \emph{residual analysis}.
\end{remark}

% exercise
\begin{exercise}
Following a class test, 10 students were asked about the number of hours they had revised for the test. The data is shown in the table below.
\begin{center}
\begin{tabular}{|l|cccccccccc|} \hline
Hours studied ($x$)	&  4	 &  9 & 10 & 14 &  4 &  7 & 12 & 22 &  1 & 17 \\
Test score ($y$)		& 31 & 58 & 65 & 73 & 37 & 44 & 60 & 91 & 21 & 84 \\ \hline
\end{tabular}
\end{center}
Perform a simple linear regression to estimate the relationship between the number of hours studied and the score achieved in the test.
\begin{answer}
%It is easy to show that
%\begin{align*}
%\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})
%		& = \sum_{i=1}^n x_iy_i - \frac{1}{n}\left(\sum_{i=1}^n x_i\right)\left(\sum_{i=1}^n y_i\right) \text{ and} \\
%\sum_{i=1}^n (x_i - \bar{x})^2
%		& = \sum_{i=1}^n x_i^2 - \frac{1}{n}\left(\sum_{i=1}^n x_i\right)^2.
%\end{align*}
%
%From the table,
%\bit
%\it $n=10$,
%\it $\sum_i x_i = 100$ and $\sum_i y_i = 564$,
%\it $\sum_i x_i^2 = 1376$ and $\sum_i x_iy_i = 6945$.
%\eit
%This yields
Tedious calculations yield
\[
\sum_{i=1}^n(x_i-\bar{x})^2  = 376 \text{\quad and\quad} \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y}) = 1305.
\]
Thus
\begin{align*}
\hat{\beta}
	& = \displaystyle\frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^n(x_i-\bar{x})^2}
	= \displaystyle\frac{1305}{376}	= 3.47,\\
\intertext{and}
\hat{\alpha}
	& = \displaystyle\bar{y} - \hat{\beta}\bar{x}
	= \displaystyle\frac{564}{10} - \left(\frac{1305}{376}\right)\left(\frac{100}{10}\right) = 21.69.
\end{align*}
The estimated relationship is therefore $\hat{y} = 21.69 + 3.471 x$.
\end{answer}
\end{exercise}

%-------------------------------------------------
\section{Linear regression II}\label{sec:slr2}

%-----------------------------
%\subsection{}
For a fixed realisation $(x_1,x_2,\ldots,x_n)$ of the marginal sample $(X_1,X_2,\ldots,X_n)$, the maximum likelihood estimators $\hat{\alpha}$, $\hat{\beta}$ and $\hat{\epsilon}_i$ are linear functions of $Y_1,Y_2,\ldots,Y_n$. Because the $Y_i$ are independent normal variables, it thus follows that $\hat{\alpha}$, $\hat{\beta}$ and $\hat{\epsilon}_i$ are also normal variables.

% lemma: intercept
\begin{lemma}
The MLE of the intercept $\alpha$ satisfies
$$\hat{\alpha} \sim N(\alpha,\sigma^2/n)$$
\end{lemma}
\begin{proof}
The expected value of $\hat{\alpha}$ is
\begin{align*}
\expe(\hat{\alpha})
	= \expe(\bar{Y}-\beta\bar{x})
	& = \expe\left(\frac{1}{n}\sum_{i=1}^n Y_i - \frac{\beta}{n}\sum_{i=1}^n x_i\right) \\
	& = \frac{1}{n}\sum_{i=1}^n \expe(Y_i) - \frac{\beta}{n}\sum_{i=1}^n x_i \\
	& = \frac{1}{n}\sum_{i=1}^n (\alpha+\beta x_i) - \frac{\beta}{n}\sum_{i=1}^n x_i \\
	& = \alpha.
\end{align*}
%This shows that $\hat{\alpha}$ is an \emph{unbiased} estimator for $\alpha$.
Because $\var(Y_i)=\sigma^2$, the variance of $\hat{\alpha}$ is
\begin{align*}
\var(\hat{\alpha})
	& = \var\left(\frac{1}{n}\sum_{i=1}^n Y_i - \frac{\beta}{n}\sum_{i=1}^n x_i\right) \\
	& = \frac{1}{n^2}\sum_{i=1}^n \var(Y_i)
	= \frac{\sigma^2}{n}.
\end{align*}
Hence $\hat{\alpha} \sim N(\alpha,\sigma^2/n)$, as required.
\end{proof}

% lemma: gradient
\begin{lemma}%[Gradient]
The MLE of the gradient $\beta$ satisfies
$$\hat{\beta}\sim N\left(\beta,\frac{\sigma^2}{\sum_{i=1}^n(x_i-\bar{x})^2}\right)$$
\end{lemma}
\begin{proof}
Since $\expe(Y_i) = \alpha + \beta x_i$ and $\expe(\bar{Y}) = \alpha + \beta\bar{x}$, the expected value of $\hat{\beta}$ is therefore
\begin{align*}
\expe(\hat{\beta})
	& = \expe\left[\frac{\sum_{i=1}^n (x_i-\bar{x})(Y_i-\bar{Y})}{\sum_{i=1}^n (x_i-\bar{x})^2}\right] \\
	& = \frac{\sum_{i=1}^n (x_i-\bar{x})\expe(Y_i-\bar{Y})}{\sum_{i=1}^n (x_i-\bar{x})^2}
`	= \frac{\sum_{i=1}^n \beta(x_i-\bar{x})^2}{\sum_{i=1}^n (x_i-\bar{x})^2} = \beta.
\end{align*}
Using the fact that $\sum_{i=1}^n x_i = n\bar{x}$, it is easy to see that $\hat{\beta}$ can be rewritten as
\[
\hat{\beta} = \frac{\sum_{i=1}^n (x_i-\bar{x})Y_i}{\sum_{i=1}^n (x_i-\bar{x})^2}.
\]
Because $\var(Y_i)=\sigma^2$, the variance of $\hat{\beta}$ is
\begin{align*}
\var(\hat{\beta})
	= \var\left[\frac{\sum_{i=1}^n (x_i-\bar{x})Y_i}{\sum_{i=1}^n (x_i-\bar{x})^2}\right]
	& = \frac{1}{\left[\sum_{i=1}^n(x_i-\bar{x})^2\right]^2}\sum_{i=1}^n(x_i-\bar{x})^2\var(Y_i) \\
	& = \frac{\sigma^2}{\sum_{i=1}^n(x_i-\bar{x})^2}.
\end{align*}
Hence $\hat{\beta}\sim N\left(\beta,\frac{\sigma^2}{\sum_{i=1}^n(x_i-\bar{x})^2}\right)$, as required.
\end{proof}

The residuals $\hat{\epsilon}_i$ are normal variables, and the estimated error variance $\hat{\sigma}^2$ is the sample mean of the \emph{squared} residuals. It follows therefore that under a suitable scaling, $\hat{\sigma}^2$ has a chi-squared distribution.

\begin{lemma}%[Error variance]
The MLE of the error variance $\sigma^2$ satisfies
\[
\frac{n\hat{\sigma}}{\sigma} \sim \chi^2_{n-2}
\]
\end{lemma}
\begin{proof}
Recall that
\[
\hat{\sigma}^2 = \frac{1}{n}\sum_{i=1}^n \hat{\epsilon_i}^2
\quad\text{where}\quad
\hat{\epsilon}_i = Y_i-(\hat{\alpha}+\hat{\beta} x_i).
\]
Consider
\begin{align*}
\frac{1}{\sigma^2}\sum_{i=1}^n\big[Y_i-(\alpha+\beta x_i)\big]^2
	& = \frac{1}{\sigma^2}\sum_{i=1}^n\big[(\hat{\alpha}-\alpha) + (\hat{\beta}-\beta)x_i + (Y_i-(\hat{\alpha}+\hat{\beta}x_i))\big]^2 \\
	& = \frac{n(\hat{\alpha}-\alpha)^2}{\sigma^2} + \frac{(\hat{\beta}-\beta)^2}{\sigma^2}\sum_{i=1}^n x_i^2 + \frac{n\hat{\sigma}^2}{\sigma^2}.
\end{align*}
The first three terms in this expression all have chi-squared distribution.
\bit
\it
Because $Y_i\sim N(\alpha+\beta x_i,\sigma^2)$ it follows that $\big[Y_i-(\alpha+\beta x_i)\big]/\sigma\sim N(0,1)$, so
\[
\displaystyle\frac{1}{\sigma^2}\sum_{i=1}^n\big[Y_i-(\alpha+\beta x_i)\big]^2\sim\chi^2_{n}.
\]
\it
Because $\hat{\alpha}\sim N(\alpha,\sigma^2/n)$ it follows that $\sqrt{n}(\hat{\alpha}-\alpha)/\sigma\sim N(0,1)$, so
\[
\displaystyle\frac{n(\hat{\alpha}-\alpha)^2}{\sigma^2} \sim \chi^2_1.
\]
\it
Because $\hat{\beta}\sim N\left(\beta,\sigma^2/\sum_{i=1}^n(x_i-\bar{x})^2\right)$ it follows that $(\hat{\beta}-\beta)\sqrt{\sum_{i=1}^n x_i^2}/\sigma \sim N(0,1)$, so
\[
\frac{(\hat{\beta}-\beta)^2}{\sigma^2}\sum_{i=1}^n x_i^2 \sim \chi^2_1.
\]
\eit
It is easy to see that if $U\sim\chi^2_a$ and $V\sim\chi^2_b$ are independent, then $U+V\sim\chi^2_{a+b}$. It thus follows that $n\hat{\sigma}/\sigma\sim \chi^2_{n-2}$ as required.
\end{proof}

%-----------------------------
\subsection{Test statistics for $\alpha$ and $\beta$}

We have shown that $\hat{\alpha} \sim N(\alpha,\sigma^2/n)$ and $\hat{\beta}\sim N\Big[\beta,\sigma^2 / \sum_{i=1}^n(x_i-\bar{x})^2\Big]$. The error variance $\sigma^2$ is usually unknown, and we use instead the following (unbiased) estimator for $\sigma^2$, based on the squared residuals:
\[
\hat{\sigma}^2 = \frac{1}{n-2}\sum_{i=1}^n \hat{\epsilon}_i^2
\quad\text{where}\quad
\hat{\epsilon}_i = Y_i-(\hat{\alpha}+\hat{\beta} x_i).
\]
This estimator for $\sigma^2$ yields the following test statistics:
%\begin{align*}
%T_1 & = \frac{\hat{\alpha}-\alpha}{\sqrt{\hat{\sigma}^2/(n-2)}} \\[2ex]
%T_2 & = \frac{\hat{\beta}-\beta}{\sqrt{n\hat{\sigma}^2/[(n-2)\sum_{i=1}^n(x_i-\bar{x})^2]}}
%\end{align*}
\[
T_1 = \frac{\hat{\alpha}-\alpha}{\sqrt{\hat{\sigma}^2/(n-2)}}
\quad\text{and}\quad
T_2 = \frac{\hat{\beta}-\beta}{\sqrt{n\hat{\sigma}^2/[(n-2)\sum_{i=1}^n(x_i-\bar{x})^2]}}.
\]

\bit
\it Under the null hypothesis $H_0:\alpha=0$,
\[
T_1 = \frac{\hat{\alpha}-\alpha}{\sqrt{\hat{\sigma}^2/(n-2)}} \sim t_{n-2}.
\]
\it Uhder the null hypothesis $H_0:\beta=0$,
\[
T_2 = \frac{\hat{\beta}-\beta}{\sqrt{n\hat{\sigma}^2/[(n-2)\sum_{i=1}^n(x_i-\bar{x})^2]}} \sim t_{n-2}.
\]
\eit

$T_2$ can be used to test whether or not $Y$ depends (linearly) on $X$:
\begin{align*}
H_0: 	&\ Y = \alpha+\epsilon, \\
H_1:	&\ Y = \alpha+\beta X + \epsilon.
\end{align*}

%-----------------------------
\subsection{ANOVA for regression}

%For a fixed realisation $(x_1,x_2,\ldots,x_n)$ of the marginal sample $(X_1,X_2,\ldots,X_n)$,
Recall that the \emph{predicted value} of $Y_i$ is
\[
\hat{Y}_i = \hat{\alpha} + \hat{\beta}X_i.
\]
The total deviation of $Y_i$ from the overall mean $\bar{Y}$ can be divided into two components:
\[
Y_i - \bar{Y} = (Y_i-\hat{Y}_i) + (\hat{Y}_i - \bar{Y}),
\]
from which it follows that
\[
\sum_{i=1}^n(Y_i - \bar{Y})^2 = \sum_{i=1}^n(Y_i-\hat{Y}_i)^2 + \sum_{i=1}^n(\hat{Y}_i - \bar{Y})^2.
\]
As with ANOVA, we define the following sums-of-squares.
\[
\begin{array}{lll}
SST	& = \displaystyle\sum_{i=1}^n (Y_i-\bar{Y})^2
\qquad & \text{The \emph{total} sum-of-squares.} \\
SSR	& = \displaystyle\sum_{i=1}^n (\hat{Y}_i-\bar{Y})^2
\qquad & \text{The \emph{regression} (or \emph{model}) sum-of-squares.} \\
SSE	& = \displaystyle\sum_{i=1}^n (Y_i-\hat{Y}_i)^2
\qquad & \text{The \emph{error} sum-of-squares.}
\end{array}
\]

The total sum-of-squares $SST$ is determined the marginal sample $(Y_1,Y_2,\ldots,Y_n)$, and substituting for $\hat{Y}_i = \hat{\alpha} + \hat{\beta}X_i$ we see that the regression sum-of-squares satisfies
\[
SSR = \frac{\big[\sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})\big]^2}{\sum_{i=1}^n (X_i-\bar{X})^2}
\]
The error sum-of-squares is then given by $SSE = SST - SSR$.

\bigskip
Under $H_0:\beta=0$,
\[
\frac{1}{\sigma^2}\sum_{i=1}^n (\hat{Y}_i-\bar{Y})^2	\sim \chi^2_1
\text{\quad and\quad}
\frac{1}{\sigma^2}\sum_{i=1}^n (Y_i-\hat{Y}_i)^2		\sim \chi^2_{n-2}.
\]
Thus we have the test statistic
\[
F
%	= \frac{SSR}{\frac{1}{n-2}SSE}
	= \frac{\sum_{i=1}^n (\hat{Y}_i-\bar{Y})^2}{(n-2)^{-1}\sum_{i=1}^n (Y_i-\hat{Y}_i)^2}
	\sim F_{1,n-2} \quad\text{under $H_0:\beta=0$.}
\]
which provides an alternative meathod of testing whether or not $Y$ depends linearly on $X$.

\begin{exercise}
The table below shows the deaths due to bronchitis ($x$) and corresponding daily temperatures ($y$), averaged over a long period.
\begin{center}
\begin{tabular}{lcccccccccc}\hline
$x$ & 253 & 232 & 210 & 200 & 191 & 187 & 134 & 102 & 81 & 25 \\
$y$ & 35 & 37 & 39 & 41 & 43 & 45 & 47 & 49 & 51 & 53 \\ \hline
\end{tabular}
\end{center}
Use the simple linear model $y = \alpha + \beta x + \epsilon$ to perform a least-squares regression of $y$ on $x$. Test whether the slope of the regression line is significantly different from zero at the 5\% significance level.
\begin{answer}
The various quantities of interest are computed here:
\bit
\it $n = 10$.
\it $\sum x_{i} = 1615$.
\it $\sum x_{i}^{2}	= 308929$.
\it $\sum (x_i-\bar{x})^2	= 308929 - (1615)^{2}/10 = 48106.5$.
\it $\sum y_{i} =  440$.
\it $\sum y_{i}^{2}  = 19690$.
\it $\sum (y_i-\bar{y})^2 = 19690 - (440)^{2}/10 = 330$.
\it $\sum x_{i}y_{i}	= 67209$.
\it $\sum (x_i-\bar{x})(y_i-\bar{y})	= 67209 - (1615){\times}(440)/10 = -3851$.
\eit

The OLS estimates of the regression coefficients are
\begin{align*}
\hat{\beta}		&\quad = \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2} = \frac{-3851}{48106.5} = -0.080052 \\
\hat{\alpha}	&\quad = \bar{y}-\hat{\beta}\bar{x} = 44 + 0.080052{\times}161.5 = 56.928326
\end{align*}

The least squares regression line is
\[
y = 56.928326 - 0.080052x.
\]
To test the null hypothesis $H_0:\beta=0$, we compute the model sum-of-squares:
\[
SSM
	= \frac{\big[\sum (x_i-\bar{x})(y_i-\bar{y})\big]^{2}}{\sum (x_i-\bar{x})^2}
	=\frac{(-3851)^{2}}{48106.5}
	= 308.2785
\]
and the error sum-of-squares,
\[
SSE
	= \sum (y_i-\bar{y})^2 - S_R = 330.0 - 308.2785 =  21.7215.
\]
The test statistic is
\[
F = \frac{SSM}{\frac{1}{n-2}SSE} = \frac{308.2785}{21.7215/8} = 113.54.
\]

Critical values of the $F_{1,8}$-distribution are
\bit
\it $5.318$ at sig. level $0.05$
\it $7.570$ at sig. level $0.025$
\it $11.25$ at sig. level $0.001$
\it $14.68$ at sig. level $0.005$
\eit
Thus the null hypothesis ${\beta} = 0$ is strongly rejected at the $5\%$ significance level.
\end{answer}
\end{exercise}

%-----------------------------
\subsection{The coefficient of determination}

Recall that, for any pair of random variables $X$ and $Y$, the \emph{correlation coefficient} is defined by
\[
\rho(X,Y)
	= \frac{\cov(X,Y)}{\sqrt{\var(X)\var(Y)}}
	= \frac{\expe\big[(X-\expe X)(Y-\expe Y)\big]}
			{\sqrt{\expe\big[(X-\expe X)^2\big]\expe\big[(Y-\expe Y)^2\big]}}
\]

For a bivariate random sample $(X_1,Y_1),(X_2,Y_2),\ldots,(X_n,Y_n)$, the \emph{sample correlation coefficient} (also called the Pearson correlation) is defined by
\[
R = \frac{\sum_{i=1}^n(X_i-\bar{X})(Y_i - \bar{Y})}{\sqrt{\sum_{i=1}^n(X_i-\bar{X})^2\sum_{i=1}^n(Y_i-\bar{Y})^2}}
\]

For the simple linear regression model $Y=\alpha+\beta X + \epsilon$, the MLE of $\beta$ can be written as,
\begin{align*}
\hat{\beta}
	& = \frac{\sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\sum_{i=1}^n (X_i-\bar{X})^2}
	= R\sqrt{\frac{\sum_{i=1}^n(Y_i-\bar{Y})^2}{\sum_{i=1}^n(X_i-\bar{X})^2}}.
\end{align*}

%The square of the empirical correlation coefficient is called the \emph{coefficient of determination}, denoted by $R^2$:
The \emph{coefficient of determination} is the square of the sample correlation, and denoted by $R^2$:
\[
R^2
	= \frac{\big[\sum_{i=1}^n(X_i-\bar{X})(Y_i - \bar{Y})\big]^2}{\sum_{i=1}^n(X_i-\bar{X})^2\sum_{i=1}^n(Y_i-\bar{Y})^2}
	= \frac{SSR}{SST}.
\]

where $SSR$ and $SST$ are the model sum-of-squares and total sum-of-squares respectively. Thus $R^2$ is the proportion of the total variation explained by the regression model: it quantifies how well the regression line fits the data points, and accordingly is often referred to as a \emph{goodness-of-fit} statistic.

%=====================================================================
\stopcontents[chapters]
\endinput


% Section 1: Introduction

\section{Introduction}

Optimal transport is widely used in the field of computer science, especially in areas as computer graphics, computer vision, medical image processing and deep learning. As the product of the intersection of multiple disciplines, it contains problems from probability, analysis, and optimization. The main objective of the research is to establish a geometric tool for efficient comparison of probability distributions, that is, the modeling of probability distributions by geometric methods and the measurement of the distance between probability distributions is a bridge connecting geometry and probability.

Take the problem given by the French mathematician Monge more than 200 years ago as an example: When two sand plates are given (each sand plate can represent a probability distribution), a sand plate can be transmitted in many ways (Transport or Reshape) to another sandbox. Based on the local cost of transmitting a single sand particle, each transport method corresponds to a global cost. The purpose of optimal transport is to find the transport solution with the lowest overall cost, so as to further establish the geometric toolset for probability distribution.

The optimal transport problem has a long and rich research history, which can be traced back to the eighteenth-century Monge mentioned above. The Russian mathematician Kantorovich gave a more practical form of relaxation in the 1940s and was further promoted in the 1990s because of a series of important mathematical theoretical achievements, including important work of French mathematician Brenier. It is particularly important that many Fields Prize winners have made important contributions in the study of optimal transport theory, such as the French mathematician Cédric Villani (The Fields Award 2010), Italian Mathematics Alessio Figalli (The Fields Award 2018), and has many important monographs \cite{book1, book2, book3, book4}. In terms of application, optimal transport has been widely used in the field of computer science, especially in computer graphics, computer vision, medical image processing, and deep learning.

In order to introduce the optimal transmission problem more concisely, we only consider the optimal transmission problem for discrete probability vectors (histograms). First, a probability vector or histogram refers to a vector $a \in \Sigma_m$ belongs to a set of probability simplex, that is,

\begin{equation}
  \Sigma_{m}:=\left\{\mathbf{a} \in \mathbb{R}_{+}^{m}: \sum_{i=1}^{m} \mathbf{a}_{i}=1\right\}
\end{equation}

Due to the computational difficulty of the optimal transport problem proposed by Monge and the limitation of this model, the Kantorovich relaxed optimal transport model has drawn attention in academia. By removing the limitation of fully deterministic transport (the quantity of the same point cannot be decomposed), Kantorovich gives a concise and effective optimal transport model. Transport is achieved through the Couplings matrix $P_+^{n \times m}$, where the set of coupling matrices is defined as

\begin{equation}
  \mathbf{U}(\mathbf{a}, \mathbf{b}) \stackrel{\text { def. }}{=}\left\{\mathbf{P} \in \mathbb{R}_{+}^{m \times n}: \mathbf{P} \mathbf{1}_{n}=\mathbf{a} \quad \text { and } \quad \mathbf{P}^{\mathrm{T}} \mathbf{1}_{m}=\mathbf{b}\right\}
\end{equation}

$\mathbf{a} \in \Sigma_m$ and $\mathbf{b} \in \Sigma_n$ are both probability vectors or histograms. The coupling matrix set is bounded and consists of $m + n$ equality constraints, which can be regarded as a convex polyhedron.

Kantorovich optimal transmission problem can be defined as

\begin{equation}
  \mathcal{L}_{\mathbf{C}}(\mathbf{a}, \mathbf{b}):=\min _{\mathbf{P} \in \mathbf{U}(\mathbf{a}, \mathbf{b})}\langle\mathbf{C}, \mathbf{P}\rangle:=\sum_{i, j} \mathbf{C}_{i j} \mathbf{P}_{i j}
\end{equation}

Where $C \in \mathbb{R}^{n \times m}$ represents the cost matrix and $C_{ij}$ represents the cost required to transfer from $i$ to $j$. The Kantorovich optimal transport problem is a linear programming problem, and the problem does not necessarily have a unique solution. The importance of the optimal transport problem is not only in itself, it provides a way to meaningfully characterize the distance between probability vectors or histograms.

\vspace{5ex}
\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\linewidth]{img/ot}
  \label{fig:ot}
  \caption{Illustration of Optimal Transport Interpolation}
\end{figure}


\section{The Isomorphism Theorems}
\begin{definition}
    A subgroup $H\le G$ is called normal if $\forall h\in H,\forall g\in G, ghg^{-1}\in H$, in which occasion $H\unlhd G$
\end{definition}
\begin{example}
    1. $\{e\}\unlhd G,G\unlhd G$.\\
    2. The subgroup of the dihedral group $D_{2n}$ generated by the rotations is normal. but that generated by the reflection generator is not normal (given $n\ge 3$).\\
    3. If $G$ is abelian, then for every $H\le G,H\unlhd G$.
\end{example}
\begin{lemma}
    A subgroup $H\le G$ is normal if and only if $\forall a\in G,aH=Ha$.
\end{lemma}
\begin{proof}
    Trivial but let us write it down.\\
    If $H$ is normal, then for any $ah\in aH,\exists h'\in H,aha^{-1}=h'\implies ah=h'a\in Ha$, so $aH\subset Ha$.
    Similarly $Ha\subset aH$, so $Ha=aH$.\\
    Conversely, if $\forall a\in G,Ha=aH$, we can choose any $h\in H,\exists h'\in H,ah=h'a\implies aha^{-1}=h'\in H$, so $H$ is normal.
\end{proof}
\begin{corollary}
    Let $H\le G$.
    If $|G/H|=2$, then $H$ is normal.
\end{corollary}
\begin{proof}
    If $a\in H$, then obviously $aH=Ha$, otherwise, since $H$ has index $2$, $aH=G\setminus H=Ha$, thus $H\unlhd G$.
\end{proof}
\begin{proposition}
    Let $\phi:G\to K$ be a homomorphism, then $\ker\phi\unlhd G$.
\end{proposition}
\begin{proof}
    Suppose $h\in\ker\phi$, then $\forall g\in G$, then $\phi(ghg^{-1})=\phi(g)e_K\phi(g)^{-1}=e_K\implies ghg^{-1}\in\ker\phi$.
\end{proof}
So we know that every kernel is a normal subgroup, but how about the converse?
Must every normal subgroup the kernel of some homomorphism?
\begin{definition}
    Let $G$ be a group and $H\unlhd G$, then we can define the operation
    $$(aH)\cdot(bH)=(ab)H$$
    And $G/H$ is a group under this operation.
    This is called the quotient group.
\end{definition}
Given that it is well defined, which we will prove later, then we know that whenever $H$ is normal, then it is the kernel of the homomorphism $\pi: G\to G/H$ by $\pi(a)=aH$.
This is called the caconical projection.\\
If we do not have $H$ being normal, then if we want to define the operation
$$aH\times bH=abH$$
But is it well defined?
Note that to do so, if $aH=a'H,bH=b'H$, then $a^{-1}a',b^{-1}b'\in H$, but to make the operation well-defined, we must have
$$a'b'H=abH\iff a^{-1}b^{-1}a'b'\in H$$
But this is not always true.
But if $H$ is normal, then it is however true.
In fact, this is true if and only if $H$ is normal.
\begin{theorem}
    Our operation on quotient group is well-defined and $G/H$ is a group under it.
\end{theorem}
\begin{proof}
    If $aH=a'H,bH=b'H$, then
    $$a'b'H=a'bH=a'Hb=aHb=abH$$
    Due to normality of H.\\
    To see that $G/H$ is thus a group, we observe that $(aH\cdot bH)\cdot cH=abcH=aH\cdot(bH\cdot cH)$.
    Also $H=eH$ is the identity and $gH\cdot g^{-1}H=H$.
\end{proof}
\begin{example}
    1. Note that $n\mathbb Z\le\mathbb Z$, and it is normal since $\mathbb Z$ is abelian.
    Now $\mathbb Z_n\cong \mathbb Z/n\mathbb Z$ by the isomorphism $k\mapsto k+n\mathbb Z$.\\
    2. Let $R=\langle r|r^n\rangle\le D_{2n}$, then $|D_{2n}/R|=2$, so $D_{2n}/R\cong C_2$.\\
    3. Let $K$ be the group consisting of $\{e,r^2\}$ in $D_8$.
    One can check that this is normal, and that $D_8/K\cong K_4=C_2\times C_2$ since (by inspection) every element in the quotient group has order $2$.\\
    4. Let $K$ be the subgroup of $Q_8$ consisting of $\{\pm\underline{1}\}$, and $Q_8/K\cong K_4$ since every element has order $2$ again.
    From this example and the last one, we can see that if $H_1\le G_1,H_2\le G_2$ and $H_1\cong H_2,G_1/H_1\cong G_2/H_2$, we do not necessarily have $G_1\cong G_2$.
    Hence, when we dissolve a group into normal subgroup and quotient, there might not be an unique way to rebuild the group from them.
\end{example}
\begin{theorem}[First Isomorphism Theorem]\label{1_isom_thm}
    Suppose $\phi:G\to H$ is a homomorphism, then $G/\ker\phi\cong\operatorname{Im}\phi$.
    Indeed, the map $\bar\phi:G/\ker\phi\to\operatorname{Im}\phi$ by $g\ker\phi\mapsto\phi(g)$ is well defined and is an isomorphism.
\end{theorem}
The theorem gives the following commutative diagram, where $\pi$ is the caconical projection:
$$
\begin{tikzcd}
    G\arrow{r}{\phi} \arrow[swap]{d}{\pi} & \operatorname{Im}\phi\\
    G/\ker\phi\arrow[swap,dashed]{ur}{\bar\phi}&
\end{tikzcd}
$$
\begin{proof}
    We know that $\ker\phi$ is normal, thus we can form the quotient $G/\ker\phi$.\\
    If $g\ker\phi=h\ker\phi$, then $h^{-1}g\in\ker\phi$, hence
    $$e_H=\phi(h^{-1}g)=\phi(h)^{-1}\phi(g)\implies \phi(g)=\phi(h)$$
    thus $\bar\phi$ is well-defined.
    Note also that
    $$\bar\phi((g\ker\phi)(h\ker\phi))=\bar\phi(gh\ker\phi)=\phi(gh)=\phi(g)\phi(h)=\bar\phi(g\ker\phi)\bar\phi(h\ker\phi)$$
    so it is a homomorphism.
    Furthermore, if $\bar\phi(g\ker\phi)=\bar\phi(h\ker\phi)$, then
    $$\phi(g)=\phi(h)\implies \phi(h^{-1}g)=e_H\implies h^{-1}g\in\ker\phi\implies h\ker\phi=g\ker\phi$$
    So it is injective.
    It is also surjective by definition, so it is bijective, hence it is an isomorphism.
\end{proof}
\begin{example}
    1. Consider $\mathbb Z_n\cong\mathbb Z/n\mathbb Z$.
    Now an easy proof of that is to recognize the homomorphism $\mathbb Z\to\mathbb Z_n$ sending an integer to the remainder it left when divided by $n$.
    And the result follows by Theorem \ref{1_isom_thm}.\\
    2. The function $\phi:(\mathbb R,+,0)\to(\mathbb C\setminus\{0\},\times,1)$ by $t\mapsto e^{2\pi it}$, so the image of $\phi$ is $S^1=\{z\in\mathbb C:|z|=1\}$ and $\ker\phi=\mathbb Z$, so $\mathbb R/\mathbb Z\cong S^1$.\\
    3. If $H$ and $G$ are groups, we have $G\times H$ and $\{e\}\times H\unlhd G\times H$, but $G\times H/\{e\}\times H\cong G$.\\
    4. Let $G$ be the group of all symmetries (isometries) of the tetrahedron, then consider the map $\phi:G\to\operatorname{Sym} V$ where $V$ is the set of vertices by action.
    But this is injective and $\operatorname{Sym}V\cong S_4$ has $24$ elements, and the rotational symmetries forms an order-$12$ proper subgroup of $G$, thus we must have $G\cong G/\{e\}\cong\operatorname{Im}\phi\le S_4$, but $12<|\operatorname{Im}\phi||24=|S_4|$ by Theorem \ref{1_isom_thm}, so by Corollary \ref{lagrange}, $\operatorname{Im}\phi\cong S_4$.
    5. $G$ also acts on the opposite pairs of edges, which has order $3$, so it gives a homomorphism $\phi:G\to S_3$.
    Since its image has an element of order $2$ and an element of order $3$, this homomorphism is surjective, therefore $S_4/\ker\phi=G/\ker\phi\cong S_3$, so $|\ker\phi|=4$.
    Interestingly, there is never again a surjective homomorphism from $S_n$ to $S_{n-1}$ for $n>4$.
\end{example}
\begin{definition}
    A group $G$ is simple if it has no proper normal subgroup.
\end{definition}
\begin{example}
    $C_p$ is simple for $p$ prime, since it does not even have any proper subgroup by Corollary \ref{lagrange}.
\end{example}


\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{physics}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}
\relpenalty=10000
\binoppenalty=10000

\begin{document}
\section{Geometry}
  \subsection{Inscribed angles}
    \begin{enumerate}
      \item Inscribed angles subtending the same arc are equal to each other
      \item Inscribed angle is equal to half of the central angle subtending the same arc.
      \item \textbf{Alternate segment theorem}: Angle between chord and tangent is equal to inscribed angle which subtends to that chord.
    \end{enumerate}
  \subsection{Power of point}
    \begin{enumerate}
      \item The \textbf{power of point} $P$ with respect to circle with centre $O$ and radius $r$ is defined as
      $$ p= PO^2-r^2 $$
      \item For any line through point $P$ which intersects the circle at points $A$ and $B$
      $$p= PA \times PB$$
    \end{enumerate}
  \subsection{Trigonometry}
    \begin{enumerate}
      \item Basic trigonometric identities
      $$\frac{\sin x}{\cos x} = \tan x$$
      $$\sin^2 x + \cos^2 x =1$$
      \item Double angle formulae
      $$ \cos 2x = \cos^2 x - \sin^2 x $$
      $$ \sin 2x = 2\sin x \cos x $$
      \item Sine law
      $$\frac{a}{\sin\alpha} = \frac{b}{\sin\beta} = \frac{c}{\sin\gamma} = 2R$$
      \item Cosine law
      $$ a^2 + b^2 - c^2 -2ab\cos\gamma = 0$$
    \end{enumerate}
\newpage
\section{Algebra}
  \subsection{Polynomials}
    \begin{enumerate}
      \item \textbf{Bezout's theorem}: A polynomial $P(x)$ is divisible by the binomial $(x-a)$ if and only if $P(a)=0$.

      \item \textbf{The fundamental theorem of algebra}: Every non-constant polynomial has a complex root.

      \item \textbf{The rational root theorem}: If $x = p/q$ is a rational zero
      of a polynomial $P(x) = a_nx^n +\hdots + a_0$ with integer coefficients and $p,q=1$,
      then $p | a_0$ and $q | a_n$.

      \item \textbf{Vieta's formulae}: If the solutions polynomial of degree $n$ are $x_1,x_2,\dots,x_n$ and  $a_n=1$, then the following holds:
      \begin{eqnarray*}
      x_1+x_2+\ldots+x_n &=& -a_{n-1},\\
      x_1x_2+x_1x_3+\ldots+x_{n-1}x_{n} &=& \hphantom{-} a_{n-2}, \\
      x_1x_2x_3+x_1x_2x_4+\ldots+x_{n-2}x_{n-1}x_n &=& -a_{n-3},\\
      \ldots \\
      x_1x_2\ldots x_n &=& (-1)^n a_0.
      \end{eqnarray*}
    \end{enumerate}
  \subsection{Inequalities}
    \begin{enumerate}
    	\item \textbf{General mean inequality}:
    	The mean of order $p$ of positive real numbers $x_1,\dots,x_n$ is defined as:
    	$$M_p=
    	\begin{cases}
    	\left(\frac{x_1^p+ \dots + x_n^p}{n}\right)^{1/p} &\text{for } p \ne 0 \\
    	\sqrt[n]{x_1 \dots x_n}                           &\text{for } p=0
    	\end{cases}
    	$$
    	In particular
    	\begin{center}
    		\begin{tabular}{lcl}
    			Smallest element & $\min\{x_i\}$ & $M_{-\infty}$ \\
    			Harmonic mean & HM & $M_{-1}$ \\
    			Geometric mean & GM & $M_0$ \\
    			Arithmetic mean & AM & $M_1$ \\
    			Quadratic mean & QM & $M_2$ \\
    			Largest element & $\max\{x_i\}$ & $M_{\infty}$
    		\end{tabular}
    	\end{center}
    	Then for any real $p$ and $q$
    	$$M_p \leq M_q \iff p \leq q $$

    	\item \textbf{Cauchy inequality}:
    	For real numbers $x_1, \dots , x_n, y_1, \dots , y_n$

    	$$\left(\sum_{i=1}^{n} x_i y_i\right)^2 \leq \sum_{i=1}^{n} x_i^2 \sum_{i=1}^{n} y_i^2 $$

    	\item \textbf{Chebyshev inequality}:
    	For real numbers $x_1 \geq \dots \geq x_n$ and $y_1 \geq \dots \geq y_n$
    	$$\frac{1}{n} \sum_{i=1}^{n} x_iy_i
    	\geq
    	\left(\frac{1}{n}\sum_{i=1}^{n}x_i\right)
    	\left(\frac{1}{n}\sum_{i=1}^{n}y_i\right)
    	\geq
    	\frac{1}{n} \sum_{i=1}^{n} x_iy_{n+1-i} $$

    	\item \textbf{Jensen inequality.}
    	Given positive real numbers $\lambda_1,\hdots,\lambda_n$ for which $\lambda_1+\hdots+\lambda_n=1$  and a convex function $f(x)$ the following holds:
    	$$f(\lambda_1 x_1 + \hdots + \lambda_n x_n) \leq \lambda_1 f(x_1) + \hdots + \lambda_n f(x_n)$$
    	Similarly, when $f(x)$ is a concave function, then
    	$$f(\lambda_1 x_1 + \hdots + \lambda_n x_n) \geq \lambda_1 f(x_1) + \hdots + \lambda_n f(x_n)$$
  	\end{enumerate}
  \subsection{Functional equations}
    \begin{enumerate}
      \item
      If $f(x)=f(y)$ implies $x=y$, then $f$ is \textbf{injective}
      \item
      If for each element $y$ in function codomain, there exists $x$ for which $f(x)=y$, then $f$ is \textbf{surjective}.
      \item
      If $f$ is both injective and surjective then $f$ is \textbf{bijective} (one-to-one).
      \item \textbf{Cauchy functions}: If any of the following is satisfied
      \begin{enumerate}
        \item The function is continuous at one point,
        \item The function is monotonic on any interval,
        \item The function is bounded on any interval.
      \end{enumerate}
      then all of the following functional equations have the respective solutions.
      \begin{align}
         f(x+y) &= f(x) + f(x) & \Rightarrow && f(x) &= cx \\
         f(xy)  &= f(x)f(y)    & \Rightarrow && f(x) &= x^c \\
         f(xy)  &= f(x) +f(y)  & \Rightarrow && f(x) &= c \log |x| \\
         f(x+y) &= f(x)f(y)    & \Rightarrow && f(x) &= e^{cx}
      \end{align}
    \end{enumerate}
\newpage
\section{Number Theory}
  \subsection{Divisibility}
    \begin{enumerate}
      \item
      If $a \mid b$ and $ c \mid d$ then $ac \mid bd$
      \item
      If $a \mid b$ and $a \mid c$, then $a \mid b+c$
      \item
      \textbf{Euclid's algorithm.} \\
      $\gcd (a,b) = \gcd (a,b-a)$
      \item
      \textbf{Corollary of Euclid's algorithm.} \\
      $ax+by=n$ has solution $(x,y)$ in integers if and only if $gcd(a,b) \mid n$
    \end{enumerate}
  \subsection{Congruences}
    For integers $a,b,c,d,m,n$ and prime $p$.
    \begin{enumerate}
      \item
      $a \equiv b \mod m \iff m \mid a-b $
      \item
      $a\equiv b \mod m$ and $ c\equiv d \mod m \implies a+c\equiv b+d \mod m$
      \item
      $a \equiv b \mod m \iff an \equiv bn \mod mn$
      \item
      $a \equiv b \mod m \implies an \equiv bn \mod m$
    \end{enumerate}
  \subsection{Exponential congruences}
    \begin{enumerate}
    \item
    \textbf{Fermat's little theorem.} \\
    For prime $p$ and integer $a$
    $$a^p \equiv a \mod p$$

    \item
    \textbf{Wilson's theorem.} \\
    $$(p-1)! \equiv -1 \mod p$$
    if and only if when $p$ is prime number.

    \item
    \textbf{Number of factors} \\
    The number of positive factors of $n=p_1^{\alpha_1} \dots p_k^{a_k}$
    $$d(n)= (\alpha_1+1)(\alpha_2+1)\dots (\alpha_k+1)$$
    \item
    \textbf{Sum of factors} \\
    The sum of positive factors of $n=p_1^{\alpha_1} \dots p_k^{a_k}$

    $$\sigma(n)= \frac{p_1^{\alpha_1+1}-1}{p_1-1} + \dots \frac{p_k^{\alpha_k+1}-1}{p_k-1}$$

    \item
    \textbf{Euler's function} \\
    Euler’s function or totient function $\varphi(n)$ is defined for $n=p_1^{\alpha_1} \dots p_k^{a_k}$ as the number
    of positive integers less than $n$ and coprime to $n$. Then
    $$\varphi(n) = n \left(1-\frac{1}{p_1}\right) \dots  \left(1-\frac{1}{p_k}\right)$$

    \item
    \textbf{Euler's theorem}  (Generalisation of Fermat's theorem)\\
    Let $n$ be a natural number and $a$ an integer such that $\gcd(a,n)=1$. Then
    $$a^{\varphi(n)} \equiv 1 \mod n $$
    \end{enumerate}
\newpage
\section{Combinatorics}
  \subsection{Counting of objects}
    \begin{enumerate}
      \item \textbf{Permutations}: $P_n=n!$
      \item \textbf{Variations}: $V^k_n=\frac{n!}{(n-k)!}$
      \item \textbf{Combinations}: $C^k_n=\frac{n!}{(n-k)!}$
    \end{enumerate}
  \subsection{Pigeonhole principle}
    \begin{enumerate}
      \item If a set of $nk + 1$ different elements is partitioned into $n$ mutually disjoint subsets, then at least one subset will contain at least $k + 1$ elements.
    \end{enumerate}
  \subsection{Graph Theory}
    \begin{enumerate}
      \item \textbf{Tree} is a connected graph with no circuits. A connected graph with $n$ vertices is a tree if and only if it has $n-1$ edges.
      \item \textbf{Euler path} is a path in which every edge of the graph appears exactly once. Likewise \textbf{Euler circuit} is a circuit in which every edge appears exactly once.
      \item If each vertex in a connected graph has even degree, then the graph contains an Euler circuit.
      \item If a connected graph has exactly two vertices with odd degree, it contains an Euler path.
      \item A \textbf{Hamilton circuit} is a circuit in which each vertex appears exactly once.
      \item
      A \textbf{planar graph} can be embedded in a plane with edges corresponding to non-intersecting lines (not necessarily straight). A planar graph with $n$ vertices has at most $3n-6$ edges.
      \item \textbf{Dirac's theorem}: A graph with $n$ vertices contains a Hamilton cycle if the degree of each vertex is at least $n/2$.
      \item \textbf{Euler's formula}: $E+2=F+V$, where $E,F,V$ are the numbers of edges, faces and vertices of a polyhedron.

  \end{enumerate}
\end{document}s


\subsection{Complexity Estimate}

\begin{frame}{Complexity Estimate}
    \begin{itemize}
        \item Invented by Gustavo Enrique de Almeida Prado Alves Batista, Xiaoyue Wang and Eamonn Keogh in 2011
            \cite{batista2011complexity}

        \item A possible approach to measure the complexity of a time series

        \item Linear complexity
    \end{itemize}
\end{frame}

\begin{frame}{Complexity Estimate}{Calculation}
    \begin{block}{Given}
        \begin{itemize}
            \item A domain set $\mathbb{U}$

            \item A distance measure function $d$ with $d: \mathbb{U} \times \mathbb{U} \to \mathbb{R}$

        \end{itemize}
    \end{block}
    \begin{block}{Input}
        \begin{itemize}
            \item A time series $Q = (q_1, q_2, \dots, q_i, \dots, q_l)$ with length $l$ over the domain set
                $\mathbb{U}$
        \end{itemize}
    \end{block}
\end{frame}

\begin{frame}{Complexity Estimate}{Calculation}
    \begin{block}{Calculation}
        \begin{itemize}
            \item $CE(Q) = \sqrt[2]{\sum \limits_{i=1}^{l-1} d(q_i, q_{i + 1})^2}$
        \end{itemize}
    \end{block}
\end{frame}

\begin{frame}{Length Normalized Complexity Estimate}{Calculation}
    \begin{block}{Calculation}
        \begin{itemize}
            \item $LNCE(Q) = \frac{1}{l-1}CE(Q)$
        \end{itemize}
    \end{block}
\end{frame}


\documentclass{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]

\begin{document}
\title{Solving simultaneous modular arithmetic equations}
\author{Dave Neary}

\maketitle

\section{The Chinese Remainder Theorem}

\begin{theorem}
	The Chinese Remainder Theorem states that for $n_1,n_2,\cdots,n_k$ pairwise
	coprime integers greater than 1 (that is, $\gcd(n_i,n_j) = 1, i \neq j$)
	whose product is $N$, and integers $a_1,a_2,\cdots,a_k$ with
	$0\leq a_i < n_i$, there is a unique integer $x$ such that $0 \leq x < N$
	and:
	\begin{align*}
		x &\equiv a_1 \pmod{x_1} \\
		x &\equiv a_2 \pmod{x_2} \\
		& \vdots  \\
		x &\equiv a_k \pmod{x_k}
	\end{align*}
\end{theorem}

\section{Applying the theorem}

We will apply the theorem using a construction method which can also be used to
prove the existence and uniqueness of the number $x$ with the following problem:

\textbf{Question:} What is the smallest positive integer that has remainders of 7, 4, and 3
when divided by 8, 9, and 13 respectively?

Since $\gcd(8,9) = \gcd(8,13) = \gcd(9,13) = 1$ we are guaranteed by the Chinese
Remainder Theorem that there will be an answer between 0 and $8\times9\times13 = 936$.

We can construct the solution with the following algorithm. We are given:

\[(m_1,m_2,m_3) = (8,9,13)\]
\[(r_1,r_2,r_3) = (7,4,3)\]

Define:
\[(M_1,M_2,M_3) = (m_2\times m_3,m_1 \times m_3, m_1 \times m_2) = (117,104,72)\]

We use the extended Euclidean algoritm to find $(N_1,N_2,N_3)$ such that:

\[ 1 = M_i N_i + m_i n_i, i\in \{1,2,3\}\]

Then we can calculate:
\[x = r_1 N_1 M_1 + r_2 N_2 M_2 + r_3 N_3 M_3 \pmod{m_1 \times m_2 \times m_3}\]

And since $M_i \equiv 0 \pmod{m_j}, i \neq j$, we are guaranteed that $x$ will
satisfy each of the congruence relations we want.

For $M_1,m_1$:
\begin{align*}
	117 &= 14 \times 8 + 5 & 5 &= 117 - 14 \times 8 \\
	8   &= 1 \times 5 + 3  & 3 &= 15 \times 8 - 117 \\
	5   &= 1 \times 3 + 2  & 2 &= 2 \times 117 - 29 \times 8 \\
	3   &= 1 \times 2 + 1  & 1 &= 44 \times 8 -3 \times 117
\end{align*}

Which yields $N_1 = -3$.

Similarly, for $M_2, M_3$, we get:
\begin{align*}
	1 &= 2 \times 104 - 23 \times 9 & N_2 &= 2 \\
	1 &= 2 \times 72 - 11 \times 13 & N_3 &= 2 \\
\end{align*}

Then we can calculate:

\begin{align*}
	x &= r_1 N_1 M_1 + r_2 N_2 M_2 + r_3 N_3 M_3 \pmod{m_1 \times m_2 \times m_3} \\
	x &= 7(-3)(117)+4(2)(104)+3(2)(72) \pmod{936} \\
	x &= -1193 \pmod{936} = 679 \pmod{936}
\end{align*}

And we can find all solutions of these equations in integers by adding or
subtracting multiples of the product of the modulos:

\[ x = 679 + 936k, k \in \mathbb{Z} \]

\end{document}


%        File: AnalyticalDuctModes.tex
%     Created: Fri Feb 11 10:00 PM 2022 E
% Last Change: Fri Feb 11 10:00 PM 2022 E
%
\documentclass[a4paper]{report}
\usepackage{mathtools}
\begin{document}

Starting with equation 2.28 (Wave Equation) in Kousen's paper,

\begin{equation}
    \frac{1}{A^2}\frac{D^2\tilde{p}}{Dt^2} -
    \nabla^2 \tilde{p} =
    2 \bar{\rho} \frac{d V_x}{d x} \frac{\partial  \tilde{v}_r}{ \partial x}
    \label{eqn:KousensWaveEquation}
\end{equation}

lets look at the no flow case. In the case of sheared flow, $dV_x/dx = 0$ the right hand side will be zero

\begin{align*}
    \frac{1}{A^2}\left(
        \frac{\partial^2 \tilde{p}}{\partial t^2} +
        \vec{V}\cdot \vec {\nabla} (\tilde{p})
    \right) -
    \nabla^2
    \tilde{p} &=
    0 \\
\end{align*}

Substituting the definitions for $\nabla$ and $\nabla^2$ in cylindrical
coordinates gives,

\begin{align*}
    \frac{1}{A^2}\left(
        \frac{\partial^2 \tilde{p}}{\partial t^2}
    +
        \vec{V}\cdot \left(
            \frac{\partial\tilde{p}}{\partial t} +
            \frac{1}{\tilde{r}}\frac{\partial \tilde{p} }{\partial \tilde{r}} +
            \frac{\partial \tilde{p}}{\partial \theta} +
            \frac{\partial \tilde{p}}{\partial x}
        \right)  \right)-
        \left(
            \frac{\partial^2 \tilde{p}}{\partial t^2} +
            \frac{1}{\tilde{r}}\frac{\partial \tilde{p}}{\partial r} +
            \frac{1}{\tilde{r}^2} \frac{\partial^2 \tilde{p}}{\partial \theta^2} +
            \frac{\partial^2 \tilde{p}}{\partial x^2}
        \right) &= 0
\end{align*}
Setting $\vec{V} = 0$,

\begin{align*}
    \frac{1}{A^2}\left(
        \frac{\partial^2 \tilde{p}}{\partial t^2}
    \right) -
        \left(
            \frac{\partial^2 \tilde{p}}{\partial t^2} +
            \frac{1}{\tilde{r}}\frac{\partial \tilde{p}}{\partial  r}  +
            \frac{1}{\tilde{r}^2} \frac{\partial^2 \tilde{p}}{\partial \theta^2} +
            \frac{\partial^2 \tilde{p}}{\partial x^2}
        \right) &= 0
\end{align*}
Recall, $\tilde{p} = p/\bar{\rho} A^2$. To dimensionalize the equation, this is
substituted and both sides are multiplied by $\bar{\rho}A^2$,

\begin{align*}
    \frac{1}{A^2}\left(
        \frac{\partial^2 {p}}{\partial t^2}
    \right) -
        \left(
            \frac{\partial^2 {p}}{\partial t^2} +
            \frac{1}{\tilde{r}}\frac{\partial p}{\partial r} +
            \frac{1}{\tilde{r}^2} \frac{\partial^2 p}{\partial \theta^2} +
            \frac{\partial^2 p}{\partial x^2}
        \right) &= 0
\end{align*}

The process of separation of variables(seperation indeterminatarum)
was first written and formalized by John Bernoulli in a letter to Leibniz. The method
of separation of variables requires an assumed solution as well as initial and boundary
conditions. For a partial differential equation, the assumed solution can be a
linear combination of solutions to a system of ordinary differential equations that
comprises the partial differential equation. Since $p$ is a function of four
variables, the solution is assumed to be a linear combination of four solutions.
Each solution is assumed to be Euler's identity, a common ansant for linear partial
differential equations and boundary conditions.

Defining,

\begin{equation}
    p(x,r,\theta,t) = X(x) R(r) \Theta(\theta) T(t)
\end{equation}

where,

\begin{align*}
    X(x) &=
    A_1 e^{ik_x x} +
    B_1 e^{-ik_x x }\\
    \Theta(\theta) &=
    A_2 e^{i k_{\theta} \theta } +
    B_2 e^{-ik_{\theta} \theta }\\
    T(t) &=
    A_3 e^{i \omega t } +
    B_3 e^{-i\omega t  }
\end{align*}

The next step is to rewrite the wave equation in terms of $X$, $R$, $\Theta$,
and $T$. To further simplify the result, each term is divided by $p$.
Before the substitution, the derivatives of the assumed solutions need to be
evaluated.

\subsubsection{Temporal Derivatives}

\begin{align*}
    \frac{\partial p}{\partial t}
    &=
    \frac{\partial }{\partial t}  \left( XR\Theta T \right) \\
    &=
    XR\Theta\frac{\partial T}{\partial t}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial p}{\partial t}
    &=
    \frac{ 1}{X R \Theta T}  \left( XR\Theta\frac{\partial T}{\partial t} \right) \\
    &=\frac{ 1}{ T}\frac{\partial T}{\partial t}
\end{align*}

\begin{align*}
    \frac{\partial^2 p}{\partial t^2}
    &=
    \frac{\partial^2 }{\partial t^2}  \left( XR\Theta T \right) \\
    &=
    XR\Theta\frac{\partial^2 T}{\partial t^2}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial^2 p}{\partial t^2}
    &=
    \frac{ 1}{X R \Theta T}  \left( XR\Theta\frac{\partial^2 T}{\partial t^2} \right) \\
    &=\frac{ 1}{ T}\frac{\partial^2 T}{\partial t^2}
\end{align*}

\begin{align*}
    \frac{\partial T}{\partial t} &=
    \frac{\partial}{\partial t}
        \left(
        A_3 e^{i \omega t} + B_3 e^{-i \omega t}
    \right)  \\
    &=
    \frac{\partial}{\partial t} \left(A_3 e^{i \omega t}  \right) +
    \frac{\partial}{\partial t} \left(B_3 e^{-i \omega t}  \right)\\
    &= i \omega A_3 e^{i \omega t} - i \omega B_3 e^{i \omega t}
\end{align*}

\begin{align*}
    \frac{\partial^2 T}{\partial t^2} &=
    \frac{\partial^2}{\partial t^2}
        \left(
        i \omega A_3 e^{i \omega t} + i \omega B_3 e^{-i \omega t}
    \right)  \\
    &=
    \frac{\partial^2}{\partial t^2} \left(i \omega A_3 e^{i \omega t}  \right) +
    \frac{\partial^2}{\partial t^2} \left(- i \omega B_3 e^{-i \omega t}  \right)\\
    &= (i \omega)^2 A_3 e^{i \omega t} - (i \omega)^2 B_3 e^{i \omega t}
\end{align*}

\begin{align*}
    \frac{1}{T}\frac{\partial^2 T}{\partial t^2}
    &=
    (i\omega)^2 \\
    &= -\omega^2
\end{align*}

\subsubsection{Radial Derivatives}
\begin{align*}
    \frac{\partial p}{\partial r}
    &=
    \frac{\partial }{\partial r}  \left( XR\Theta T \right) \\
    &=
    X\Theta T\frac{\partial R}{\partial r}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial p}{\partial r}
    &=
    \frac{ 1}{X R \Theta T}  \left( X\Theta T\frac{\partial R}{\partial r} \right) \\
    &=\frac{ 1}{ R}\frac{\partial R}{\partial r}
\end{align*}

\begin{align*}
    \frac{\partial^2 p}{\partial r^2}
    &=
    \frac{\partial^2 }{\partial r^2}  \left( XR\Theta T \right) \\
    &=
    X\Theta T\frac{\partial^2 R}{\partial r^2}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial^2 p}{\partial r^2}
    &=
    \frac{ 1}{X R \Theta T}  \left( X\Theta T \frac{\partial^2 R}{\partial r^2} \right) \\
    &=\frac{ 1}{ R}\frac{\partial^2 R}{\partial r^2}
\end{align*}
The radial derivatives will be revisited once the remaining derivatives are evaluated,

\subsubsection{Tangential Derivatives}

\begin{align*}
    \frac{\partial p}{\partial \theta }
    &=
    \frac{\partial }{\partial t}  \left( XR\Theta T \right) \\
    &=
    XRT\frac{\partial \Theta}{\partial \theta}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial p}{\partial \theta}
    &=
    \frac{ 1}{X R \Theta T}  \left( XR\Theta\frac{\partial T}{\partial \theta} \right) \\
    &=\frac{ 1}{ \Theta}\frac{\partial \Theta}{\partial \theta}
\end{align*}

\begin{align*}
    \frac{\partial^2 p}{\partial \theta^2}
    &=
    \frac{\partial^2 }{\partial \theta^2}  \left( XR\Theta T \right) \\
    &=
    XRT\frac{\partial^2 \Theta }{\partial \theta^2}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial^2 p}{\partial \theta^2}
    &=
    \frac{ 1}{X R \Theta T}  \left( XRT\frac{\partial^2 \Theta}{\partial \theta^2} \right) \\
    &=\frac{ 1}{ \Theta}\frac{\partial^2 \Theta}{\partial \theta^2}
\end{align*}

\begin{align*}
    \frac{\partial \Theta}{\partial \theta} &=
    \frac{\partial}{\partial \theta}
        \left(
            A_2 e^{i k_{\theta} \theta} + B_2 e^{-i k_{\theta} \theta}
        \right)  \\
    &=
    \frac{\partial}{\partial \theta} \left(A_2 e^{i k_{\theta} \theta}  \right) +
    \frac{\partial}{\partial \theta} \left(B_2 e^{-i k_{\theta} \theta}  \right)\\
    &= i k_{\theta} A_2 e^{i k_{\theta} \theta} - i k_{\theta} B_2 e^{i k_{\theta} \theta}
\end{align*}

\begin{align*}
    \frac{\partial^2 \Theta }{\partial \theta^2} &=
    \frac{\partial^2}{\partial \theta^2}
        \left(
        i k_{\theta} A_2 e^{i k_{\theta} \theta} - i k_{\theta} B_2 e^{i k_{\theta} \theta}
    \right)  \\
    &=
    \frac{\partial^2}{\partial \theta^2} \left(i k_{\theta} A_2 e^{i k_{\theta} \theta}  \right) +
    \frac{\partial^2}{\partial \theta^2} \left(- i k_{\theta} B_2 e^{-i k_{\theta} \theta}  \right)\\
    &= (i k_{\theta})^2 A_2 e^{i k_{\theta} \theta } - (i k_{\theta})^2 B_2 e^{i k_{\theta} \theta}
\end{align*}

\begin{align*}
    \frac{1}{\Theta}\frac{\partial^2 \Theta}{\partial \theta^2}
    &=
    (ik_{\theta})^2 \\
    &= -k_{\theta}^2
\end{align*}

\subsubsection{Axial Derivatives}

\begin{align*}
    \frac{\partial p}{\partial x}
    &=
    \frac{\partial }{\partial x}  \left( XR\Theta T \right) \\
    &=
    R\Theta T \frac{\partial X}{\partial x}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial p}{\partial x}
    &=
    \frac{ 1}{X R \Theta T}  \left( R\Theta\frac{\partial X}{\partial x} \right) \\
    &=\frac{ 1}{ X}\frac{\partial X}{\partial x}
\end{align*}

\begin{align*}
    \frac{\partial^2 p}{\partial x^2}
    &=
    \frac{\partial^2 }{\partial x^2}  \left( XR\Theta T \right) \\
    &=
    R\Theta T \frac{\partial^2 X}{\partial x^2}
\end{align*}

\begin{align*}
    \frac{1}{p}\frac{\partial^2 p}{\partial x^2}
    &=
    \frac{ 1}{X R \Theta T}  \left( R\Theta T \frac{\partial^2 X}{\partial x^2} \right) \\
    &=\frac{ 1}{ X}\frac{\partial^2 X}{\partial x^2}
\end{align*}

\begin{align*}
    \frac{\partial X}{\partial x} &=
    \frac{\partial}{\partial t}
        \left(
        A_3 e^{i k_x t} + B_3 e^{-i \omega t}
    \right)  \\
    &=
    \frac{\partial}{\partial t} \left(A_1 e^{i k_x x}  \right) +
    \frac{\partial}{\partial t} \left(B_1 e^{-i k_x x }  \right)\\
    &= i k_x A_1 e^{i k_x x } - i k_x B_1 e^{i k_x x}
\end{align*}

\begin{align*}
    \frac{\partial^2 X}{\partial x^2} &=
    \frac{\partial^2}{\partial x^2}
        \left(
        i k_x A_1 e^{i k_x x} + i k_x B_1 e^{-i k_x x}
    \right)  \\
    &=
    \frac{\partial^2}{\partial x^2} \left(i k_x A_1 e^{i k_x x}  \right) +
    \frac{\partial^2}{\partial x^2} \left(- i k_x B_1 e^{-i k_x x}  \right)\\
    &= (i k_x)^2 A_1 e^{i k_x x} - (i k_x)^2 B_1 e^{i k_x x}
\end{align*}

\begin{align*}
    \frac{1}{X}\frac{\partial^2 X}{\partial x^2}
    &=
    (i k_x)^2 \\
    &= -k_x^2
\end{align*}

Substituting this back into the wave equation yields ,

\begin{align*}
    \frac{1}{A^2}\left(
        \frac{\partial^2 {p}}{\partial t^2}
    \right) &=
        \left(
            \frac{\partial^2 {p}}{\partial t^2} +
            \frac{1}{\tilde{r}}\frac{\partial p}{\partial r} +
            \frac{1}{\tilde{r}^2} \frac{\partial^2 p}{\partial \theta^2} +
            \frac{\partial^2 p}{\partial x^2}
        \right)
\end{align*}

\begin{equation}
    \frac{1}{A^2} \frac{1}{T}\frac{\partial^2 T}{\partial t^2} =
    \frac{1}{R}\frac{\partial^2 R}{\partial r^2 } +
    \frac{1}{r}\frac{1}{R}\frac{\partial R}{\partial r}  +
    \frac{1}{r^2}\frac{1}{\Theta}\frac{\partial \Theta}{\partial \theta} +
    \frac{1}{X}\frac{\partial^2 X}{\partial x^2}
    \label{eqn:waveode}
\end{equation}

Notice that each term is only a function of its associated independent variable.
So, if we vary the time, only the term on the left-hand side can vary. However,
since none of the terms on the right-hand side depend on time, that means the
right-hand side cannot vary, which means that the ratio of time with its second
derivative is independent of time. The practical upshot is that each of these
terms is constant, which has been shown. The wave numbers are the \textit{separation constants}
that allow the PDE to be split into four separate ODE's. Substituting the separation constants
into Equation (\ref{eqn:waveode}) gives,

\begin{equation}
    -\frac{\omega^2}{A^2}  =
    \frac{1}{R}
    \left(
    \frac{\partial^2 R}{\partial r^2 } +
    \frac{1}{r}\frac{\partial R}{\partial r}
\right) -
    \frac{k_{\theta}^2}{r^2}-
    k_x^2
    \label{eqn:waveode2}
\end{equation}
Note that the dispersion relation states $\omega = k A$

\begin{equation}
    \frac{1}{R}
    \left(
    \frac{\partial^2 R}{\partial r^2 } +
    \frac{1}{r}\frac{\partial R}{\partial r}
\right) -
    \frac{k_{\theta}^2}{r^2}-
    k_x^2 + k^2 = 0
    \label{eqn:waveode3}
\end{equation}
The remaining terms are manipulated to follow the same form as \textit{Bessel's Differntial
Equation} ,

\begin{equation}
    x^2 \frac{d^2 y}{dx^2} + x \frac{dy }{dx } + (x^2 - n^2) y = 0
    \label{eqn:besselODE}
\end{equation}

The general solution to Bessel's differential equation is a linear combination of
the Bessel functions of the first kind, $J_n(x)$ and of the second kind, $Y_n(x)$
\cite{wolphram:bessel}. The subscript $n$ refers to the order of Bessel's equation.

\begin{equation}
    y(x) = AJ_n(x) + BY_n(x)
    \label{eqn:besselsolution}
\end{equation}

By rearranging Equation (\ref{eqn:waveode3}), a comparison can be made to Equation
(\ref{eqn:besselODE}) to show that the two equations are of the same form.

The first step is to revisit the radial derivatives that have not been addressed.
As was done for the other derivative terms, the radial derivatives will also
be set equal to a separation constant, $-k_r^2$.

\begin{align}
    \underbrace{\frac{1}{R}
    \left(
    \frac{\partial^2 R}{\partial r^2 } +
    \frac{1}{r}\frac{\partial R}{\partial r}
\right) -
    \frac{k_{\theta}^2}{r^2}}_{-k_r^2}-
    k_x^2 + k^2 = 0
    \label{eqn:wavenumber_without_kr}
\end{align}

The reader may be curious as to why the tangential separation constant $k_{\theta}$ is
included within the definition of the radial separation constant.

Recall the ODE for the tangential direction,

\begin{align*}
    \frac{\partial \Theta}{\partial \theta} \frac{1}{\Theta} = - k_{\theta}^2\\
    \frac{\partial \Theta}{\partial \theta} \frac{1}{\Theta} + \Theta k_{\theta}^2 = 0
\end{align*}

where the solution is more or less,

\begin{align*}
    \Theta(\theta) = e^{i k_{\theta} \theta}
\end{align*}

In order to have non trivial, sensible solutions, the value of $\Theta(0)$ and
$\Theta(2\pi)$ need to be the same, and this needs to be true for any multiple
of $2\pi$ for a fixed r. Taking $\Theta$ to be one, a unit circle, it can be shown that the domain
is only going to be an integer multiple. Therefore, there is an implied periodic
azimuthal boundary condition, i.e. $0<\theta\leq 2 \pi$ and $k_{\theta}=m$.

Continuing with the radial derivatives\ldots

\begin{align*}
    -k_r^2 =\frac{1}{R}
    \left(
    \frac{\partial^2 R}{\partial r^2 } +
    \frac{1}{r}\frac{\partial R}{\partial r}
\right) -
    \frac{m^2}{r^2}
\end{align*}
To further simplify, the chain rule is used to do a change of variables, $x = k_r r$
\begin{align*}
    \frac{\partial R}{\partial r} &= \frac{dR}{dx}\frac{dx}{dr}\\
    &=
    \frac{dR}{dx}\frac{d}{dr}\left( k_r r \right) \\
    &=
    \frac{dR}{dx} k_r
\end{align*}

\begin{align*}
    \frac{\partial^2 R}{\partial r^2} &= \frac{d^2R}{dx^2}\left(\frac{dx}{dr}\right)^2 +
    \frac{dR}{dr}\frac{d^2x}{dr^2}\\
    &=
    \frac{d^2R}{dx^2}\frac{d}{dr} k_r^2 + k_r \frac{d^2r}{dr^2}\\
    &=
    \frac{d^2R}{dx^2}\frac{d}{dr} k_r^2
\end{align*}

Substituting this into Equation (\ref{eqn:waveode3}),
\begin{equation}
    \left(\frac{d^2R}{dx^2}k_r^2 +
    \frac{1}{r}\frac{d^2R}{dx^2}k_r\right) +
    \left(k_r^2 - \frac{m^2}{r^2}\right)R
    \label{eqn:waveode4}
\end{equation}
Dividing Equation \ref{eqn:waveode4} by $k_r^2$,

\begin{equation}
    \left(\frac{d^2R}{dx^2} +
    \frac{1}{k_r r}\frac{d^2R}{dx^2}\right) +
    \left(1  - \frac{m^2}{k_r^2 r^2}\right)R
    \label{eqn:waveode5}
\end{equation}

\begin{equation}
    \left(\frac{d^2R}{dx^2} +
    \frac{1}{x^2}\frac{d^2R}{dx^2}\right) +
    \left(1  - \frac{m^2}{x^2}\right)R
    \label{eqn:waveode6}
\end{equation}

Multiplying Equation (\ref{eqn:waveode6}) by $x^2$ gives,

\begin{equation}
    \frac{d^2R}{dr^2}x^2 +
    \frac{dR}{dr}x +
    \left( x^2 - m^2 \right)R
    \label{eqn:finalradialode}
\end{equation}
which matches the form of Bessel's equation

In summary, the wave equation for no flow in a hollow duct with hard walls is obtained
from Equation (\ref{eqn:wavenumber_without_kr}).
\begin{equation}
    k^2 = k_r^2 + k_x^2
    \label{eqn:wavenumber_equation}
\end{equation}

\subsubsection{Hard Wall boundary condition}
\begin{equation}
    \frac{\partial P}{\partial r} = \frac{\partial}{\partial r} \left( X\Theta T R \right)
\end{equation}

\section{}

To get the same equation but for uniform flow, the same procedure can be followed.

Starting with Equation 2.27 redimensionalized,

\begin{align*}
    \frac{ d^2 \tilde{p}}{d \tilde{r}^2} +
    \frac{1}{\tilde{r}}
    \frac{d \tilde{p}}{d \tilde{r}} +
    \frac{2 \bar{\gamma} \left( \frac{d m_x}{d \tilde{r}} \right)}
    {\left( k - \bar{\gamma} m_x \right)}\frac{d \tilde{p}}{d \tilde{r}}+
    \left[ \left( k - \bar{\gamma} m_x \right)^2 - \frac{m^2}{\tilde{r}^2}-
    \bar{\gamma}^2 \right] \tilde{p}
\end{align*}

Let's separate the new terms from the old ones,

\begin{align*}
    \frac{ d^2 \tilde{p}}{d \tilde{r}^2} +
    \frac{1}{\tilde{r}}
    \frac{d \tilde{p}}{d \tilde{r}} +
    \frac{2 \bar{\gamma} \left( \frac{d m_x}{d \tilde{r}} \right)}
    {\left( k - \bar{\gamma} m_x \right)}\frac{d \tilde{p}}{d \tilde{r}}+
    \left[ \left( k - \bar{\gamma} m_x \right)^2 - \frac{m^2}{\tilde{r}^2}-
    \bar{\gamma} \right] \tilde{p}
\end{align*}

Recalling the non-dimensional definitions,
\begin{align*}
    \tilde{p} &= \frac{p}{\bar{\rho} A^2} \\
    \tilde{r} &= \frac{r}{r_T} \\
    \frac{\partial \tilde{p}}{\partial \tilde{r}} &=
    \frac{ \partial \tilde{p}}{\partial r} \frac{\partial r}{ \partial \tilde{r}}  \\
    &= \frac{ \partial \tilde{p}}{\partial r} \frac{\partial }{ \partial \tilde{r}} \left( \tilde{r} r_T \right) \\
    &=
    \frac{ \partial \tilde{p}}{\partial r}  r_T \\
    \frac{\partial^2 \tilde{p}}{\partial \tilde{r}^2} &=
    \frac{ \partial^2 \tilde{p}}{\partial r^2}  (r_T)^2+
    \frac{ \partial \tilde{p}}{\partial r} \frac{\partial^2 r}{ \partial \tilde{r}^2} \\
    &= \frac{ \partial^2 \tilde{p}}{\partial r^2}  (r_T)^2
\end{align*}

\begin{align*}
    \frac{\partial}{\partial r} \left( \frac{p}{\bar{\rho} A^2} \right)
    &=
    \frac{\left(\frac{\partial}{\partial r} \left(  p\right) \bar{\rho} A^2 -
    \underbrace{\frac{\partial \bar{\rho}A^2}{\partial r}}_0 p \right)}{\left( \bar{\rho} A^2 \right)^2}\\
    &= \frac{1}{\bar{\rho}A^2} \frac{\partial p}{\partial r}
\end{align*}

\begin{align*}
    \frac{ d^2 \tilde{p}}{d \tilde{r}^2} +
    \frac{1}{\tilde{r}}
    \frac{d \tilde{p}}{d \tilde{r}}-
    \frac{m^2}{\tilde{r}^2}\tilde{p}-
    \bar{\gamma}^2  \tilde{p}
 +
    \frac{2 \bar{\gamma} \left( \frac{d M_x}{d \tilde{r}} \right)}
    {\left( k - \bar{\gamma} M_x \right)}\frac{d \tilde{p}}{d \tilde{r}}+
    \left( k - \bar{\gamma} M_x \right)^2\tilde{p}
\end{align*}

If there is only uniform flow, then $dM_x/dr = 0$,

\begin{align*}
    \frac{ d^2 \tilde{p}}{d \tilde{r}^2} +
    \frac{1}{\tilde{r}}
    \frac{d \tilde{p}}{d \tilde{r}}-
    \frac{m^2}{\tilde{r}^2}\tilde{p}-
    \bar{\gamma}^2  \tilde{p}
 +
    \left( k - \bar{\gamma} M_x \right)^2\tilde{p}
\end{align*}

Re-dimensionalizing,

\begin{align*}
    \frac{1}{\bar{\rho} A^2}\left[
    \frac{ d^2 p}{d r} r_T^2+
    \frac{r_T}{r}
    \frac{d p}{d r} r_T -
    \frac{m^2}{r^2}r_T^2 p - k_x^2r_T^2  p\right]
    + \left( \frac{\omega }{A}r_T - k_x r_T M_x \right)^2p
\end{align*}

Expanding the last term and substituting $\omega/A = k$

\begin{align*}
    \frac{1}{\bar{\rho} A^2}\left[
    \frac{ d^2 p}{d r} r_T^2+
    \frac{r_T}{r}
    \frac{d p}{d r} r_T -
    \frac{m^2}{r^2}r_T^2 p - k_x^2r_T^2  p\right]
    +\left( r_T^2\left(
        k^2 - 2 k k_x M_x - k_x^2 M_x^2 \right)
    \right)p
\end{align*}
Canceling out $r_T/\bar{\rho}A$ in every term

\begin{align*}
    \frac{ d^2 p}{d r} +
    \frac{1}{r}
    \frac{d p}{d r} + \left[
    k^2 - 2 k k_x M_x - k_x^2 M_x^2- \frac{m^2}{r^2}  - k_x^2\right]p
\end{align*}

Defining

$$-N^2 = k_x^2 M_x^2 - 2 k k_x M_x - k_x^2 $$
$$-N^2 = -(1 -  M_x^2)k_x^2 - 2 k k_x M_x  $$
$$-N^2 = - \beta^2 k_x^2 - 2 k k_x M_x  $$

\begin{align*}
    \frac{ d^2 p}{d r} +
    \frac{1}{r}
    \frac{d p}{d r} + \left[
    k^2 - N^2 - \frac{m^2}{r^2}  \right]p
\end{align*}

Let $k_r^2 = k^2 - N^2$

\begin{align*}
    \frac{ d^2 p}{d r} +
    \frac{1}{r}
    \frac{d p}{d r} + \left[
    k_r^2  - \frac{m^2}{r^2}  \right]p
\end{align*}

Looking at the radial wavenumber,

\begin{align*}
    k_r^2 &= k^2 - N^2 \\
          &= k^2-\beta^2 k_x^2 - 2 k k_x M_x \\
    0 &= - \beta ^2 k_x ^2 - \left( 2M_x k \right)k_x +(k^2 - k_r^2)
\end{align*}

Where the roots to this equation are the axial wavenumber,

Applying the quadratic formula and taking

\begin{align*}
    <+content+>
\end{align*}<++>
\bibliographystyle{plain}
\bibliography{references}
\end{document}


%---------------------------Average Aspect Frobenius-----------------------------
\section{Mean Aspect Frobenius\label{s:hex-med-aspect-frobenius}}

For hexahedra, there is not a unique definition of the aspect Frobenius.
Instead, we use the aspect Frobenius
defined for tetrahedra (see section~\S\ref{s:tet-aspect-Frobenius}),
but choose the reference $W$ element to be right isosceles at
the hexahedral corner. Consider the eight tetrahedra formed by edges
incident to the corner of a hexahedron.
Given a corner vertex $i$ and its three adjacent vertices $j$, $k$, and $\ell$ ordered
in a clockwise manner (so that $ijk\ell$ is a positively oriented tetrahedron),
denote the tetrahedral aspect frobenius of that corner as $F_{ijk\ell}$.
To obtain a single value for the metric, we average the eight unique tetrahedral aspects
\[
  q = \frac{1}{8}\left(F_{0134} + F_{1205} + F_{2316} + F_{3027} + F_{4750} + F_{5461} + F_{6572} + F_{7643} \right).
\]

\hexmetrictable{mean aspect frobenius}%
{$1$}%                                        Dimension
{$[1,3]$}%                                    Acceptable range
{$[1,DBL\_MAX]$}%                             Normal range
{$[1,DBL\_MAX]$}%                             Full range
{1}%                                          Cube
{--}%                                         Citation
{v\_hex\_med\_aspect\_frobenius}%             Verdict function name


\chapter{Ranked Retrieval}
\begin{multicols*}{2}

\noindent Boolean queries are not suitable for most users and often results in either too few or too many results. In ranked retrieval, users can use natural language for query and we only show top 10 results. \\

\noindent In bag-of-words model, vector representation doesn’t consider the ordering of word in a document.\\

\noindent Term frequency is the number of times a term occurs in a document. \\

$$w_{t,d} =
\begin{cases}
    1 + log_{10} \text{tf}_{t,d} & \text{tf}_{t,d} > 0 \\
    0 & \text{otherwise}
\end{cases}
$$

\noindent Document frequency is number of times a term occurs in a collection of documents. Rare term has low document frequency, and is more informative than frequent terms. Inverse document frequency has no effect on one-term queries.

$$\text{idf}_t = log_{10} \frac{N}{\text{df}_t}$$

\noindent TF-IDF weighting:

$$w_{t,d} = (1+ log_{10} \text{tf}_{t,d})\times log_{10} \frac{N}{\text{df}_t}$$

\noindent SMART Notation: \verb|ddd.qqq|
\begin{center}
\includegraphics[width=8cm]{smart-notion}
\end{center}

\noindent Example: \verb|lnc.ltc|
\begin{center}
\includegraphics[width=8cm]{smart-notion-example}
\end{center}

\noindent We rank documents according to their proximity to the query in vector space. Proximity can be measured using Euclidean Distance or Cosine Similarity.

$$\text{dist}(A,B) = \sqrt{(x_A - x_B)^2 + (y_A - y_B)^2}$$

$$\text{cosine} (\vec{q},\vec{d}) = \frac{\vec{q} \cdot \vec{d}}{|\vec{q}||\vec{d}|}$$

\end{multicols*}