% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.\
\documentclass[12pt,twocolumn]{article} %,twocolumn

%\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
%\documentstyle[times,twocolumn]{article}
\usepackage[dvips]{graphicx,graphics}
% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{10in} \setlength{\textwidth}{7in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.5in}  % Centers text.
\setlength{\evensidemargin}{-.5in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand {\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471: Lecture 6\\
Multivariate normal distributions Part II.}
% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
% For two authors (default example)
\maketitle \thispagestyle{empty}

\begin{enumerate}


\item For given bivariate data $w_i=(x_i,y_i)$, we are interested
in testing if the data follows bivariate normal. Bivariate normal
data is somewhat simpler to analyze. If $X$ and $Y$ are bivariate
normal with $X \sim N(\mu_X,\sigma_X^2)$ and $Y \sim
N(\mu_Y,\sigma_Y^2)$,
$$\mathbb{E}(Y|X=x)= \beta_0 + \beta_1x,$$
where $\beta_1=\rho\sigma_Y/\sigma_X$.

\item You may use $\chi^2$ goodness-of-fit test or other tests to
check bivariate normalness but a simpler approach would be to
check if given bivariate data can be generated via linear
transform $$
w=Hz +\mu \sim N(\mu,HH')$$ where $z \sim N(0, I)$.
First estimate the sample covariance matrix:
$$\hat V = \frac{1}{n}\sum_{i=1}^n (w_i - \bar w)(w_i -\bar w)',$$
where $\bar w$ is the sample mean vector. The sample variance
matrix is an estimator of unknown population covariance $V$. It
can be computed using the {\em Kroneker tensor product} $\otimes$.
For $A=(a_{ij})$ and $B$, $A \otimes B = (a_{ij}B)$.
\begin{verbatim}
>>barw=mean(w,2);
>>temp=w-kron(ones(1,1000),barw);
>>hatV=temp*temp'/1000;
hatV =
    2.0982    1.0232
    1.0232    1.9711
\end{verbatim}
Let $\hat V = \hat H \hat H'$ be the Cholesky factors. Then $z =
\hat H^{-1}w$.
\begin{verbatim}
>> hatH=chol(hatV)'
hatH =
    1.4485         0
    0.7064    1.2133
>> inv(hatH)
ans =
    0.6904         0
   -0.4019    0.8242
>> newz=inv(hatH)*w;
>>qqplot(newz(1,:));qqplot(newz(2,:));
\end{verbatim}

\item Other factorization technique for covariance matrix $V$.
Suppose $V$ has positive eigenvalues $\lambda_i$ and corresponding
normalized eigenvectors $e_i$. Let $Q=(e_1,e_2,e_3)$. Then $QQ'=I$
and $V=QDiag(\lambda_1, \lambda_2, \lambda_3)Q'.$ So
$V^{1/2}=QDiag(\lambda_1^{1/2}, \lambda_2^{1/2},
\lambda_3^{1/2})Q'.$ For $z \sim N(0,I)$, $w=V^{1/2}z \sim
N(0,V)$.
\begin{verbatim}
>>V=[2 1
     1 2]
>> [Q D]=eig(V)
Q = -0.7071    0.7071
     0.7071    0.7071
D =  1     0
     0     3
>> Q*D.^(1/2)*Q'
ans = 1.3660    0.3660
      0.3660    1.3660
>> V^(1/2)
ans = 1.3660    0.3660
      0.3660    1.3660
>>w=V^(1/2)*[z1 z2]';
\end{verbatim}
It can be shown that generating bivariate normal this way gives
the identical distribution as the Cholesky factorization (HW2).

\end{enumerate}
\end{document}
