Lecture 013

Ada's Lecture

Probability Theory

Basic Definitions and Properties

Probability Space: Think probability space as a gray-scale picture such that when summed, equal to 1. And probability function extract the intensity of one pixel. An event is just a group of pixels.

Uniform Distribution: (\forall l \in \Omega)(\text{Pr}[l] = \frac{1}{|\Omega|})

Event: E \subseteq \Omega

// Exercise (Practice with events) // Exercise (Basic facts about probability)

Building Probability Tree from Code

Building Probability Tree from Code

Probability Tree Example

Probability Tree Example

Conditional Probability: setting all outcome that cannot happen given the event and normalize all non-zero probability to sum to 1

// Exercise (Conditional probability practice)

Probability of More Events:

// Exercise (Practice with chain rule)

Independent: we cannot conclude and identify any true independence in the world, this leads to circular definition (can be fixed by looking at agreement in code)

\begin{align*} \text{Pr}[A | B] &= \text{Pr}[A] \tag{Undefined when $\text{Pr}[B] = 0$}\\ \text{Pr}[B | A] &= \text{Pr}[B] \tag{Undefined when $\text{Pr}[A] = 0$}\\ \text{Pr}[A \cap B] &= \text{Pr}[A] \cdot \text{Pr}[B] \tag{Definition}\\ \text{Pr}[\bigcup_{i \in [n]}A_i] &= \prod_{i \in S}\text{Pr}[A_i] \tag{for $A_1, ..., A_n$ all independent}\\ \end{align*}

Random Variables Basics

Random Variable: a function X : \Omega \rightarrow \mathbb{R} transform sample space to real number. (think of it as a enum with real value)

Probability mass function (PMF) of X : \Omega \rightarrow \mathbb{R}: a function p_X : \mathbb{R} \rightarrow [0, 1] such that (\forall x \in \mathbb{R})(p_X(x) = \text{Pr}[X = x])

// Exercise (Practice with random variables)

Expected Value: E[X] = \sum_{l \in \Omega} \text{Pr}[l] \cdot X(l) = \sum_{x \in \text{range}(X)} x \cdot \text{Pr}[X = x] where \text{range}(X) = \{X(l) | l \in \Omega\}

// Exercise (Equivalence of expected value definitions) // Exercise (Practice with expected value) // Exercise (Practice with linearity of expectation)

Indicator Random Variable: maps event to random variable I_A(l) = \begin{cases} 1 & \text{if} l \in A\\ 0 & \text{otherwise}\\ \end{cases} (where A \subseteq \Omega is an event)

Practical Calculation:

\begin{align*} &\mathbb{E}[X]\\ = & \mathbb{E}[\sum_j I_{E_j}] \tag{let $X = \sum_j I_{E_j}$ where $I_{E_j}$ are indicator random variables}\\ = & \sum_j \mathbb{E}[I_{E_j}]\\ = & \sum_j \text{Pr}[E_j] \tag{by $\mathbb{E}[I_{E_j}] = \text{Pr}[E_j]$}\\ \end{align*}

// Exercise (Practice with linearity of expectation and indicators)

Markov's Inequality: Let X be non-negative random variable. Then (\forall \epsilon \geq 1)(\text{Pr}[X \geq \epsilon \cdot E[X]] \leq \frac{1}{\epsilon})

// Exercise (Practice with Markov’s inequality)

Three Popular Random Variables

Bernoulli: x has p probability to equal 1 X ~ \text{Bernoulli}(p) such that \begin{align*} \text{Pr}[X = 1] &= p\\ \text{Pr}[X = 0] &= 1 - p\\ \end{align*}

Binomial: repeat p probability n times X ~ \text{Binomial}(n, p) such that X = X_1 + X_2 + ... + X_n where (\forall i \in [n])(X_i ~ \text{Bernoulli}(p))

// Exercise (Expectation of a Binomial random variable) // Exercise (Practice with Binomial random variable)

Geometric: how many times to get SSR X ~ \text{Geometric}(p)

X = 1
while (Bernoulli(p) = 0) {
  X += 1
}

// Exercise (PMF of a geometric random variable) // Exercise (Practice with geometric random variable) // Exercise (Expectation of a geometric random variable)

Some general tips:

// TODO: Check Your Understanding

Randomized Computation

Random in Computation

Random Variables

Randomized Algorithms:

Deterministic Algorithm

Deterministic Algorithm
Deterministic Algorithm A computes f : \Sigma^* \rightarrow \Sigma^* in T(n)

Classifying Nondeterministic Algorithms

Nondeterministic algorithm should gamble correctness and run-time

Nondeterministic algorithm should gamble correctness and run-time

Example of Nondeterministic Algorithm

Example of Nondeterministic Algorithm

Monte Carlo Algorithm

Monte Carlo Algorithm
Monte Carlo Algorithm A computes f : \Sigma^* \rightarrow \Sigma^* in T(n)

Las Vegas Algorithm

Las Vegas Algorithm
Las Vegas Algorithm A computes f : \Sigma^* \rightarrow \Sigma^* in T(n)

// Exercise (Las Vegas to Monte Carlo) // Exercise (Monte Carlo to Las Vegas)

Randomized Approximation

Randomized Approximation for MAX-CUT

Expected value of Random Variables

Expected value of Random Variables

0.88 approximation for CUT

0.88 approximation for CUT

Expected Cut

Expected Cut

Randomized Approximation for MIN-CUT

Contraction algorithm: iteratively merge two connected vertex together, and keep all the edges

BPP: polynomial solvable using randomized algorithms

BPP: polynomial solvable using randomized algorithms

// Exercise (Boosting for one-sided error) // Exercise (Boosting for two-sided error)

// Exercise (Maximum number of minimum cuts) // Exercise (Contracting two random vertices)

Sutner's Lecture

Random Algorithm

Randomness is computational resource, however, it is extremely hard to get true randomness.

Defining Random:

Approximation: x_n = a_1x_{n-1} + a_2x_{n-2} + ... + a_kx_{n-k} \mod m

Probability:

Boole's Inequality (Union Bound): Pr[\cup A_i] \leq Pr[A_1] + Pr[A_2] + ... + Pr[A_n] Bonferroni's Inequality: Pr[\cap A_i] \geq Pr[A_1] + Pr[A_2] + ... + Pr[A_n] - (n - 1)

Inclusion-Exclusion: \sum_{I \subseteq [n]} (-1)^{|I|} Pr[\cap_{i \in I} A_i] = 0

Variance: Var[X] = E[(X - \mu)^2] = E[X^2] - E[X]^2

Uniform Distribution:

SELECTION: given a unsorted list, find k-th element in the corresponding sorted list.

PZT(Polynomial Zero Testing): whether a polynomial with integer coefficient is always 0 (essentially checking whether coefficients are all 0 when the polynomial simplifies)

Schwartz-Zippel Lemma: let P \in \mathbb{F}[x_1, ..., x_n] (solution space) be of degree d (dimension) and S \subset \mathbb{F} a set of cardinality s. If P is not identically zero, then P has at most ds^{n-1} roots in S. (Pr[P(x) = 0] \leq d/s where x is random point in polynomial)

Primarily Testing

Table of Content