COM­P4804: Al­go­rithms II
$\new­com­mand{\R}{\mathbb{R}}\De­clar­e­Math­Op­er­a­tor{\E}{\mathbf{E}}\De­clar­e­Math­Op­er­a­tor{\deg}{deg}$
Re­view of Basic Prob­a­bil­ity

Here are my orig­i­nal hand-writ­ten notes on this topic.

Prob­a­bil­ity func­tion

In gen­eral $\Pr\{A\cup B\} = \Pr\{A\} + \Pr\{B\} - \Pr\{A\cap B\}$ be­cause the first two terms count $\Pr\{A\cap B\}$ twice

Venn Diagram

this is called the in­clu­sion-ex­clu­sion for­mula. We im­me­di­ately get Boole's In­equal­ity: \[ \Pr\{A \cup B\} \le \Pr\{A\} + \Pr\{B\} \en­space. \] Boole's In­equal­ity is also called the union bound.

Some ter­mi­nol­ogy

Ex­am­ples

Cal­cu­lat­ing some prob­a­bil­i­ties

Ex­pec­ta­tion and Ran­dom Vari­ables

Lin­ear­ity of Ex­pec­ta­tion

If you're in­ter­ested in a proof of lin­ear­ity of ex­pec­ta­tion, here it is: \begin{align*} \E[X+Y] & = \sum_{x}\sum_y (x+y)\Pr\{\text{$X=x$ and $Y=y$}\} \\ & = \sum_{x}\sum_y x\Pr\{\text{$X=x$ and $Y=y$}\} + \sum_{x}\sum_y y\Pr\{\text{$X=x$ and $Y=y$}\} \\ & = \sum_{x}\sum_y x\Pr\{\text{$X=x$ and $Y=y$}\} + \sum_y\sum_{x} y\Pr\{\text{$X=x$ and $Y=y$}\} \\ & = \sum_{x}x\sum_y \Pr\{\text{$X=x$ and $Y=y$}\} + \sum_y y\sum_{x} \Pr\{\text{$X=x$ and $Y=y$}\} \\ & = \sum_{x} x\Pr\{\text{$X=x$}\} + \sum_y y\Pr\{\text{$Y=y$}\} \notag \\ & = \E[X] + \E[Y] \notag \end{align*} Not very en­light­en­ing. The key step is where the num­ber of sum­ma­tion sym­bols goes from 4 down to 2. This is pos­si­ble, be­cause when we sum, over all $y$, $\Pr\{\text{$X=x$ and $Y=y$}\}$ we get $\Pr\{X=x\}$. The Venn di­a­gram below shows an ex­am­ple of this. Here the event $X=x$ is shown as a pink cir­cle. The dif­fer­ent pos­si­ble val­ues of $Y$ are shown as blobs and they have to cover the pink cir­cle be­cause they cover all of $U$.

the key step in proving linear of expectation

More In­di­ca­tor Vari­able Ex­am­ples

In­di­ca­tor vari­ables, along with lin­ear­ity of ex­pec­ta­tion are an ex­tremely ef­fi­cient way of com­put­ing ex­pected val­ues.

Balls in Urns

Throw $n$ balls into $m$ urns in such a way that each ball is equally likely to land in any urn. (Ex­er­cise: Check, using the de­f­i­n­i­tion of a prob­a­bil­ity func­tion, that this im­plies $\Pr\{\text{ball $i$ lands in urn 1}\}=1/m$). What is the ex­pected num­ber of balls in the first urn?

De­fine \[ I_i = \begin{cases} 1 & \text{if ball $i$ lands in urn 1} \\ 0 & \text{oth­er­wise} \end{cases} \] Then \[ \E[I_i] = \Pr\{\text{ball $i$ lands in urn 1}\}\times 1 = 1/m \] So \[ \E[I_1+\cdots I_n] = \E[I_1] + \cdots \E[I_n] = n/m \] Done.

Records

Take a ran­dom per­mu­ta­tion $x_1,\ldots,x_n$ of $1,\ldots, n$. Call $x_i$ a record if $x_i=\max\{x_1,\ldots,x_i\}$. What is the ex­pected num­ber of records?

De­fine \[ I_i = \begin{cases} 1 & \text{if $x_i=\max\{x_1,\ldots,x_i\}$} \\ 0 & \text{oth­er­wise} \end{cases} \] The largest value among $x_1,\ldots,x_i$ is equally likely to be any of $x_1,\ldots,x_i$, so $\Pr\{x_i=\max\{x_1,\ldots,x_i\}\} = 1/i$. So, \[ \E[I_i] = 1/i \] So, the ex­pected num­ber of records is \[ \E[I_1+\cdots+I_n] = \E[I_1] + \cdots \E[I_n] = 1 + 1/2 + 1/3+\cdots 1/n \] The sum $1+1/2+\cdots 1/n$ is called the $n$th har­monic num­ber, $H_n$. Using the fact that $\int_1^n 1/x\,dx = \ln n$, We can eas­ily show that $\ln n \le H_n \le \ln n+1$:

Harmonic upper bound Harmonic lower bound