\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage[tight]{subfigure}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {#1} \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[5]{\handout{#1}{#2}{#3}{#4}{#5}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex

%\renewcommand{\baselinestretch}{1.25}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document header: change the lecture number, date, scribe name, and
% lecture topic.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\lecture{Statistical Techniques in Robotics (16-831, F10)}
{Lecture\#22 (Thursday November 4)}
{Lecturer: Drew Bagnell}
{Scribe:Joseph Lisee \footnotemark}
{Guassian Processes}

% Be sure to acknowledge all previous scribes.
\footnotetext{Some content adapted from previous scribes: Alberto Rodriguez, Stephane Ross}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document body: Scribe your notes here.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Gaussian Processes}


\subsection{Introduction}
There are many machine learning problems for which regression is a viable solution.  Examples of linear regression methods include Bayes linear regression (BLR) and online convex programming when applied to square laws. For some problems linear approximations do not provide enough accuracy in their estimates and nonlinear methods methods like extended kalman filters are required. Gaussian processes are the state of the art in nonlinear regression methods, but unlike the previously covered methods it is a non-parametric method with infinitely many parameters. 

Gaussian process regression uses a multidimensional gaussian with a dimension for each training and test point. To compute posterior probability at a test point you condition on the training data points. For example we can start with two dimensional gaussian with mean $\mu$ and variance $\Sigma$:

\begin{equation}
  \begin{array}{rcl}
    \left[ \begin{array}{c}
        y_1\\
        y_2\\
      \end{array}
      \right]
    &
    \sim
    &
    N \left(
    \left[ \begin{array}{c}
        \mu_1\\
        \mu_2\\
      \end{array}
      \right],
    \left[ \begin{array}{cc}
        \Sigma_{11} & \Sigma_{12}\\
        \Sigma_{21} & \Sigma_{22}\\
      \end{array}
      \right] 
    \right)
  \end{array}
\end{equation}

We can then find the conditional distrobution $P(x_2|x_1)$ with the following equations:
\begin{equation}\label{eq:mu-cond}
  \mu_{2|1} = \mu_2 + \Sigma_{21} \Sigma_{11}^{-1} (y_1 - \mu_1)
\end{equation}

\begin{equation}\label{eq:sigma-cond}
  \sigma_{2|1} = \Sigma_{22} - \Sigma_{21} \Sigma_{11}^{-1} \Sigma_{12} 
\end{equation}

This entire process can be expanded to match the size of the date set and is covered in more detail in section \ref{subsec:computpose}. The next section will formally define gaussian processes and cover how the $\Sigma$ matrix is computed from a data set.

\subsection{Formal Definition}

A gaussian process is a random stochastic process where correlation is introduced between neighboring samples (think of a stochastic process as a sequence of random variables). The same way that an instance of a random variable is a single sample, an instance of a stochastic process can be thought as vector of samples:

\begin{equation}
  X = \left[ x_1, x_2, x_3 \ldots\right]
\end{equation}

Gaussian Processes artificially introduce correlation between close samples in that vector in order to enforce some sort of smoothness on the succession of samples. The way that correlation is introduced is by constructing the joint probability distribution of the long vector of samples. Gaussian processes assume that probability distribution to be a multidimensional gaussian:

\begin{equation}
  p(X^i) = \frac{1}{z} e^{(X - \mu)\Sigma^{-1}(X - \mu)}
\end{equation}

The correlation between samples in the succession $X^i$ depends on matrix $\Sigma$. In Gaussian Processes the covariance matrix is constructed as the Gram matrix of the samples with some desired kernel $\kappa(\cdot,\cdot)$ as the inner product:

\begin{equation}\label{eq:kappa}
  \begin{gathered}
    \Sigma=\left( \begin{array}{cccc}
      \kappa(x_1,x_1)& \kappa(x_1,x_2) & \dotsb & \kappa(x_1,x_n)\\
      \kappa(x_2,x_1)& \kappa(x_2,x_2) & \dotsb & \kappa(x_2,x_n)\\
      \vdots & & & \vdots\\
      \kappa(x_n,x_1)& \kappa(x_n,x_2) & \ldots & \kappa(x_n,x_n)\end{array}                                                   \right)
  \end{gathered}
\end{equation}

In order to introduce correlation between neighboring samples, the kernel $\kappa$ is usually designed to have small support and centered around zero (i.e. a triangular or a gaussian). The kernel usually can be described as a function of the distance $x_i-x_j$ and must be symmetric and positive definite. That is $\kappa(x,x') = \kappa(x',x)$, and the kernel matrix $K$ induced by $k$ for any set of input is a positive definite matrix. Example of some kernel functions are given below:

\begin{figure}
  \begin{center}
    \includegraphics[width=0.6\textwidth]{kernel_matrix.png}
  \end{center}
\caption{A plot of the laplace kernel with $\gamma = 1$ where $\textbf{x} = (0, 0.2, 0.4, \dots, 6)$. The correlation quickly tapers off as the distance between data points increase.\label{fig:kernel}}
\end{figure}

\begin{itemize}
\item Squared Exponential Kernel (Gaussian/RBF): $\kappa(x,x') =       \exp(\frac{-(x-x')^2}{2\gamma^2})$ where $\gamma$ is the length scale of the kernel.
\item Laplace Kernel: $\kappa(x,x') = \exp(\frac{-|x-x'|}{\gamma})$ (See in figure \ref{fig:kernel} for an example).
\item Indicator Kernel: $\kappa(x,x') = I(x=x')$, where $I$ is the indicator function.
\item Linear Kernel: $\kappa(x,x') = x^Tx'$.
\end{itemize}

More complicated kernels can be constructed by adding known kernel functions together, as the sum of two kernel functions is also a kernel function.

\subsection{Gaussian Processes as a Distrobution Over Functions}
A gaussian process can be thought of as a gaussian distribution over functions (thinking of functions as infinitely long vectors containing the value of the function at every input). Formally let the input space $\mathcal{X}$ and $f : \mathcal{X} \rightarrow \mathbb{R}$ a function from the input space to the reals, then we say $f$ is a gaussian process if for any vector of inputs $\textbf{x} = [x_1, x_2, \dots, x_n]^T$ such that $x_i \in \mathcal{X}$ for all $i$, the vector of output $f(\textbf{x})$ = $[f(x_1), f(x_2), \dots, f(x_n)]^T$ is gaussian distributed.

The gaussian process is specified by a mean function $\mu : \mathcal{X} \rightarrow \mathbb{R}$, such that $\mu(x)$ is the mean of $f(x)$ and a covariance/kernel function $k: \mathcal{X} \times \mathcal{X} \rightarrow \mathbb{R}$ such that $\kappa(x,x')$ is the covariance between $f(x)$ and $f(x')$. We say $f \sim GP(\mu,k)$ if for any $x_1, x_2, \dots x_n \in \mathcal{X}$, $[f(x_1), f(x_2), \dots, f(x_n)]^T$ is gaussian distributed with mean $[\mu(x_1), \mu(x_2), \dots, \mu(x_n)]^T$ and $n \times n$ covariance/kernel matrix $K_{Data}$:

\subsection{Inference}

Gaussian Processes are useful as priors over functions for doing non-linear regression. Given a set of observed input and corresponding output values $(x_1, f(x_1)), (x_2, f(x_2)), \dots, (x_n, f(x_n))$, and gaussian process prior on $f$, $f \sim GP(\mu,k)$, we would like to compute the posterior over the value $f(x^*)$ at any query input $x^*$. Figure \ref{figInference} illustrates this process. Sample functions from a prior zero-mean GP are first shown on the left, and after observing a few values, the posterior mean and sample functions from the posterior are shown on the right. We can observe from this that the sample functions from the posterior passes close to the observed values but varies a lot in region where there is no observation.

\begin{figure}
\begin{minipage}{0.49\textwidth}
\includegraphics[width=\textwidth]{gp_prior.png}
\end{minipage}
\hfill
\begin{minipage}{0.49\textwidth}
\includegraphics[width=\textwidth]{gp_posterior.png}
\end{minipage}
\caption{Samples from a zero-mean GP prior (Left) and samples from the posterior after a few observations (Right).\label{figInference}}
\end{figure}

\subsection{Computing the Posterior} \label{subsec:computpose}

The posterior can be derived similarly to how the update equations for the Kalman filter was derived. First we will find what is the joint distribution of $[f(x^*), f(x_1), f(x_2), \dots, f(x_n)]^T$, and then use the conditioning rule for gaussian to compute the conditional distribution of 
\[
f(x^*)|f(x_1), \dots, f(x_n)
\]

Assume for now that the prior mean function $\mu = 0$. Then the joint distribution of 
\[
[f(x^*), f(x_1), f(x_2), \dots, f(x_n)]^T
\]
is gaussian:

\begin{equation}
  \begin{array}{rcl}
    \left[ \begin{array}{c}
        f(x_1)\\
        \dots\\
        f(x_n)\\
        f(x^*)\\
      \end{array}
      \right]
    &
    \sim
    &
    N \left(
    \left[ \begin{array}{c}
        0\\
        0\\
        \dots\\
        0\\
      \end{array}
      \right],
    \left[ \begin{array}{cc}
        K_{Data} & \kappa(x^*,\textbf{x})^T\\
        \kappa(x^*,\textbf{x}) & \kappa(x^*,x^*)\\
      \end{array}
      \right] \right)
  \end{array}
\end{equation}

where

\begin{equation}
  \kappa(x^*,\textbf{x}) = \left[ \begin{array}{c}
      \kappa(x^*,x_1) \\
      \kappa(x^*,x_2) \\
      \dots \\
      \kappa(x^*,x_n) \\
    \end{array} \right]
\end{equation}

Now using the conditioning rule we obtained that the posterior for $f(x^*)$ is gaussian:

\begin{equation} 
  \begin{array}{ccccccc}
    f(x^*)|f(\textbf{x}) & \sim & N( & \kappa(x^*,\textbf{x})^T K_{Data}^{-1}                 f(\textbf{x}) & , & \kappa(x^*, x^*) + \kappa(x^*,\textbf{x})^T K_{Data}^{-1} \kappa(x^*,\textbf{x}) & )\\
  \end{array}
\end{equation}


\end{document}
