\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{xcolor}
\usepackage{enumerate}

\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}[5]{\handout{XX}{#3}{#4}{Scribe: #5}{Lecture #1: #2}}

\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}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\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

\begin{document}

\lecture{7}{Probability Puzzles}{September 19, 2019}{Prof.\ Eric Price}{Hongru Yang, Zihang He}
% Example:
%\lecture{1}{Coupon Collector; Balls and Bins}{August 29th, 2019}{Prof.\ Eric Price}{John Doe, Jane Roe}

\section{Balls and Bins Revisit}
\paragraph{Question:}

\begin{enumerate}
\item How many balls can I throws in, typically, into $n$ bins before\\
\begin{enumerate}
\item max load is 2 with 1 choice?\\
\item max load is 2 with 2 choices?\\
\end{enumerate}

\item How many balls can I throws in, typically, into $n$ bins before\\
\begin{enumerate}
\item max load is 3 with 1 choice?\\
\item max load is 3 with 2 choices?\\
\end{enumerate}
\end{enumerate}

(1.a)
After $k$ balls are thrown, if max load is 1, then the loads of $k$ bins are 1 and $n-k$ bins are 0. Define failure as the case that the max load is 2. The chance of failure of $k$-th is $\frac{k}{n}$.

Between $\frac{k}{2}$-th and $k$-th balls thrown, the failure prob is $O\left(\frac{k}{n}\right)$. The total failure probability after $k$ balls are thrown is approximately $1-\left(1-\frac{k}{n}\right)^k=\Theta\left(\frac{k^2}{n}\right)$.

(1.b)
Same analysis as $(1.a)$. Except now the failure probability of $k$-th is $O(\frac{k^2}{n^2})$. So the total failure probability after $k$ balls are thrown is $1 - \left(1 - \frac{k^2}{n^2}\right)^k = \Theta \left(\frac{k^3}{n^2}\right)$.

(2.a)
After $k$ balls $(k<n)$ are thrown,
\begin{itemize}
  \item expect $\Theta\left(k\right)$ bins with 1 ball.
  \item expect $\Theta\left(\frac{k}{n}\times k\right)=\Theta\left(\frac{k^2}{n}\right)$ bins with 2 ball.
  \item with $\Theta\left(\frac{k^3}{n^2}\right)$ probability that there exists a bin with height 3.
\end{itemize}
Typically, we can throw $\Theta(n^{2/3})$ balls before the max load is 3.

(2.b)
After $k$ balls $(k<n)$ are thrown,
\begin{itemize}
  \item expect $\Theta\left(k\right)$ bins with 1 ball.
  \item expect $\Theta\left(\frac{k}{n}\times\frac{k}{n}\times k\right)=\Theta\left(\frac{k^3}{n^2}\right)$ bins with 2 ball.
  \item with $\Theta\left(\frac{k^7}{n^6}\right)$ probability that there exists a bin with height 3.
\end{itemize}
Typically, we can throw $\Theta(n^{6/7})$ balls before the max load is 3.
\paragraph{Conclusion:}
In general, for any height $C=O(1)$. We can throw $k$ balls, typically, before the max load is $C$ where
\begin{enumerate}[(a)]
\item $k=n^{1-\frac{1}{C}}$ with 1 choice
\item $k=n^{1-\frac{1}{2^C-1}}$ with 2 choices
\end{enumerate}

\section{Random Walk}
\paragraph{Question:}
Start at 0. At each step, move +1 or -1 with equal probability. Stop if reach -10 or 100
\begin{enumerate}[(a)]
\item Pr[stop at -10]
\item How long does it stop in expectation?
\end{enumerate}

\textbf{Solution:}

(a)

\paragraph{Method 1:} Using \textbf{expectation}

Let $X_t$ denote the distribution of its location after moving $t$ steps.
$\E[X_t-X_{t-1}]=\frac{1}{2}\times(+1)+\frac{1}{2}\times(-1)=0$. Therefore, $\E[X_t]$ remains the same for different $t$.
$\Pr[\text{stops at }-10]\times(-10)+(1-\Pr[\text{stops at }100])\times 100=0$ which indicates $\Pr[\text{stops at }-10]=\frac{10}{11}$.

\paragraph{Method 2:}

Let $p_i$ denote the probability of stopping at -10 when starting at $i$. We have
$$p_i=\left\{\begin{array}{ll}1&\text{if }i=-10;\\0&\text{if }i=100;\\ \frac{1}{2}\left(p_{i-1}+p_{i+1}\right)&\text{otherwise}.\end{array}\right.$$
%$$p_i=\frac{1}{2}\left(p_{i-1}+p_{i+1}\right), p_{-10}=1, p_{100}=0.$$
By solving this equation, We have $p_i$ is linear with $i$ and $p_{0}=\frac{10}{11}$.
\newpage
(b)


Let $n_i$ denote the expected number of steps to stop when starting at $i$. We have
$$n_i=\left\{\begin{array}{ll}0&\text{if }i=-10\text{ or }100;\\ \frac{1}{2}\left(n_{i-1}+1\right)+\frac{1}{2}\left(n_{i+1}+1\right)&\text{otherwise}.\end{array}\right.$$
%$$p_i=\frac{1}{2}\left(p_{i-1}+p_{i+1}\right), p_{-10}=1, p_{100}=0.$$
By solving this equation, we have $n_i=-i^2+90i+1000$ and $n_{0}=1000$.

\end{document}
