\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage[tight]{subfigure}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{color}
\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}

\lecture{Statistical Techniques in Robotics (16-831, F10)}
{Lecture \#16 (Thursday October $14^{th}$)}
{Lecturer: Drew Bagnell}
{Scribe: Heather Knight, Xinjilefu \footnotemark}
{Bayesian Linear Regression (BLR) Part 1}

\footnotetext{Some content adapted from previous scribes: Kevin Lipkin, Alvaro Collet-Romea, Laura Lindzey and Hans
Pirnay}

\section{Bayes' Online Learning with a Prior}
\subsection{Standard Weighted Majority with a Prior}

\begin{itemize}
\item Numer of experts: $N$
\item Prior: $p_{i}$  ($p_{i} \geq 0$ and $\sum_i p_{i} \geq 1$)
\item Set initial non-uniform weights to each expert: $w_{i}^1 = Np_{i}$
\item Each expert makes prediction $y_{i} \in \{0,1\}$
\item \textbf{for} $t= 1, \cdots, T$ \\
\end{itemize}
Predict:
\begin{itemize}
\item 	Predict 1 \textbf{if}
\begin{align}
  \sum_{y_i = 1}{w_{i}^t} \geq \sum_{y_i=0}{w_{i}^t}
\end{align}
\item	\textbf{else},	Predict 0
\end{itemize}
Update:
\begin{itemize}
\item If expert $e_{i}$ made a mistake, $w_{i}^{t+1} \leftarrow \frac{1}{2} w_{i}^t$
\end{itemize}
Analysis of Algorithm:
\begin{itemize}
\item Total weights of the experts will decrease over time with mistakes $W = \sum_{i}{w_{i}}$
\item Weight of the best expert $w^{*} \leq  W$
\item $m$ is the total number of mistakes predicted by the algorithm
\item $m^*$ are the number of mistakes made by the best expert:
\begin{equation}
	w^* = 2^{-m^*} N p^*
\end{equation}
\item The total weight $W$ is at most
\begin{equation}
	W \leq N\left(\frac{4}{3} \right) ^{-m}
\end{equation}

\item Thus, since $w^* \leq  W$
\begin{equation}
2^{-m^*} N p^* \leq N \left(\frac{4}{3} \right) ^{-m}
\end{equation}

\begin{equation}
-m^* + \log_2 p^* \leq -m c
\end{equation}
where $c = \log_{2}(\frac{4}{3})$

\item Therefore, the total mistakes made by the algorithm are bounded by:
\begin{equation}
m \leq \frac{{m^* + \log_2(\frac{1}{p^*})}}{c}
\end{equation}
\end{itemize}
Weighted majority using prior:
\begin{itemize}
\item No dependence on the number of expert $N$
\item Because of prior, infinite number of experts are possible (except for the weight update)
\item If you see ``log n" where n is some discrete set of experts, think hidden uniform distribution
\item Every learning algorithm has a prior, the prior for the Weighted Majority is all experts are equally good ($p_i =
\frac{1}{N}$)
\item Priors in hypothesis space correspond to weights on experts
\end{itemize}



\subsection{General Weighted Majority Update}
\begin{itemize}
\item Bayes' Rule is a special case of weighted majority
\item Predict:
\begin{itemize}
\item Choose expert $e_i$ in proportion to $\frac{w_{i}}{\sum_{j}{w_{j}}}$
\item Predict the same as what expert $e_{i}$ predicts
\end{itemize}
\item Receive Loss: $l_{t}(i)$
\item Update Weights:
\begin{itemize}
\item $w_{i}^{t+1} = w_{i}^te^{-\alpha l_{t}(i)}$
\\or, use first term of Taylor Series expansion:
\item $w_{i}^{t+1} = w_{i}^t (1-\alpha l_{t}(i))$
\\shows that Bayes Rule has no regret properties
\end{itemize}
\item Expert $e_i$'s prediction is a probability distribution: $p_{i}(y)$
% \item Standard loss for making a probabilistic prediction is log-loss:
% \begin{equation}
% l_{t}(i) = \log{\frac{1}{p_{i}(y_{t})}}
% \end{equation}
% Where $y_{t}$ is the true observation
% \item Plugging the log-loss into the weight update rule:
% \begin{equation}
% w_{i}^{t+1} = w_{i}^te^{\alpha \log{(p_{i}(y_{t}))}}
% \end{equation}
% \item This simplifies to:
% \begin{equation}
% w_{i}^{t+1} = w_{i}^t [p_{i}(y_{t})]^{\alpha}
% \end{equation}
% \item Which, when $\alpha = 1$, is Bayes' Rule exactly.  According to Bayes' Rule: $p(i|y) \propto p(y|i)p(i)$.  In this
% case, $p(i|y)$ is equivalent to $w_i^{t+1}$, $p(i)$ is equivalent to $w_i^{t}$, and $p(y|i)$ is $p_{i}(y_{t})$.
\end{itemize}




\section{Bayes' Linear Regression}
\begin{itemize}
\item $\theta$ = weight vector
\item $x_{t}$ = set of features at every timestep
\item $y_{t}$ = true prediction of outcome
\end{itemize}


\begin{figure}
\centering
\def\svgwidth{.4\columnwidth}
\input{gm.pdf_tex}
\caption{Graphic model of BLR}
\label{F:BLR}
\end{figure}


We want to derive how to update our representation given a series of data $D = \{x, y\}$ up to timestep $t$ and $x_{t+1}$, the probability of an observation $\tilde{y}_{t+1}$ is
\begin{eqnarray}
p(\tilde{y}_{t+1}|x_{t+1},D) &=& \int p(\tilde{y}_{t+1}|x_{t+1},D,\theta)\cdot p(\theta|D)d\theta\\
&=& \int p(\tilde{y}_{t+1}|x_{t+1},\theta)\cdot p(\theta|D)d\theta
\end{eqnarray}
In BLR, the prior of the weight vector $\theta$ is a Gaussian where $\theta \sim N(\mu_0, \Sigma_0)$.
\begin{align}
\label{E:moment}
p(\theta) = \frac{1}{z} \exp \{-(\theta-\mu_0)^{T}\Sigma_0^{-1}(\theta-\mu_0)\}
\end{align}
This is called the Moment Parameterization of a Guassian, where $\Sigma_0$ is positive-definite and symmetric. \\

The Natural Parameterization is given by:
\begin{equation}
p(\theta) = \frac{1}{z} \exp \{J_0^{T}\theta - \frac{1}{2}\theta^{T}P_0 \theta\}
\end{equation}
where
\begin{align}
P_0 & = \Sigma_0^{-1} \\
J_0 & = P_0 \mu_0
\end{align}

We can calculate $p(\theta | D)$ recursively using the Bayes' Theorem
\begin{align}
    p(\theta | D) = \dfrac{1}{z} p(y_t |\theta,D) p(\theta|D)
\end{align}
where we know the likelihood $p(y_t |D, \theta) = p(y_t |x_t, \theta)$ is given by a Gaussian $\mathcal{N}(\theta^Tx_t,\sigma_t^2)$
\begin{eqnarray}
p(y_t|x_t,\theta) =  \dfrac{1}{z} \exp \{ \dfrac{-(\theta^T x_t-y_t)^2}{2\sigma^2} \}
\end{eqnarray}
The updating rule for $p(\theta|D)$ at timestep $t$ is given by multiplication of two exponential functions. Adding the exponent of the prior to that of the likelihood yields
\begin{eqnarray}
-\frac{1}{2\sigma^2}\left(\theta^Tx_t-y_t\right)^2 + J_{t-1}^T\theta - \frac{1}{2}\theta^TP_{t-1}\theta
\end{eqnarray}
collecting terms to find updates $J_t$ and $P_t$:
\begin{eqnarray}
&=&-\frac{1}{2\sigma^2}\left(\theta^Tx_t x_t^T\theta-2\theta^Tx_t y_t + y_t^2\right) + J_{t-1}^T\theta - \frac{1}{2}\theta^TP_{t-1}\theta\\
&=&\left(\frac{x_t^Ty_t}{\sigma^2}+J_{t-1}^T\right)\theta  -\frac{1}{2}\theta^T\left(\frac{x_t x_t^T}{\sigma^2} + P_{t-1}\right)\theta - \frac{y_t^2}{2\sigma^2}
\end{eqnarray}
Since this all happens in the exponent of an exponential function, the constant $y_t^2/\sigma^2$-term can be shifted into the regularizing constant $z$. Thus, the update rules for $J_t$ and $P_t$ are
\begin{eqnarray}
J_t &=& \frac{y_t x_t}{\sigma^2} + J_{t-1}\\
P_t &=& \frac{x_t x_t^T}{\sigma^2} + P_{t-1}
\end{eqnarray}
\begin{enumerate}
\item In a gaussian model, a new datapoint \underline{always} lowers the variance - this downgrading of the variance does not always make sense
\item If you believe there are outliers, this model won't work for you
\item The variance is not a function of $y_t$. The precision is only affected by \underline{input not output}. This is a consequence of having the same $\sigma$ (observation error) everywhere in space.
\end{enumerate}

\end{document}
