\documentclass[landscape]{slides}
\usepackage{multicol}
\usepackage[all,poly,ps,dvips,color]{xy}
\input{preamble}
  
\input{SLIDES}
 
%\usepackage[dvips]{graphics}
%\usepackage[all,poly,ps,dvips,color]{xy}
%\UseCrayolaColors

%\DeclareMathOperator{\mathin}{in}
%\DeclareMathOperator{\mathout}{out}

\newcommand{\mcost}[1]{\mathit{MinInCost}(#1)}

\newcommand{\vindex}[2]{\left[ #1 \right] _ #2}
\newcommand{\eigen}{\mathbf a}
\newcommand{\elem}{\mathbf e}
\newcommand{\state}{\mathbf x}
\newcommand{\maxdeg}{\Delta}
\newcommand{\maxdegC}{d_{max}}

\newcommand{\din}{d_{\mathin}}
\newcommand{\dout}{d_{\mathout}}
\newcommand{\dmax}{d_{\max}}


\newcommand{\nlabel}[2]{\ar@{} @(#1,#1) |<<{#2}}
\newcommand{\gnlabel}[2]{[#1(.25)] {#2}}
\newcommand{\node}{{\bullet}}
\newcommand{\bypass}{{\circ}}

\begin{document}

\begin{titlepage}
\title{CS 591, Lecture 20}

\author {Jared Saia \\
{\red University of New Mexico}}

\date{}
\maketitle

\end{titlepage}


\begin{SLIDE}[Class Outline]

\begin{itemize}
\item Presentations - Good Job!!
\item Smoothed Analysis Intro
\item Smoothed Analysis of Shortest Path Problem
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Smoothed Analysis Intro]
Motivation:
\begin{itemize}
\item Worst Case Analysis is too hard - typical instances of real-world
problems are not at all similar to the worst case
\item Average Case Analysis is too easy - a ``random'' instance of a
problem is usually not a typical instance
\item Smoothed Analysis is just right - combines the difficulty of
worst case analysis with the easiness of average case analysis
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Smoothed Analysis]
\begin{itemize}
\item The smoothed complexity of an algorithm is
\[
max_{x} E_{y \in N_{\epsilon} (x)} C (y)
\]

\item $x$ ranges over all inputs, $y$ is a random instance in a
neighborhood of $x$ (whose size depends on the smoothing parameter
$\epsilon$), $C (y)$ is the cost of running the algorithm on $y$ and
$E$ denotes expectation

\item As $\epsilon$ gets small, the smoothed complexity approaches
worst case complexity; as $\epsilon$ gets large, smoothed complexity
approaches best case complexity

\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Most Famous Result (so far)]
\begin{itemize}
\item The smoothed complexity of the simplex algorithm for linear
programming is polynomial (even though the worst case run time of the simplex algorithm is exponential!)
\item Linear programming is a continuous problem where the input is
continuous numbers
\item Smoothing operation adds Gaussian noise with parameter
$\epsilon$ to each number in the input
\item Running time is polynomial with the degree of the polynomial
depending on $1/\epsilon$
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Problems]
\begin{itemize}
\item Most known results on smoothed analysis are on continuous problems
\item Hard to know how to add ``noise'' to discrete problem 
\item We will discuss two ideas
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Partial Bit Randomization]
\begin{itemize}
\item Imagine we have a problem which involves the use of integers
\item We parameterize the smoothness by an integer $k$
\item For each integer, the last $k$ bits are randomly modified
\item We will use this analysis for the single source shortest paths problem
\end{itemize}
\end{SLIDE}


\begin{SLIDE}[Single Source Shortest Paths]
\begin{itemize}
\item Given a graph with $n$ vertices and $m$ edges
\item Edge weights are in $[0,2^{K}-1]$ ($K$ bit integers)
\item Assume that addition, etc of integers can be done in
constant time
\item Average complexity is known to be $O (n+m)$ (assumes integers
are all random)
\item Worst case is known to be $O (m+nK)$
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Theorem: Smoothed Analysis]
{\bf Theorem}
\begin{itemize}
\item Let $G$ be an arbitrary graph, $c: E \longrightarrow [0,\dots
,2^{K}-1]$ be an arbitrary cost function and let $k$ be such that
$0\leq k\leq K$
\item Let $\bar{c}$ be obtained from $c$ by making the last $k$ bits
of each edge cost random
\item Then the single source shortest path problem can be solved in
expected time $O (m+n (K-k))$
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Proof]
\begin{itemize}
\item For a node $v$, let $\mcost{v}$ be the minimum cost of any
incoming edge
\item Goldberg has shown that the running time for his algorithm is:
\[
O (n+m+\sum_{v} (K-\log \mcost{v}+1)
\]
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Proof]
\begin{itemize}
\item Note that $\mcost{v}$ is the minimum of $d_{in} (v)$ number of
which the last $k$ bits are random
\item For an edge $e$, let $r (e)$ be the number of leading zeros in
the random part of $e$.
\item Note that $E (r (e)) = 2$.  Why?
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Proof]
Thus we have:
\begin{eqnarray}
K - \log \mcost{v} & \leq & K - k + \max_{e \in inedges (v)} r (e)\\
& \leq & K - k + \sum_{e \in inedges (v)} r (e)
\end{eqnarray}
Thus:
\[
E (K - \log \mcost{v}) \leq K - k + O (d_{in} (v))
\]

and if we sum over all $n$ vertices, the time bound follows.
\end{SLIDE}

\begin{SLIDE}[Partial Permutations]
\begin{itemize}
\item Smoothed Analysis model we'll use for Quicksort is Partial Permutations
\item Parameterized by real number $p : 0\leq p \leq 1$
\item Select each element independently with probability $p$ and let
$m$ be the number of selected elements
\item Take one of the $m!$ permutations of $m$ elements (uniformly at
random) and let it act on the selected elements.
\end{itemize}
\end{SLIDE}


\begin{SLIDE}[QuickSort]
\begin{itemize}
\item Theorem: Expected number of comparisons of quicksort is $4/p
(1+o (1))n \log_{4/3} n$
\item To show this will involve several steps
\item 1) We will calculate $p_{i}$, the probability that the first
position is selected and replaced by the $i$-th element in the
smoothing step.
\item 2) For a fixed element, we will say a call of quicksort is
``good'' if the subproblem containing the elem has less than $3/4$ its
original size 
\item 3) We'll show that the probability a call is good is relatively
large (using the $p_{i}$'s calculated in step 1), so that the total
number of expected calls is small
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Some Notes]
Review of quicksort:
\begin{itemize}
\item Choose a pivot element in the list, call it $\rho $
\item Split the list into $l1$ and $l2$ where $l1$ is all elements
less than or equal to $\rho $ and $l2$ is all elems greater than $\rho $
\item Recursively sort $l1$ and $l2$
\item Return the sorted list $l1,\rho ,l2$
\end{itemize}

Note: Our version of quicksort just chooses the first element in the
list as the pivot element
\end{SLIDE}

\begin{SLIDE}[$p_{i}$]
\begin{itemize}
\item Assume we have a list of $x$ elements.
\item Let $p_{i}$ be the probability that in the ``smoothing'', the
first element is selected and filled with the $i$-th element
\item Note that $p_{1}$ is greater than $p_{i}$ for all $i>2$
\item But all the remaining $p_{i}$ ($i>1$), are equal by symmetry
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[$p_{1}$]
\begin{eqnarray}
p_{1} & = & p \sum_{0\leq j \leq x-1} {x-1 \choose j} p^{j}
(1-p)^{x-1-j} \frac{1}{j+1}\\
& = & \frac{1}{x} \sum_{0\leq j\leq x-1}{x \choose j+1}p^{j+1} (1-p)^{x-1-j}\\
& = & \frac{1}{x} \sum_{1 \leq j\leq x}{x \choose j}p^{j}(1-p)^{x-j}\\
& = & \frac{1}{x} (1- (1-p)^{x})
\end{eqnarray}
\end{SLIDE}

\begin{SLIDE}[$p_{i}$]
\begin{itemize}
\item By symmetry, $p_{2}=p_{3}=\dots =p_{x}$
\item Hence we have 
\begin{eqnarray}
p_{i} & = & (p-p_{1})/ (x-1)\\
& \geq & \frac{p-1/x}{x-1}
\end{eqnarray}
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Good Calls]
We can now bound the runtime
\begin{itemize}
\item Consider a fixed element and say a call is ``good'' if the
subproblem containing the element has less than $3/4$ its original size
\item How many calls are needed until the elem is in some subproblem
of constant size $d$?
\item Number of good calls is bounded by $\log_{4/3} n$.
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Good Calls]
\begin{itemize}
\item Q: What is the probability that a call is good?
\item A: A call is good if the pivot (the first element) is among the
elements with rank $x/4$ to $3x/4$ in the input list
\item There are $x/2$ such elems which would make good pivots
\item Each of these elems is the pivot with probability at least $p_{2}$
\item Hence the call is good with probability at least $(x/2)p_{2}$
(events that $i$-th elem chosen as pivot are mutually exclusive so can
sum probabilities)
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Good Calls]
\begin{eqnarray}
\frac{x}{2}p_{2} & \geq & \frac{x}{2}\cdot\frac{p- 1/x}{x-1}\\
& \geq & \frac{p-p/d}{2}\\
\end{eqnarray}

\begin{itemize}
\item The last equation follows provided that we choose $d$ and bound
$x$ such that $p/d \geq 1/x$ is always true
\item Let $\pi = \frac{p-p/d}{2}$ be a lower bound on the probability a call
is good
\item We need $\log_{4/3} n$ good calls
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[The End Game]
\begin{itemize}
\item Expected number of calls to get $\log_{4/3}n$ good calls is
$\pi^{-1} \log_{4/3}n$
\item Hence running time is no more than $n \pi^{-1} \log_{4/3}n+dn$
where $dn$ is the total cost of the small calls
\item Choosing the optimum value of $d$ gives a running time of $4/p
(1+o (1))n \log_{4/3} n$
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Conclusion]
\begin{itemize}
\item Smoothed Analysis is a brand new and possibly very useful way to
analyze algorithms
\item There are still many, many problems it hasen't been tried on yet
\item Frequently, The challenge for discrete problems is figuring out
how to add in the ``noise''
\item Keep it in mind the next time you are trying to analyze a ``real
world'' problem
\end{itemize}

Good luck on Exams and Have a Great Winter Break!!!  Enjoy the
good ski conditions!!!
\end{SLIDE}


\end{document}
