\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{xcolor}
\usepackage{natbib}
\DeclareMathOperator*{\E}{\mathbb{E}}
\let\Pr\relax 
\DeclareMathOperator*{\Pr}{\mathbb{P}}

\newcommand{\eps}{\epsilon}
\newcommand{\inprod}[1]{\left\langle #1 \right\rangle}
\newcommand{\R}{\mathbb{R}}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {\bf CS 388R: Randomized Algorithms, Fall 2019 } \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
      \textcolor{red}{\textbf{NOTE:} THESE NOTES HAVE NOT BEEN EDITED OR CHECKED FOR CORRECTNESS}
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{#3}{Scribes: #4}{Lecture #1}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{wasysym}
\usepackage{geometry}
\usepackage{color}
\usepackage{hyperref}
\usepackage{bm}
\usepackage{algorithm}
\usepackage{algorithmic}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=cyan,
}

\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex

\newcommand*{\dif}{\mathop{}\!\mathrm{d}}
% \geometry{a4paper,scale=0.8}
\title{Randomized Algorithms Lecture 3}
\author{Tongzheng Ren}
\date{August 29th, 2019}

\begin{document}

\lecture{4}{Von Neumann's theorem, Yao's principle}{September 10, 2019}{Prof.\ Eric Price}{Ying-hao Chen, Atharva Pendse}
% \maketitle

\section{Explaination of HW 2 Problem 1}
\begin{itemize}
    \item Decision problems (is min-cut $\leq k$?) v.s. Optimization problems (what is min-cut?)
    \item If the answer to optimization problem $\in [B]$ and decision problem takes $T(n)$ time for $\frac{3}{4} $ success probability,
    \[
        \Rightarrow \text{ binary search gives optimization in time } T(n)\log B \text{ with } \frac{3}{4} \text{ success probability. }
    \]
    \item If ans to optimization problem $\in [B]$ and decision problem takes $T(n)$ time for $1-\frac{1}{4\log B} $ success probability,
    \begin{eqnarray*}
    \begin{aligned}
        &\Rightarrow&& \mathbb{P}[\text{optimization problem fails}]&& \leq&& \sum \mathbb{P}[\text{decision problem fails}]&\\
        &&&&& \leq&& \log B\cdot \max\mathbb{P}[\text{decision problem fails}]&\\
    \end{aligned}
    \end{eqnarray*}
    \item By amplification, we can solve optimization problem with $\frac{3}{4} $ prob. in $T\log B\log \log B $ time. That means, at each level we repeat the decision problem $ O(\log\log B) $ times to amplify the probability of getting a correct answer. Proof can be obtained using union bound.
    \item To construct a $T\log B $ time algorithm, one can consider how to recover from getting to the wrong branch in binary search (go back to the parent node when something happens).
\end{itemize}
\section{Fun Probability Exercise}
\paragraph{Q1:} Given a standard die, roll it until we see a 6. How many rolls do we need in expectation?
\begin{enumerate}
    \item Consider it as a geometry distribution with $p =\frac{1}{6} $. 
    \[
        \mathbb{E}[\#\text{rolls}] = \sum\limits_{i=1}^{\infty} \left(\frac{5}{6}\right)^{i-1}\frac{1}{6}\cdot i = 6
    \]
    \item Define a recursive relationship. Let $X = \mathbb{E}[\#\text{rolls}]$.
    \[
        X = \frac{5}{6}\cdot (X+1) + \frac{1}{6}\cdot 1
    \]
    By solving this equation, we can get $X = 6$.
\end{enumerate}
\paragraph{Q2:} As the previous problem, what is $\mathbb{E}[\#\text{rolls until find 6}\ |\ \text{all outcomes are even}]$? In other words, we will start over with the process if we ever roll an odd number.
\begin{enumerate}
    \item Suppose that we throw away all the runs with odd outcomes. The intuition is that as the run becomes longer, it's more likely to be thrown away. Hence, it's biased toward short sequence of rolls. We know that we will stop as soon as we see 1, 3, 5, and 6. Using the same logic as the previous problem, we can use property geometry distribution with $p =\frac{4}{6} $ to show that
    \[
        \mathbb{E}[\#\text{rolls}] = \frac{1}{p} = \frac{6}{4} = 1.5
    \]
    Note that the distribution of $\#\text{rolls}$ ending at 1, 3, 5, 6 are the same (They are symmetric). Let $R$ be the number of rolls until stops. Then
    \[
        \mathbb{E}[\#\text{rolls until we meet 6}\ |\ \text{all outcomes are even}] = \mathbb{E}[R\ |\ \text{find roll in 6}] = \mathbb{E}[R] = 1.5
    \]
    \item Could we have defined a recursive relationship like before? Using that method, we have
    \[
        X = \frac{3}{6}X + \frac{2}{6}(X+1) + \frac{1}{6}\cdot 1
    \]
    That is, we have $\frac{3}{6}$ probability to reset (if we roll an odd number), $\frac{2}{6} $ probability to proceed (if we roll a 2 or 4), and $\frac{1}{6}$ probability to stop (if we roll a 6). The answer is no, this method won't work. The problem is that in the second term, it should be $(X + \mathbb{P}[\text{this roll count}]) $ instead of $(X+1)$, since there is still a non-zero probability to be reset. However, what is $\mathbb{P}[\text{this roll counts}]$? Actually,
    \[
        \mathbb{P}[\text{this roll counts}] = \mathbb{P}[\text{we never see a 1,3, or 5}] = \sum\limits_{i=1}^\infty \left(\frac{2}{6}\right)^{i-1}\frac{1}{6} = \frac{1/6}{1-2/6} = \frac{1}{4}
    \]
    Hence, we can define $X = \mathbb{E}[\#\text{rolls}] $ and 
    \[
        X = \frac{3}{6}X + \frac{2}{6}\left(X+\frac{1}{4}\right) + \frac{1}{6}\cdot 1
    \]
    We can now solve for X, giving us $X = 1.5$ as expected.
\end{enumerate}
\section{Von Neumann's Theorem}
    Suppose that Alice and Bob are playing a game where there's a payoff matrix $V$. Alice can choose a row of $V$ and Bob can choose a column of $V$. Alice wants to minimize the payoff but Bob wants to maximize it. This is a zero-sum game. Suppose that Alice can use a mixed strategy with distribution $p$ over the rows and Bob can use a mixed strategy with distribution $q$ over the columns. The expected payoff can be described as
    \[
        p^T V q
    \]
    Actually, according to Von Neumann's theorem, 
    \[
        \min\limits_p \max\limits_{e_i} p^TVe_i = \min\limits_p \max\limits_q p^TVq = \max\limits_q\min\limits_p  p^TVq = \max\limits_q\min\limits_{e_j}  e_j^TVq
    \]
    No matter who goes first, the expected payoff are the same. Also, the second people can always choose his(her) best strategy deterministically.
\subsection{Recall}
\begin{itemize}
    \item Deterministic alg. needs $\Omega(n) $ queries in game tree evaluation.
    \item Non-deterministic alg. needs $\Theta (\sqrt{n}) $ queries in game tree evaluation.
\end{itemize}
Suppose we put all the run time information to a cost matrix $V$, where each column represents an game tree instance and each row represents a deterministic algorithm. 
Note that there's at least one $n$ on each row.
\[
    \min\limits_{\text{alg }\mathcal{A}}\max\limits_{\text{instance }\mathcal{I}} V(\mathcal{A}, \mathcal{I}) = n
\]
There's some $\Theta(\sqrt{n}) $ on each column.
\[
    \max\limits_{\text{instance }\mathcal{I}}\min\limits_{\text{alg }\mathcal{A}} V(\mathcal{A}, \mathcal{I}) = \Theta(\sqrt{n})
\]
According to previous lecture, we know that the expected number of queries for randomized algorithm is bounded by
\[
    \min\limits_{\substack{p:\text{distr.}\\ \text{over algs}}} \max\limits_{\text{instance }\mathcal{I}} p^TVe_{\mathcal{I}} \leq n^{0.793}
\]
By Von Neumann's theorem, we have
\[
    \max\limits_{\substack{q:\text{distr.}\\ \text{over instances}}}\min\limits_{\mathcal{A}:\text{det. alg}} e_{\mathcal{A}}^TVq = \min\limits_{\substack{p:\text{distr.}\\ \text{over algs}}} \max\limits_{\text{instance }\mathcal{I}} p^TVe_{\mathcal{I}} \leq n^{0.793}
  \]

  This is known as ``Yao's principle.''  Suppose we want to know the
  perfomance of the optimal randomized algorithm, when performed on
  its worst-case input for that algorithm.  Yao's principle says that
  it suffices to consider the worst-case fixed \emph{distribution} on
  inputs, and analyze the performance of the best deterministic
  algorithm for that input.

  That is to say, suppose we can show for a particular distribution on
  inputs that no deterministic algorithm can perform better than $X$.
  Then any randomized algorithm, being just a mixture of deterministic
  algorithms, also performs no better than $X$.  Yao's principle says
  that this is without loss of generality: there exists such a
  distribution on inputs so that the lower bound for randomized algorithms
  derived from this approach is optimal.

\paragraph{Goal:} pick some distr. $q$ s.t. no det. alg. does well on it. Consider a NAND tree where every node is active with probability $p$. In this case, 
\[
    1-p = \mathbb{P}[\text{not active}] = \mathbb{P}[\text{both child active}] = p^2
\]
By solving $p^2 +p -1 = 0 $, we'll have $p = \frac{\sqrt{5}-1}{2} $. In this distribution, the expected number of leafs that our randomized game tree algorithm from previous lecture needs to explore is
\begin{align*}
    T(h) &\leq T(h-1)(1-p)+ 2T(h-1)p\\
    & = T(h-1)(1+p)\\
    &\leq (1+p)^{h}\\
    & = (2^{\log_2 (1+p)})^h\\
    & = (2^h)^{\log_2 (1+p)}\\
    & = n^{\log_2 (1+p)} \leq n^{0.6943}
\end{align*}
\end{document}
