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

\graphicspath{{figures/}}

\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}

\newcommand{\lecref}[1]{[lecture~\##1]}
\newcommand{\figref}[1]{Fig.~\ref{fig:#1}}
\newcommand{\secref}[1]{Section~\ref{sec:#1}}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document header: change the lecture number, date, scribe name, and
% lecture topic.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\lecture{Statistical Techniques in Robotics (16-831, F10)}
{Lecture\#04 (Thursday September 2)}
{Lecturer: Drew Bagnell}
{Scribe:Joydeep Biswas}% \footnotemark}
{Particle Filters: The Good, The Bad, The Ugly, And Some Fixes}

% Be sure to acknowledge all previous scribes.
%\footnotetext{Some content adapted from previous scribes: name1, name2, ...}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document body: Scribe your notes here.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%================================================================================
\section{Particle Filters: The Good}

\begin{enumerate}
\item Particle filters can answer most queries with samples of $Bel(x)$:\\
This is good because we do not need (and indeed, in most cases would not have) a complete solution of $Bel(x)$
 
\item (Normalized) Importance Sampling \lecref{3}:\\
Even if we cannot sample from 
\begin{eqnarray}
p(x_{t+1}|x_t,z_{t+1},u_t) &\propto& p(z_{t+1}|x_{t+1}) \cdot p(x_{t+1}|x_t,u_t) \\
p(x_{t+1}|x_t,z_{t+1},u_t) &=& \frac{obs.motion}{\mathds{Z}}
\label{eq:p_sampling}
\end{eqnarray}
we can use some distribution $q$ instead of $p$ to sample from, and factor out importance weights \lecref{3}. However, unless 
$q$ closely matches $p$, the weights would get increasingly smaller.

\item Works with a finite number of particles:\\
Particle filters (should) use resampling to do ``survival of the fittest'', thus sampling densely around where the best estimates lie.
\end{enumerate}

%================================================================================
\section{Particle Filters: The Bad}

\subsection{Loss of diversity}
\label{sec:lossofdiversity}

Repeated resampling (without low variance resampling) in the absence of any actual sensory observations could lead to loss of diversity. This problem is illustrated by the following example of a robot localizing itself in two dimensions on a map with two (identical) rooms. 

\figref{two_rooms_t0} shows the state of a particle filter at a particular instant of time (say, $t=0$). Suppose that the two clusters of particles have equal weights, and each particle has weight $1/N$, where $N$ = number of particles. After resampling in the next iteration, (if the particle filter does not use low variance resampling), it is unlikely that both the resampled clusters will still have equal weights. In the absence of any new observations, the particle filter would end up (after a few more time steps) in a state like that in \figref{two_rooms_tn}, where one cluster has dwindled at the expense of the other, for no good reason.

\begin{figure} [h!]
\centering \def\svgwidth{8cm} \input{figures/two_rooms_t0.pdf_tex}
\caption{Loss of diversity example: State of particles at time step $t=0$, with two equally weighted clusters and all particles with equal weights.}
\label{fig:two_rooms_t0}
\end{figure}

\begin{figure} [h!]
\centering \def\svgwidth{8cm} \input{figures/two_rooms_tn.pdf_tex}
\caption{Loss of diversity example: State of particles at a later time step. The particles have essentially coalesced to a simgle hypotheses, located in room 2.}
\label{fig:two_rooms_tn}
\end{figure}

\subsection{Really good observation models result in bad particle filters}
\label{sec:goodobs}

\begin{figure} [htb]
\centering \def\svgwidth{8cm} \input{figures/goodobs.pdf_tex}
\caption{``Good'' observation model: The observation likelihood has an accurate and confident (tall and narrow) peak around location $x_1$, and an erroneous low intensity peak around $x_2$.}
\label{fig:goodobs}
\end{figure}

If the observation model is really good (both accurate and confident), then the updates of the belief of the particle filter are likely to result in confident (closely clustered), yet incorrect estimates. This problem is best illustrated by the following example of a robot localizing itself in a single dimension $x$. \figref{goodobs} shows the observation likelihood $P(z|x)$ at an instant of time. Notably, the observation model has a very narrow but strong peak at location $x_1$, where the sensor believes that the robot is located. Also, there is a smaller peak due to some noisy readings (say) at location $x_2$. The observation likelihood is uniformly infinitesimal everywhere else. Given this observation likelihood, two problematic issues are likely to crop up:


\begin{enumerate}
\item Given the narrow width of the peak around $x_1$, it is likely that no particle would fall within the region covered by the peak. Thus, the weights of most particles would be driven to zero, and the accurate location estimate (as provided by the observation model) would be lost.
\item It is likely that a particle (or more) might lie under the region covered by the hump around $x_2$, and its (or their) weight(s) would increase with respect to the other particles, which (as described by the last point) would have infinitesimal weights. This would result in the particle filter providing a confident, albeit completetely wrong estimate of the robot's location.
\end{enumerate}

\subsection{Non-deterministic behaviour}
Given the random sampling necessary for a particle filter, it is unlikely that two particle filters, even with identical initial states and observations of time, would follow the exact same history of estimates. 

\subsection{Mismatch between $p$ and $q$}
The farther $q$ is to $p$, the lesser it will be sampling the modes of $p$. Eventually, the particle filter could entirely loose track of the modes of $p$, and degenerate into overconfident, yet incorrect estimates.

%================================================================================
\section{Particle Filters: The Ugly (Misconceptions)}

\begin{enumerate}
\item ``\emph{Particle filters sample from a motion model, weight by an observation model}''\\
Particle filters do not \emph{always} sample from a motion model and then weight by an observation model. 
They \emph{could} sample from other distributions, if they were available, easy to sample from, and/or more accurate.

\item ``\emph{Particle filters are for localization}''\\
Particle filters are not used \emph{exclusively} for localization

\end{enumerate}


%================================================================================
\section{Particle Filters: Fixes For The Bad}
\setcounter{subsection}{-1}
\subsection{Use more particles}
With infinite particles, even if $p$ and $q$ were dissimilar, one could at least ensure that $q$ was such that all regions of $p$ were being sampled. Also, resampling would not be as crucial.

\subsection{Resample less}
This would partially fix the issue raised in \secref{lossofdiversity}. One approach is to resample only when the variance in the weights of the particles is high.

\subsection{Better resampling}

This would again help with the issue raised in \secref{lossofdiversity}.
Before resampling, (conceptually) a list of the particles is created (\figref{sample_list}), with the length of the list equal to the sum of the weight of the particles, (say) $W$, such that each particle (conceptually) occupies a length in the list equal to its weight.\\
The na\"{\i}ve approach to resampling is to pick $N$ random samples from the list, as depicted in \figref{naivesampling}. Intuitively, particles with weight greater than $W/N$ should have been sampled at least once, particles with weight $2W/N$ at least twice, and so on. However, this is not ensured by the na\"{i}ve algorithm.\\
An alternative algorithm is to find all particles with weights greater than $W/N$, draw one sample from them, decrease the length of their ``segments'' in the list by $W/N$, and draw the remaining samples from this new (shortened) list. 
%\figref{bettersampling} illustrates this approach.\\
An even better algorithm, called ``low variance sampling'' (similar in principle to ``stochastic universal sampling''\footnote{\url{http://en.wikipedia.org/w/index.php?title=Stochastic_universal_sampling&oldid=356360569}}) draws $N$ samples using a single randomly generated number. Let the random number generated be $r$,such that $r\in(0,W)$. It is assumed that $r$ is drown from a uniform distribution. Then, the first sample is drawn from location $r$ in the list, the second from location $\left[\left(r+\frac{W}{N}\right)\bmod W\right]$, the i'th sample from location $\left[\left(r+\frac{i\cdot W}{N}\right)\bmod W\right]$ and so on, until $N$ new samples have been generated, as illustrated by \figref{lowvariancesampling}. 

\begin{figure}[htb]
\centering \def\svgwidth{12cm} \input{figures/sample_list.pdf_tex}
\caption{Resampling list}
\label{fig:sample_list}
\end{figure}

\begin{figure}[htb]
\centering \def\svgwidth{12cm} \input{figures/naivesampling.pdf_tex}
\caption{Na\"{\i}ve resampling: $N$ samples are drawn from random locations, as indicated by arrows}
\label{fig:naivesampling}
\end{figure}

\begin{figure}[htb]
\centering \def\svgwidth{12cm} \input{figures/lowvariancesampling.pdf_tex}
\caption{Low variance resampling: First sample drawn from random location $r$, rest picked at successive intevals of $\left[\frac{W}{N}\right]$}
\label{fig:lowvariancesampling}
\end{figure}

\subsection{Make observation model less certain}
\secref{goodobs} illustrated the ill-effects of a very good observation model. Two hacks to alleviate this problem are:
\begin{itemize}
\item Convolve the observation model with a Gaussian, thus smearing it out
\item Raise the likelihood values returned by the observation model to a power $c$ where $c\in(0,1)$. A commonly chosen value of $c$ is $1/M$, where $M$ is the dimensionality of the observation, thus taking the geometric mean of the observation values.
\end{itemize}

\subsection{Use a better sampling distribution $q$}
The closer the distribution $q$ to $p$, the more accurate the update of the belief is likely to be. One hack is to use a coarse grid estimate of $p$ to sample from.

\subsection{Rao-Blackwellization}
Rao-Blackwellized particle filters (to be discussed later in the course) include most of the good properties and the ``fixes'' mentioned here, including sampling less, and being more exact.

\end{document}


















