% \documentclass[serif]{beamer} % Serif for Computer Modern math font.
\documentclass[serif, handout]{beamer} % Handout to ignore pause statements

\hypersetup{colorlinks,linkcolor=,urlcolor=red}


\usefonttheme{serif} % Looks like Computer Modern for non-math text -- nice!
\setbeamertemplate{navigation symbols}{} % Suppress navigation symbols
% \usetheme{Berlin} % Displays sections on top
\usetheme{Frankfurt}  % Displays section titles on top: Fairly thin but still swallows some material at bottom of crowded slides
%\usetheme{Berkeley}

\usepackage[english]{babel}
\usepackage{amsmath} % for binom
% \usepackage{graphicx} % To include pdf files!
% \definecolor{links}{HTML}{2A1B81}
% \definecolor{links}{red}
\setbeamertemplate{footline}[frame number] 

\mode<presentation>

\title{Random Vectors\footnote{See last slide for copyright information.}}
\subtitle{STA 302 Fall 2016}
\date{} % To suppress date

\begin{document}

\begin{frame}
  \titlepage
\end{frame}


\begin{frame}
\frametitle{Random Vectors and Matrices}
\framesubtitle{See Chapter 3 of \emph{Linear models in statistics} for more detail.}  \pause
\begin{itemize}
    \item A \emph{random matrix} is just a matrix of random variables. \pause
    \item Their joint probability distribution is the distribution of the random matrix. \pause
    \item  Random matrices with just one column (say, $p \times 1$) may be called \emph{random vectors}.
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Expected Value}
%\framesubtitle{} 

The expected value of a random matrix is defined as the matrix of expected values.  \pause
Denoting the $p \times c$ random matrix $\mathbf{X}$ by $[X_{i,j}]$, \pause
\begin{displaymath}
    E(\mathbf{X}) = [E(X_{i,j})].
\end{displaymath}
\end{frame}

\begin{frame} 
\frametitle{Immediately we have natural properties like}
%\framesubtitle{} 
\begin{eqnarray*}
    E(\mathbf{X}+\mathbf{Y}) &=&  \pause E([x_{i,j}+y_{i,j}])       \\ \pause
                             &=& [E(x_{i,j}+y_{i,j})]       \\ \pause
                             &=& [E(x_{i,j})+E(y_{i,j})]    \\ \pause
                             &=& [E(x_{i,j})]+[E(y_{i,j})]  \\ \pause
                             &=& E(\mathbf{X})+E(\mathbf{Y}). 
\end{eqnarray*}
\end{frame} 

\begin{frame}
\frametitle{Moving a constant matrix through the expected value sign} \pause
Let $\mathbf{A} = [a_{i,j}]$ be an $r \times p$ matrix of constants, while $\mathbf{X}$ is still a $p \times c$ random matrix. Then  \pause
\begin{eqnarray}
    E(\mathbf{AX}) 
        &=& E\left(\left[\sum_{k=1}^p a_{i,k}x_{k,j}\right]\right) \nonumber \\ \pause
        &=& \left[E\left(\sum_{k=1}^p a_{i,k}x_{k,j}\right)\right] \nonumber \\ \pause
        &=& \left[\sum_{k=1}^p a_{i,k}E(x_{k,j})\right] \nonumber \\ \pause
        &=& \mathbf{A}E(\mathbf{x}). \nonumber
\end{eqnarray} \pause

Similar calculations yield $E(\mathbf{AXB}) = \mathbf{A}E(\mathbf{X})\mathbf{B}$.
\end{frame}

\begin{frame}
\frametitle{Variance-Covariance Matrices} \pause
Let $\mathbf{x}$ be a $p \times 1$ random vector with $E(\mathbf{x}) = \boldsymbol{\mu}$.  \pause
The \emph{variance-covariance matrix} of $\mathbf{x}$ (sometimes just called the \emph{covariance matrix}), denoted by $cov(\mathbf{x})$, is defined as  \pause
\begin{displaymath}
    cov(\mathbf{x}) = E\left\{ (\mathbf{x}-\boldsymbol{\mu})
                             (\mathbf{x}-\boldsymbol{\mu})^\prime\right\}.
\end{displaymath}
\end{frame}


\begin{frame}
\frametitle{$cov(\mathbf{x}) = E\left\{ (\mathbf{x}-\boldsymbol{\mu})
                             (\mathbf{x}-\boldsymbol{\mu})^\prime\right\}$} \pause
\begin{columns}   % Use Beamer's columns to use more of the margins!
\column{1.1\textwidth}
{\scriptsize
\begin{eqnarray*}
   cov(\mathbf{x}) &=& E\left\{
        \left( \begin{array}{c}
        x_1-\mu_1 \\  x_2-\mu_2 \\ x_3-\mu_3
        \end{array} \right)
        \left( \begin{array}{c c c}
        x_1-\mu_1 &  x_2-\mu_2 & x_3-\mu_3
        \end{array} \right) \right\}  \\ \pause
  &=& E\left\{
        \left( \begin{array}{l l l}
        (x_1-\mu_1)^2 &  (x_1-\mu_1)(x_2-\mu_2) & (x_1-\mu_1)(x_3-\mu_3) \\
        (x_2-\mu_2)(x_1-\mu_1) &  (x_2-\mu_2)^2 & (x_2-\mu_2)(x_3-\mu_3) \\
        (x_3-\mu_3)(x_1-\mu_1) &  (x_3-\mu_3)(x_2-\mu_2) & (x_3-\mu_3)^2 \\
        \end{array} \right) \right\}  \\ \pause
         \nonumber \\
  &=& 
    \left( \begin{array}{l l l}
    E\{(x_1-\mu_1)^2\} &  E\{(x_1-\mu_1)(x_2-\mu_2)\} & E\{(x_1-\mu_1)(x_3-\mu_3)\} \\
    E\{(x_2-\mu_2)(x_1-\mu_1)\} &  E\{(x_2-\mu_2)^2\} & E\{(x_2-\mu_2)(x_3-\mu_3)\} \\
    E\{(x_3-\mu_3)(x_1-\mu_1)\} &  E\{(x_3-\mu_3)(x_2-\mu_2)\} & E\{(x_3-\mu_3)^2\} \\
        \end{array} \right)   \\ \pause
         \nonumber \\
  &=& 
    \left( \begin{array}{l l l}
    Var(x_1) &  Cov(x_1,x_2) & Cov(x_1,x_3) \\
    Cov(x_1,x_2) &  Var(x_2) & Cov(x_2,x_3) \\
    Cov(x_1,x_3) &  Cov(x_2,x_3) & Var(x_3) \\
        \end{array} \right) .  \\ \pause
         \nonumber 
\end{eqnarray*}
So, the covariance matrix $cov(\mathbf{x})$ is a $p \times p$ symmetric matrix with variances on the main diagonal and covariances on the off-diagonals. 
}% End size
\end{columns}

\end{frame}

\begin{frame}
\frametitle{Analogous to $Var(a\,x) = a^2\,Var(x)$} \pause
Let $\mathbf{x}$ be a $p \times 1$ random vector with $E(\mathbf{x}) = \boldsymbol{\mu}$ and $cov(\mathbf{x}) = \boldsymbol{\Sigma}$, while $\mathbf{A} = [a_{i,j}]$ is an $r \times p$ matrix of constants. Then \pause
\begin{eqnarray*} 
    cov(\mathbf{Ax}) 
    &=&  \pause
    E\left\{ (\mathbf{Ax}-\mathbf{A}\boldsymbol{\mu})
             (\mathbf{Ax}-\mathbf{A}\boldsymbol{\mu})^\prime \right\}  \\ \pause
    &=& 
    E\left\{ \mathbf{A}(\mathbf{x}-\boldsymbol{\mu})
             \left(\mathbf{A}(\mathbf{x}-\boldsymbol{\mu})\right)^\prime 
             \right\}  \\ \pause
    &=& 
    E\left\{ \mathbf{A}(\mathbf{x}-\boldsymbol{\mu})
             (\mathbf{x}-\boldsymbol{\mu})^\prime \mathbf{A}^\prime
             \right\} \nonumber \\ \pause
    &=&      \mathbf{A}E\{(\mathbf{x}-\boldsymbol{\mu})
             (\mathbf{x}-\boldsymbol{\mu})^\prime\} \mathbf{A}^\prime
              \\ \pause
    &=&      \mathbf{A}cov(\mathbf{x}) \mathbf{A}^\prime \nonumber \\
    &=&      \mathbf{A}\boldsymbol{\Sigma}\mathbf{A}^\prime 
\end{eqnarray*}
\end{frame}

\begin{frame}
\frametitle{Positive definite is a natural assumption}
\framesubtitle{For covariance matrices}  \pause
  \begin{itemize}
    \item $cov(\mathbf{x}) = \boldsymbol{\Sigma}$ \pause
    \item $\boldsymbol{\Sigma}$ positive definite means $\mathbf{a}^\prime \boldsymbol{\Sigma} \mathbf{a} > 0$.
          for all $\mathbf{a} \neq \mathbf{0}$. \pause
    \item $y = \mathbf{a}^\prime \mathbf{x} = a_1x_1 + \cdots + a_p x_p$ is a scalar random variable. \pause
    \item $Var(y) = \mathbf{a}^\prime cov(\mathbf{x}) \mathbf{a}  \pause 
          = \mathbf{a}^\prime \boldsymbol{\Sigma} \mathbf{a}$   \pause 
    \item $\boldsymbol{\Sigma}$ positive definite just says that the variance of any (non-trivial) linear combination is positive.  \pause
    \item This is often what you want (but not always).
  \end{itemize}



\end{frame}


\begin{frame}
\frametitle{Matrix of covariances between two random vectors}  \pause
Let $\mathbf{x}$ be a $p \times 1$ random vector with $E(\mathbf{x}) = \boldsymbol{\mu}_x$ and let $\mathbf{y}$ be a $q \times 1$ random vector with $E(\mathbf{y}) = \boldsymbol{\mu}_y$.   \pause

\vspace{3mm}

The $p \times q$ matrix of covariances between the elements of $\mathbf{x}$ and the elements of $\mathbf{y}$ is  \pause
\begin{displaymath}
    C(\mathbf{x,y}) = E\left\{ (\mathbf{x}-\boldsymbol{\mu}_x)
                             (\mathbf{y}-\boldsymbol{\mu}_y)^\prime\right\}.
\end{displaymath}
\end{frame}


\begin{frame}
\frametitle{Adding a constant has no effect}
\framesubtitle{On variances and covariances}  \pause

It's clear from the definitions
  \begin{itemize}
    \item $cov(\mathbf{x}) = E\left\{ (\mathbf{x}-\boldsymbol{\mu})
                             (\mathbf{x}-\boldsymbol{\mu})^\prime\right\}$
    \item $C(\mathbf{x,y}) = E\left\{ (\mathbf{x}-\boldsymbol{\mu}_x)
                             (\mathbf{y}-\boldsymbol{\mu}_y)^\prime\right\}$
  \end{itemize}  \pause
That
  \begin{itemize}
    \item $ cov(\mathbf{x} + \mathbf{a}) = cov(\mathbf{x})$  \pause
    \item $C(\mathbf{x} + \mathbf{a},\mathbf{y} + \mathbf{b})  \pause
        = C(\mathbf{x},\mathbf{y})$
  \end{itemize}
\vspace{5mm}  \pause
For example, $E(\mathbf{x} + \mathbf{a}) = \boldsymbol{\mu} + \mathbf{a}$, so   \pause
\begin{eqnarray*}
    cov(\mathbf{x} + \mathbf{a}) 
    & = & E\left\{ (\mathbf{x}+\mathbf{a}-(\boldsymbol{\mu}+\mathbf{a}))
          (\mathbf{x}+\mathbf{a}-(\boldsymbol{\mu}+\mathbf{a}))^\prime\right\} \\  \pause
    & = & E\left\{ (\mathbf{x}-\boldsymbol{\mu})
                   (\mathbf{x}-\boldsymbol{\mu})^\prime\right\} \\  \pause
    & = & cov(\mathbf{x})
\end{eqnarray*}
\end{frame}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{frame}
\frametitle{Copyright Information}

This slide show was prepared by  \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner},
Department of Statistical Sciences, University of Toronto. It is licensed under a 
\href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US}
     {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website:
\href{http://www.utstat.toronto.edu/~brunner/oldclass/302f16} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/302f16}}

\end{frame}


\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
\frametitle{}
%\framesubtitle{} 
  \begin{itemize}
    \item 
    \item 
    \item 
  \end{itemize}
\end{frame}

{\LARGE
\begin{displaymath}
    
\end{displaymath} }




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
