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

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

\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-06, Lecture 8}

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

\date{}
\maketitle

\end{titlepage}

\begin{SLIDE}[Class Outline]
\emph{A reasonable probability is the only certainty.} - E.W. Howe

\begin{itemize}
\item Intro to probability theory
\item Some basic Probability definitions and facts 
\item Linearity of Expectation
\item Union Bounds
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Intro to Probability Theory]

Defns:
\begin{itemize}
\item An \emph{Event Space} is a set of ``events'' which is closed
under complement and union.  

\item A \emph{Probability Function} $P$ is a mapping from an event
space, $\Gamma$, to the real numbers such that:

\begin{itemize}
\item For all $\gamma \in \Gamma $, $0 \leq P (\gamma ) \leq 1$ 
\item $P (\Omega ) = 1$, where $\Omega$ is the set containing all
atomic events and their complements.
\item For mutually disjoint events, $\gamma_{1}, \gamma_{2},\dots,
\gamma _{l}$, $$P (\bigcup _{i=1}^{l} \gamma _{i}) = \sum _{i=1}^{l} P (\gamma _{i})$$
\end{itemize}
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Example]

Consider event space when we flip a coin.  Let $\gamma
_{1}$ be the event that the coin turns up heads.

Then $\Gamma = \{ \{ \}, \gamma _{1}, \bar{\gamma _{1}}, \{\gamma _{1}
\bigcup \bar{\gamma _{1}}\}\}$

and:
\begin{itemize}
\item Every element in $\Gamma $ has probability of occurence between
$1$ and $0$.
\item $P (\Omega ) = P (\{\gamma _{1} \bigcup \bar{\gamma _{1}}\}) =
1$

\item Probabilities of events that are disjoint (can't occur together)
add.\\
E.g. $P (\gamma _{1} \bigcup \bar{\gamma _{1}}) = P (\gamma _{1}) + P
(\bar{\gamma _{1}})$

\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Basic Facts]

\begin{itemize}

\item {\bf Complement Fact:} For any event $\gamma$, $P (\bar{\gamma}) = 1 - P (\gamma )$ \\

\item {\bf Independence Fact} A set of events $\{\gamma _{i} | i \in I
\}$, is said to be \emph{independent} if for any subset $S$ of $I$,

$P (\bigcap_{i \in S} \gamma _{i}) = \prod_{i \in S} P (\gamma _{i})$

\end{itemize}


\end{SLIDE}


\begin{SLIDE}[In Class Exercise]

Imagine we flip two independent coins.  Let $\gamma _{1}$ be the event
that the first coin is heads, $\gamma _{2}$ be the event that the
second coin is heads.

Let $P (\gamma _{1}) = 1/2$ and $P (\gamma _{2}) = 1/2$.

\begin{itemize}

\item Question 1: What is the probability that both coins turn up
heads? (Hint:  Use the fact that $\gamma _{1}$ and $\gamma _{2}$ are
independent).

\item Question 2: What is the probability that at least one coin turns
up heads?  (Hint: Use the complement fact and independence of the
events $\bar{\gamma _{1}}$ and $\bar{\gamma _{2}}$).

\end{itemize}

\end{SLIDE}


\begin{SLIDE}[Useful Algebraic Tricks]

Some useful algebraic facts to know:

\begin{itemize}
\item $(1-x) \leq e^{-x}$
\item $e^{x}*e^{y} = e^{x+y}$
\end{itemize}

\end{SLIDE}


\begin{SLIDE}[Sailors and Cabins]

There are $n$ sailors and $n$ cabins and sailor $i$ is assigned to
cabin $i$.

After a night of drunken revelry, the sailors return to ship and each
of them chooses uniformly at random one of $n$ cabins to sleep in.

\begin{itemize}
\item Question: What is (an upper bound on) the probability that
\emph{no} sailor sleeps in his own cabin?
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Sailors and Cabins]

\begin{itemize}
\item Let $\gamma _{i}$ be the event that sailor $i$ sleeps in
his own cabin.

\item Note that for all $i$, $P (\gamma _{i}) = 1/n$

\item Note that all of the events $\gamma _{i}$ are independent.

\item We want $P(\bigcap _{i=1}^{n} \bar{\gamma _{i}})$

\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Sailors and Cabins]
 
\begin{eqnarray}
P(\bigcap _{i=1}^{n} \bar{\gamma _{i}}) & = & \prod _{i=1}^{n} P (\bar{\gamma _{i}}) \\
& = & \prod _{i=1}^{n} (1 - P (\gamma _{i})) \\
& = & \prod _{i=1}^{n} (1 - 1/n)\\
& \leq & \prod _{i=1}^{n} e^{-1/n}\\
& \leq & e^{-1}
\end{eqnarray}

The first step holds by Independence, and the second step holds by
Complement.
\end{SLIDE}

\begin{SLIDE}[Random Variables]

\begin{itemize}
\item A \emph{Random Variable} is a variable which randomly takes on
some value in the real numbers.
\end{itemize}

Example Random Variables:
\begin{itemize}
\item  Let $X$ be $1$ with probability $1/2$ and $0$ with probability $1/2$
\item Let $Y$ take on a value in the range $\{1,\dots,n \}$ uniformly
at random.
\item Let $Z = X + Y$.
\item Let $W = X*Y$.
\end{itemize}
\end{SLIDE}

\begin{SLIDE}[Expectation]

The \emph{Expectation} of a random variable $X$ (written $E (X)$),
which takes on values in some range $R$, is defined as follows:

\begin{itemize}
\item  $E (X) = \sum _{r \in R} (r*P (X=r))$
\end{itemize}

\end{SLIDE}


\begin{SLIDE}[Linearity of Expectation]

{\bf Linearity of Expecation Fact}: If there are random variable
$X,X_{1},\dots , X_{n}$, such that $X = \sum_{i=1}^{n} X_{i} $, then 

\begin{itemize}
\item $E (X) = \sum _{i=1}^{n} E (X_{i})$ 
\end{itemize}

Example:

Let the variable $X_{i}$ be $1$ if the $i$-th flip of a coin is heads
and $0$ otherwise and say that $E (X_{i}) = 1/2$.  Let $X =
\sum_{i=1}^{n} X_{i}$.  Then:

$E (X) = n/2$

\end{SLIDE}


\begin{SLIDE}[More Drunken Sailors]

There are $n$ sailors and $n$ cabins and sailor $i$ is assigned to
cabin $i$.

After a night of drunken revelry, the sailors return to ship and each
of them chooses uniformly at random one of $n$ cabins to sleep in.

\begin{itemize}
\item What is the expected number of sailors that actually sleep in
their own cabin?
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Sailors and Cabins]

\begin{itemize}

\item Let $r_{i}$ be an random variable which has value one of sailor $i$
sleeps in his own cabin and $0$ otherwise.  

\item $E (r_{i}) = (1/n)$

\item Let $R = \sum _{i=1}^{n} r_{i}$

\item Then we know by Linearity of Expectation:
\begin{eqnarray}
E (R) & = & E (\sum _{i=1}^{n} r_{i})\\
& = & \sum _{i=1}^{n} E (r_{i}) \\
& = & \sum _{i=1}^{n} 1/n \\
& = & 1
\end{eqnarray}

\end{itemize}

\end{SLIDE}


\begin{SLIDE}[Union Bound]

{\bf Union Bound Fact}: Let $\Gamma $ be any event space, $P$ be any
probability function and $\gamma _{1}, \gamma _{2}, \dots \gamma _{n}$
be any events in $\Gamma $.  Then:

\[
P (\bigcup _{i=1}^{n} \gamma _{i}) \leq \sum _{i=1}^{n} P (\gamma _{i})
\]

Example:\\

Let $\gamma_{1}$ be the event that coin 1 is heads, $\gamma _{2}$ be the
event that coin 2 is heads.  Then:

\[
P (\gamma _{1} \bigcup \gamma _{2}) \leq P (\gamma _{1}) + P (\gamma _{2})
\]

\end{SLIDE}


\begin{SLIDE}[Drunk Sailors, the next day]

There are $n$ sailors and $n$ mugs (of coffee).  The $i$-th mug
belongs to sailor $i$.

The next morning, each sailor wakes up and randomly takes
\emph{exactly} one mug.

\begin{itemize}
\item {\bf Question: What is an upper bound on the probability that
one of the first three sailors gets the first mug?}
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Drunk Sailors, the next day]

\begin{itemize}
\item For $i=\{1,2,3 \}$, let $\gamma _{i}$ be the event that the
$i$-th sailor gets the first mug.
\item We want $P (\gamma _{1} \bigcup \gamma _{2} \bigcup \gamma _{3})$
\item By the Union Bound,  $P (\gamma _{1} \bigcup \gamma _{2} \bigcup
\gamma _{3}) \leq P (\gamma _{1}) + P (\gamma _{2}) + P (\gamma _{3})$ 
\item So  $P (\gamma _{1} \bigcup \gamma _{2} \bigcup
\gamma _{3}) \leq 3/n$
\end{itemize}

\end{SLIDE}

\begin{SLIDE}[Another Union Bound Example]

Imagine an Attack-Resistant Peer-to-peer network over $n$ peers.

\begin{itemize}
\item Assume that for any fixed set of $n/2$ peers, the probability
that deletion of that set foils the network is $p_{f}$.

\item There are $n$ choose $n/2$ sets of size $n/2$

\item Hence the probability that no set exists such that its deletion
will foil the network is no more than $p_{f}$ * ($n$ choose $n/2$).

\end{itemize}

\end{SLIDE}


\end{document}


% \begin{SLIDE}[Example]

% Consider event that can occur when we flip two coins.  Let $\gamma
% _{1}$ be the event that first coin turns up heads, $\gamma
% _{2}$ be the event that second coin turns up heads.

% Then $\Gamma = \{\{ \}, \gamma _{1},\gamma _{2}, \bar{\gamma _{1}},
% \bar{\gamma _{2}}, \{\gamma _{1}, \bar{\gamma _{1}} \}, \{\gamma _{2},
% \bar{\gamma _{2}}\}, \{\gamma _{1}, \gamma _{2} \}, \{\gamma _{1},
% \bar{\gamma _{2}} \}, \{\bar{\gamma _{1}},\gamma _{2} \}, \\ \{
% \bar{\gamma _{1}}, \bar{\gamma _{2}} \}, \{\gamma _{1},\gamma
% _{2},\bar{\gamma _{1}}, \}, \{\gamma _{1}, \gamma _{2}, \bar{\gamma
% _{2}} \}, \{\bar{\gamma _{1}}, \bar{\gamma _{2}}, \gamma _{1} \},
% \{\bar{\gamma _{1}}, \bar{\gamma _{2}}, \gamma _{2} \}, \{\bar{\gamma
% _{1}}, \bar{\gamma _{2}}, \gamma _{1}, \gamma _{2} \} \}$

% and:
% \begin{itemize}
% \item Every element in $\Gamma $ has probability of occurence between
% $1$ and $0$.
% \item $P (\Omega ) = P (\{\bar{\gamma _{1}}, \bar{\gamma _{2}}, \gamma
% _{1}, \gamma _{2} \}) = 1$

% \item Probabilities of events that are disjoint (can't occur together)
% add.\\
% E.g. $P (\{ \gamma _{1}, \gamma _{2}\} \bigcup \{ \bar{\gamma _{1}},
% \bar{\gamma _{2}}\}) = P (\{ \gamma _{1}, \gamma _{2}\}) + P (\{
% \bar{\gamma _{1}}, \bar{\gamma _{2}}\}))$

% \end{itemize}

% \end{SLIDE}
