# Probability Space

The axiom foundation of probability theory is laid by Kolmogorov, one of the greatest mathematician of the 20th century, who advanced various very different fields of mathematics.

 Definition (Probability Space) A probability space is a triple $(\Omega,\Sigma,\Pr)$. $\Omega$ is a set, called the sample space. $\Sigma\subseteq 2^{\Omega}$ is the set of all events, satisfying: (K1). $\Omega\in\Sigma$ and $\emptyset\in\Sigma$. (Existence of the certain event and the impossible event) (K2). If $A,B\in\Sigma$, then $A\cap B, A\cup B, A-B\in\Sigma$. (Intersection, union, and difference of two events are events). A probability measure $\Pr:\Sigma\rightarrow\mathbb{R}$ is a function that maps each event to a nonnegative real number, satisfying (K3). $\Pr(\Omega)=1$. (K4). For any disjoint events $A$ and $B$ (which means $A\cap B=\emptyset$), it holds that $\Pr(A\cup B)=\Pr(A)+\Pr(B)$. (K5*). For a decreasing sequence of events $A_1\supset A_2\supset \cdots\supset A_n\supset\cdots$ of events with $\bigcap_n A_n=\emptyset$, it holds that $\lim_{n\rightarrow \infty}\Pr(A_n)=0$.
Remark
• In general, the set $\Omega$ may be continuous, but we only consider discrete probability in this lecture, thus we assume that $\Omega$ is either finite or countably infinite.
• Sometimes it is convenient to assume $\Sigma=2^{\Omega}$, i.e. the events enumerates all subsets of $\Omega$. But in general, a probability space is well-defined by any $\Sigma$ satisfying (K1) and (K2). Such $\Sigma$ is called a $\sigma$-algebra defined on $\Omega$.
• The last axiom (K5*) is redundant if $\Sigma$ is finite, thus it is only essential when there are infinitely many events. The role of axiom (K5*) in probability theory is like Zorn's Lemma (or equivalently the Axiom of Choice) in axiomatic set theory.

Useful laws for probability can be deduced from the axioms (K1)-(K5).

 Proposition Let $\bar{A}=\Omega\setminus A$. It holds that $\Pr(\bar{A})=1-\Pr(A)$. If $A\subseteq B$ then $\Pr(A)\le\Pr(B)$.
Proof.
 The events $\bar{A}$ and $A$ are disjoint and $\bar{A}\cup A=\Omega$. Due to Axiom (K4) and (K3), $\Pr(\bar{A})+\Pr(A)=\Pr(\Omega)=1$. The events $A$ and $B\setminus A$ are disjoint and $A\cup(B\setminus A)=B$ since $A\subseteq B$. Due to Axiom (K4), $\Pr(A)+\Pr(B\setminus A)=\Pr(B)$, thus $\Pr(A)\le\Pr(B)$.
$\square$
Notation

An event $A\subseteq\Omega$ can be represented as $A=\{a\in\Omega\mid \mathcal{E}(a)\}$ with a predicate $\mathcal{E}$.

The predicate notation of probability is

$\Pr[\mathcal{E}]=\Pr(\{a\in\Omega\mid \mathcal{E}(a)\})$.

We use the two notations interchangeably.

## Union bound

A very useful inequality in probability is the Boole's inequality, mostly known by its nickname union bound.

 Theorem (union bound) Let $A_1, A_2, \ldots, A_n$ be $n$ events. Then \begin{align} \Pr\left(\bigcup_{1\le i\le n}A_i\right) &\le \sum_{i=1}^n\Pr(A_i). \end{align}
Proof.
 Let $B_1=A_1$ and for $i\gt 1$, let $B_i=A_i\setminus \left(\bigcup_{j\lt i}A_j\right)$. We have $\bigcup_{1\le i\le n} A_i=\bigcup_{1\le i\le n} B_i$. On the other hand, $B_1,B_2,\ldots,B_n$ are disjoint, which implies by the axiom of probability space that $\Pr\left(\bigcup_{1\le i\le n}A_i\right)=\Pr\left(\bigcup_{1\le i\le n}B_i\right)=\sum_{i=1}^n\Pr(B_i)$. Also note that $B_i\subseteq A_i$ for all $1\le i\le n$, thus $\Pr(B_i)\le \Pr(A_i)$ for all $1\le i\le n$. The theorem follows.
$\square$

The union bound is a special case of the Boole-Bonferroni inequality.

 Theorem (Boole-Bonferroni inequality) Let $A_1, A_2, \ldots, A_n$ be $n$ events. For $1\le k\le n$, define $S_k=\sum_{i_1\lt i_2\lt \cdots\lt i_k}\Pr\left(\bigcap_{j=1}^k A_{i_j}\right)$. Then for odd $m$ in $\{1,2,\ldots, n\}$: $\Pr\left(\bigcup_{1\le i\le n}A_i\right)\le \sum_{k=1}^m (-1)^{k-1} S_k$; and for even $m$ in $\{1,2,\ldots, n\}$: $\Pr\left(\bigcup_{1\le i\le n}A_i\right)\ge \sum_{k=1}^m (-1)^{k-1} S_k$.

The inequality follows from the well-known inclusion-exclusion principle, stated as follows, as well as the fact that the quantity $S_k$ is unimodal in $k$.

 Principle of Inclusion-Exclusion Let $A_1, A_2, \ldots, A_n$ be $n$ events. Then $\Pr\left(\bigcup_{1\le i\le n}A_i\right)=\sum_{k=1}^n (-1)^{k-1} S_k,$ where $S_k=\sum_{i_1\lt i_2\lt \cdots\lt i_k}\Pr\left(\bigcap_{j=1}^k A_{i_j}\right)$.

# Conditional Probability

In probability theory, the word "condition" is a verb. "Conditioning on the event ..." means that it is assumed that the event occurs.

 Definition (conditional probability) The conditional probability that event $A$ occurs given that event $B$ occurs is $\Pr[A\mid B]=\frac{\Pr[A\wedge B]}{\Pr[B]}.$

The conditional probability is well-defined only if $\Pr[B]\neq0$.

## Law of total probability

The following fact is known as the law of total probability. It computes the probability by averaging over all possible cases.

 Theorem (law of total probability) Let $B_1,B_2,\ldots,B_n$ be mutually disjoint events, and $\bigcup_{i=1}^n B_i=\Omega$ is the sample space. Then for any event $A$, $\Pr[A]=\sum_{i=1}^n\Pr[A\wedge B_i]=\sum_{i=1}^n\Pr[A\mid B_i]\cdot\Pr[B_i].$
Proof.
 Since $B_1,B_2,\ldots, B_n$ are mutually disjoint and $\bigvee_{i=1}^n B_i=\Omega$, events $A\wedge B_1, A\wedge B_2,\ldots, A\wedge B_n$ are also mutually disjoint, and $A=\bigcup_{i=1}^n\left(A\cap B_i\right)$. Then the additivity of disjoint events, we have $\Pr[A]=\sum_{i=1}^n\Pr[A\wedge B_i]=\sum_{i=1}^n\Pr[A\mid B_i]\cdot\Pr[B_i].$
$\square$

The law of total probability provides us a standard tool for breaking a probability into sub-cases. Sometimes this will help the analysis.

## "The Chain Rule"

By the definition of conditional probability, $\Pr[A\mid B]=\frac{\Pr[A\wedge B]}{\Pr[B]}$. Thus, $\Pr[A\wedge B] =\Pr[B]\cdot\Pr[A\mid B]$. This hints us that we can compute the probability of the AND of events by conditional probabilities. Formally, we have the following theorem:

 Theorem Let $A_1, A_2, \ldots, A_n$ be any $n$ events. Then \begin{align} \Pr\left[\bigwedge_{i=1}^n A_i\right] &= \prod_{k=1}^n\Pr\left[A_k \mid \bigwedge_{i\lt k} A_i\right]. \end{align}
Proof.
 It holds that $\Pr[A\wedge B] =\Pr[B]\cdot\Pr[A\mid B]$. Thus, let $A=A_n$ and $B=A_1\wedge A_2\wedge\cdots\wedge A_{n-1}$, then \begin{align} \Pr[A_1\wedge A_2\wedge\cdots\wedge A_n] &= \Pr[A_1\wedge A_2\wedge\cdots\wedge A_{n-1}]\cdot\Pr\left[A_n\mid \bigwedge_{i\lt n}A_i\right]. \end{align} Recursively applying this equation to $\Pr[A_1\wedge A_2\wedge\cdots\wedge A_{n-1}]$ until there is only $A_1$ left, the theorem is proved.
$\square$

# Random Variable

 Definition (random variable) A random variable $X$ on a sample space $\Omega$ is a real-valued function $X:\Omega\rightarrow\mathbb{R}$. A random variable X is called a discrete random variable if its range is finite or countably infinite.

For a random variable $X$ and a real value $x\in\mathbb{R}$, we write "$X=x$" for the event $\{a\in\Omega\mid X(a)=x\}$, and denote the probability of the event by

$\Pr[X=x]=\Pr(\{a\in\Omega\mid X(a)=x\})$.

The independence can also be defined for variables:

 Definition (Independent variables) Two random variables $X$ and $Y$ are independent if and only if $\Pr[(X=x)\wedge(Y=y)]=\Pr[X=x]\cdot\Pr[Y=y]$ for all values $x$ and $y$. Random variables $X_1, X_2, \ldots, X_n$ are mutually independent if and only if, for any subset $I\subseteq\{1,2,\ldots,n\}$ and any values $x_i$, where $i\in I$, \begin{align} \Pr\left[\bigwedge_{i\in I}(X_i=x_i)\right] &= \prod_{i\in I}\Pr[X_i=x_i]. \end{align}

Note that in probability theory, the "mutual independence" is not equivalent with "pair-wise independence", which we will learn in the future.

# Linearity of Expectation

Let $X$ be a discrete random variable. The expectation of $X$ is defined as follows.

 Definition (Expectation) The expectation of a discrete random variable $X$, denoted by $\mathbf{E}[X]$, is given by \begin{align} \mathbf{E}[X] &= \sum_{x}x\Pr[X=x], \end{align} where the summation is over all values $x$ in the range of $X$.

Perhaps the most useful property of expectation is its linearity.

 Theorem (Linearity of Expectations) For any discrete random variables $X_1, X_2, \ldots, X_n$, and any real constants $a_1, a_2, \ldots, a_n$, \begin{align} \mathbf{E}\left[\sum_{i=1}^n a_iX_i\right] &= \sum_{i=1}^n a_i\cdot\mathbf{E}[X_i]. \end{align}
Proof.
 By the definition of the expectations, it is easy to verify that (try to prove by yourself): for any discrete random variables $X$ and $Y$, and any real constant $c$, $\mathbf{E}[X+Y]=\mathbf{E}[X]+\mathbf{E}[Y]$; $\mathbf{E}[cX]=c\mathbf{E}[X]$. The theorem follows by induction.
$\square$

The linearity of expectation gives an easy way to compute the expectation of a random variable if the variable can be written as a sum.

Example
Supposed that we have a biased coin that the probability of HEADs is $p$. Flipping the coin for n times, what is the expectation of number of HEADs?
It looks straightforward that it must be np, but how can we prove it? Surely we can apply the definition of expectation to compute the expectation with brute force. A more convenient way is by the linearity of expectations: Let $X_i$ indicate whether the $i$-th flip is HEADs. Then $\mathbf{E}[X_i]=1\cdot p+0\cdot(1-p)=p$, and the total number of HEADs after n flips is $X=\sum_{i=1}^{n}X_i$. Applying the linearity of expectation, the expected number of HEADs is:
$\mathbf{E}[X]=\mathbf{E}\left[\sum_{i=1}^{n}X_i\right]=\sum_{i=1}^{n}\mathbf{E}[X_i]=np$.

The real power of the linearity of expectations is that it does not require the random variables to be independent, thus can be applied to any set of random variables. For example:

$\mathbf{E}\left[\alpha X+\beta X^2+\gamma X^3\right] = \alpha\cdot\mathbf{E}[X]+\beta\cdot\mathbf{E}\left[X^2\right]+\gamma\cdot\mathbf{E}\left[X^3\right].$

However, do not exaggerate this power!

• For an arbitrary function $f$ (not necessarily linear), the equation $\mathbf{E}[f(X)]=f(\mathbf{E}[X])$ does not hold generally.
• For variances, the equation $var(X+Y)=var(X)+var(Y)$ does not hold without further assumption of the independence of $X$ and $Y$.

## Conditional Expectation

Conditional expectation can be accordingly defined:

 Definition (conditional expectation) For random variables $X$ and $Y$, $\mathbf{E}[X\mid Y=y]=\sum_{x}x\Pr[X=x\mid Y=y],$ where the summation is taken over the range of $X$.

There is also a law of total expectation.

 Theorem (law of total expectation) Let $X$ and $Y$ be two random variables. Then $\mathbf{E}[X]=\sum_{y}\mathbf{E}[X\mid Y=y]\cdot\Pr[Y=y].$

# $k$-wise independence

Recall the definition of independence between events:

 Definition (Independent events) Events $\mathcal{E}_1, \mathcal{E}_2, \ldots, \mathcal{E}_n$ are mutually independent if, for any subset $I\subseteq\{1,2,\ldots,n\}$, \begin{align} \Pr\left[\bigwedge_{i\in I}\mathcal{E}_i\right] &= \prod_{i\in I}\Pr[\mathcal{E}_i]. \end{align}

Similarly, we can define independence between random variables:

 Definition (Independent variables) Random variables $X_1, X_2, \ldots, X_n$ are mutually independent if, for any subset $I\subseteq\{1,2,\ldots,n\}$ and any values $x_i$, where $i\in I$, \begin{align} \Pr\left[\bigwedge_{i\in I}(X_i=x_i)\right] &= \prod_{i\in I}\Pr[X_i=x_i]. \end{align}

Mutual independence is an ideal condition of independence. The limited notion of independence is usually defined by the k-wise independence.

 Definition (k-wise Independenc) 1. Events $\mathcal{E}_1, \mathcal{E}_2, \ldots, \mathcal{E}_n$ are k-wise independent if, for any subset $I\subseteq\{1,2,\ldots,n\}$ with $|I|\le k$ \begin{align} \Pr\left[\bigwedge_{i\in I}\mathcal{E}_i\right] &= \prod_{i\in I}\Pr[\mathcal{E}_i]. \end{align} 2. Random variables $X_1, X_2, \ldots, X_n$ are k-wise independent if, for any subset $I\subseteq\{1,2,\ldots,n\}$ with $|I|\le k$ and any values $x_i$, where $i\in I$, \begin{align} \Pr\left[\bigwedge_{i\in I}(X_i=x_i)\right] &= \prod_{i\in I}\Pr[X_i=x_i]. \end{align}

A very common case is pairwise independence, i.e. the 2-wise independence.

 Definition (pairwise Independent random variables) Random variables $X_1, X_2, \ldots, X_n$ are pairwise independent if, for any $X_i,X_j$ where $i\neq j$ and any values $a,b$ \begin{align} \Pr\left[X_i=a\wedge X_j=b\right] &= \Pr[X_i=a]\cdot\Pr[X_j=b]. \end{align}

Note that the definition of k-wise independence is hereditary:

• If $X_1, X_2, \ldots, X_n$ are k-wise independent, then they are also $\ell$-wise independent for any $\ell\lt k$.
• If $X_1, X_2, \ldots, X_n$ are NOT k-wise independent, then they cannot be $\ell$-wise independent for any $\ell\gt k$.

## Pairwise Independent Bits

Suppose we have $m$ mutually independent and uniform random bits $X_1,\ldots, X_m$. We are going to extract $n=2^m-1$ pairwise independent bits from these $m$ mutually independent bits.

Enumerate all the nonempty subsets of $\{1,2,\ldots,m\}$ in some order. Let $S_j$ be the $j$th subset. Let

$Y_j=\bigoplus_{i\in S_j} X_i,$

where $\oplus$ is the exclusive-or, whose truth table is as follows.

 $a$ $b$ $a$$\oplus$$b$ 0 0 0 0 1 1 1 0 1 1 1 0

There are $n=2^m-1$ such $Y_j$, because there are $2^m-1$ nonempty subsets of $\{1,2,\ldots,m\}$. An equivalent definition of $Y_j$ is

$Y_j=\left(\sum_{i\in S_j}X_i\right)\bmod 2$.

Sometimes, $Y_j$ is called the parity of the bits in $S_j$.

We claim that $Y_j$ are pairwise independent and uniform.

 Theorem For any $Y_j$ and any $b\in\{0,1\}$, \begin{align} \Pr\left[Y_j=b\right] &= \frac{1}{2}. \end{align} For any $Y_j,Y_\ell$ that $j\neq\ell$ and any $a,b\in\{0,1\}$, \begin{align} \Pr\left[Y_j=a\wedge Y_\ell=b\right] &= \frac{1}{4}. \end{align}

The proof is left for your exercise.

Therefore, we extract exponentially many pairwise independent uniform random bits from a sequence of mutually independent uniform random bits.

Note that $Y_j$ are not 3-wise independent. For example, consider the subsets $S_1=\{1\},S_2=\{2\},S_3=\{1,2\}$ and the corresponding random bits $Y_1,Y_2,Y_3$. Any two of $Y_1,Y_2,Y_3$ would decide the value of the third one.