# Chernoff Bound

Suppose that we have a fair coin. If we toss it once, then the outcome is completely unpredictable. But if we toss it, say for 1000 times, then the number of HEADs is very likely to be around 500. This phenomenon, as illustrated in the following figure, is called the concentration of measure. The Chernoff bound is an inequality that characterizes the concentration phenomenon for the sum of independent trials.

Before formally stating the Chernoff bound, let's introduce the moment generating function.

## Moment generating functions

The more we know about the moments of a random variable ${\displaystyle X}$, the more information we would have about ${\displaystyle X}$. There is a so-called moment generating function, which "packs" all the information about the moments of ${\displaystyle X}$ into one function.

 Definition The moment generating function of a random variable ${\displaystyle X}$ is defined as ${\displaystyle \mathbf {E} \left[\mathrm {e} ^{\lambda X}\right]}$ where ${\displaystyle \lambda }$ is the parameter of the function.

By Taylor's expansion and the linearity of expectations,

{\displaystyle {\begin{aligned}\mathbf {E} \left[\mathrm {e} ^{\lambda X}\right]&=\mathbf {E} \left[\sum _{k=0}^{\infty }{\frac {\lambda ^{k}}{k!}}X^{k}\right]\\&=\sum _{k=0}^{\infty }{\frac {\lambda ^{k}}{k!}}\mathbf {E} \left[X^{k}\right]\end{aligned}}}

The moment generating function ${\displaystyle \mathbf {E} \left[\mathrm {e} ^{\lambda X}\right]}$ is a function of ${\displaystyle \lambda }$.

## The Chernoff bound

The Chernoff bounds are exponentially sharp tail inequalities for the sum of independent trials. The bounds are obtained by applying Markov's inequality to the moment generating function of the sum of independent trials, with some appropriate choice of the parameter ${\displaystyle \lambda }$.

 Chernoff bound (the upper tail) Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$, where ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ are independent Poisson trials. Let ${\displaystyle \mu =\mathbf {E} [X]}$. Then for any ${\displaystyle \delta >0}$, ${\displaystyle \Pr[X\geq (1+\delta )\mu ]\leq \left({\frac {e^{\delta }}{(1+\delta )^{(1+\delta )}}}\right)^{\mu }.}$
Proof.
 For any ${\displaystyle \lambda >0}$, ${\displaystyle X\geq (1+\delta )\mu }$ is equivalent to that ${\displaystyle e^{\lambda X}\geq e^{\lambda (1+\delta )\mu }}$, thus {\displaystyle {\begin{aligned}\Pr[X\geq (1+\delta )\mu ]&=\Pr \left[e^{\lambda X}\geq e^{\lambda (1+\delta )\mu }\right]\\&\leq {\frac {\mathbf {E} \left[e^{\lambda X}\right]}{e^{\lambda (1+\delta )\mu }}},\end{aligned}}} where the last step follows by Markov's inequality. Computing the moment generating function ${\displaystyle \mathbf {E} [e^{\lambda X}]}$: {\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda X}\right]&=\mathbf {E} \left[e^{\lambda \sum _{i=1}^{n}X_{i}}\right]\\&=\mathbf {E} \left[\prod _{i=1}^{n}e^{\lambda X_{i}}\right]\\&=\prod _{i=1}^{n}\mathbf {E} \left[e^{\lambda X_{i}}\right].&({\mbox{for independent random variables}})\end{aligned}}} Let ${\displaystyle p_{i}=\Pr[X_{i}=1]}$ for ${\displaystyle i=1,2,\ldots ,n}$. Then, ${\displaystyle \mu =\mathbf {E} [X]=\mathbf {E} \left[\sum _{i=1}^{n}X_{i}\right]=\sum _{i=1}^{n}\mathbf {E} [X_{i}]=\sum _{i=1}^{n}p_{i}}$. We bound the moment generating function for each individual ${\displaystyle X_{i}}$ as follows. {\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda X_{i}}\right]&=p_{i}\cdot e^{\lambda \cdot 1}+(1-p_{i})\cdot e^{\lambda \cdot 0}\\&=1+p_{i}(e^{\lambda }-1)\\&\leq e^{p_{i}(e^{\lambda }-1)},\end{aligned}}} where in the last step we apply the Taylor's expansion so that ${\displaystyle e^{y}\geq 1+y}$ where ${\displaystyle y=p_{i}(e^{\lambda }-1)\geq 0}$. (By doing this, we can transform the product to the sum of ${\displaystyle p_{i}}$, which is ${\displaystyle \mu }$.) Therefore, {\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda X}\right]&=\prod _{i=1}^{n}\mathbf {E} \left[e^{\lambda X_{i}}\right]\\&\leq \prod _{i=1}^{n}e^{p_{i}(e^{\lambda }-1)}\\&=\exp \left(\sum _{i=1}^{n}p_{i}(e^{\lambda }-1)\right)\\&=e^{(e^{\lambda }-1)\mu }.\end{aligned}}} Thus, we have shown that for any ${\displaystyle \lambda >0}$, {\displaystyle {\begin{aligned}\Pr[X\geq (1+\delta )\mu ]&\leq {\frac {\mathbf {E} \left[e^{\lambda X}\right]}{e^{\lambda (1+\delta )\mu }}}\\&\leq {\frac {e^{(e^{\lambda }-1)\mu }}{e^{\lambda (1+\delta )\mu }}}\\&=\left({\frac {e^{(e^{\lambda }-1)}}{e^{\lambda (1+\delta )}}}\right)^{\mu }\end{aligned}}}. For any ${\displaystyle \delta >0}$, we can let ${\displaystyle \lambda =\ln(1+\delta )>0}$ to get ${\displaystyle \Pr[X\geq (1+\delta )\mu ]\leq \left({\frac {e^{\delta }}{(1+\delta )^{(1+\delta )}}}\right)^{\mu }.}$
${\displaystyle \square }$

The idea of the proof is actually quite clear: we apply Markov's inequality to ${\displaystyle e^{\lambda X}}$ and for the rest, we just estimate the moment generating function ${\displaystyle \mathbf {E} [e^{\lambda X}]}$. To make the bound as tight as possible, we minimized the ${\displaystyle {\frac {e^{(e^{\lambda }-1)}}{e^{\lambda (1+\delta )}}}}$ by setting ${\displaystyle \lambda =\ln(1+\delta )}$, which can be justified by taking derivatives of ${\displaystyle {\frac {e^{(e^{\lambda }-1)}}{e^{\lambda (1+\delta )}}}}$.

We then proceed to the lower tail, the probability that the random variable deviates below the mean value:

 Chernoff bound (the lower tail) Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$, where ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ are independent Poisson trials. Let ${\displaystyle \mu =\mathbf {E} [X]}$. Then for any ${\displaystyle 0<\delta <1}$, ${\displaystyle \Pr[X\leq (1-\delta )\mu ]\leq \left({\frac {e^{-\delta }}{(1-\delta )^{(1-\delta )}}}\right)^{\mu }.}$
Proof.
 For any ${\displaystyle \lambda <0}$, by the same analysis as in the upper tail version, {\displaystyle {\begin{aligned}\Pr[X\leq (1-\delta )\mu ]&=\Pr \left[e^{\lambda X}\geq e^{\lambda (1-\delta )\mu }\right]\\&\leq {\frac {\mathbf {E} \left[e^{\lambda X}\right]}{e^{\lambda (1-\delta )\mu }}}\\&\leq \left({\frac {e^{(e^{\lambda }-1)}}{e^{\lambda (1-\delta )}}}\right)^{\mu }.\end{aligned}}} For any ${\displaystyle 0<\delta <1}$, we can let ${\displaystyle \lambda =\ln(1-\delta )<0}$ to get ${\displaystyle \Pr[X\geq (1-\delta )\mu ]\leq \left({\frac {e^{-\delta }}{(1-\delta )^{(1-\delta )}}}\right)^{\mu }.}$
${\displaystyle \square }$

## Useful forms of the Chernoff bounds

Some useful special forms of the bounds can be derived directly from the above general forms of the bounds. We now know better why we say that the bounds are exponentially sharp.

 Useful forms of the Chernoff bound Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$, where ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ are independent Poisson trials. Let ${\displaystyle \mu =\mathbf {E} [X]}$. Then 1. for ${\displaystyle 0<\delta \leq 1}$, ${\displaystyle \Pr[X\geq (1+\delta )\mu ]<\exp \left(-{\frac {\mu \delta ^{2}}{3}}\right);}$ ${\displaystyle \Pr[X\leq (1-\delta )\mu ]<\exp \left(-{\frac {\mu \delta ^{2}}{2}}\right);}$ 2. for ${\displaystyle t\geq 2e\mu }$, ${\displaystyle \Pr[X\geq t]\leq 2^{-t}.}$
Proof.
 To obtain the bounds in (1), we need to show that for ${\displaystyle 0<\delta <1}$, ${\displaystyle {\frac {e^{\delta }}{(1+\delta )^{(1+\delta )}}}\leq e^{-\delta ^{2}/3}}$ and ${\displaystyle {\frac {e^{-\delta }}{(1-\delta )^{(1-\delta )}}}\leq e^{-\delta ^{2}/2}}$. We can verify both inequalities by standard analysis techniques. To obtain the bound in (2), let ${\displaystyle t=(1+\delta )\mu }$. Then ${\displaystyle \delta =t/\mu -1\geq 2e-1}$. Hence, {\displaystyle {\begin{aligned}\Pr[X\geq (1+\delta )\mu ]&\leq \left({\frac {e^{\delta }}{(1+\delta )^{(1+\delta )}}}\right)^{\mu }\\&\leq \left({\frac {e}{1+\delta }}\right)^{(1+\delta )\mu }\\&\leq \left({\frac {e}{2e}}\right)^{t}\\&\leq 2^{-t}\end{aligned}}}
${\displaystyle \square }$

## Applications to balls-into-bins

Throwing ${\displaystyle m}$ balls uniformly and independently to ${\displaystyle n}$ bins, what is the maximum load of all bins with high probability? In the last class, we gave an analysis of this problem by using a counting argument.

Now we give a more "advanced" analysis by using Chernoff bounds.

For any ${\displaystyle i\in [n]}$ and ${\displaystyle j\in [m]}$, let ${\displaystyle X_{ij}}$ be the indicator variable for the event that ball ${\displaystyle j}$ is thrown to bin ${\displaystyle i}$. Obviously

${\displaystyle \mathbf {E} [X_{ij}]=\Pr[{\mbox{ball }}j{\mbox{ is thrown to bin }}i]={\frac {1}{n}}}$

Let ${\displaystyle Y_{i}=\sum _{j\in [m]}X_{ij}}$ be the load of bin ${\displaystyle i}$.

Then the expected load of bin ${\displaystyle i}$ is

${\displaystyle (*)\qquad \mu =\mathbf {E} [Y_{i}]=\mathbf {E} \left[\sum _{j\in [m]}X_{ij}\right]=\sum _{j\in [m]}\mathbf {E} [X_{ij}]=m/n.}$

For the case ${\displaystyle m=n}$, it holds that ${\displaystyle \mu =1}$

Note that ${\displaystyle Y_{i}}$ is a sum of ${\displaystyle m}$ mutually independent indicator variable. Applying Chernoff bound, for any particular bin ${\displaystyle i\in [n]}$,

${\displaystyle \Pr[Y_{i}>(1+\delta )\mu ]\leq \left({\frac {e^{\delta }}{(1+\delta )^{1+\delta }}}\right)^{\mu }.}$

### The ${\displaystyle m=n}$ case

When ${\displaystyle m=n}$, ${\displaystyle \mu =1}$. Write ${\displaystyle c=1+\delta }$. The above bound can be written as

${\displaystyle \Pr[Y_{i}>c]\leq {\frac {e^{c-1}}{c^{c}}}.}$

Let ${\displaystyle c={\frac {e\ln n}{\ln \ln n}}}$, we evaluate ${\displaystyle {\frac {e^{c-1}}{c^{c}}}}$ by taking logarithm to its reciprocal.

{\displaystyle {\begin{aligned}\ln \left({\frac {c^{c}}{e^{c-1}}}\right)&=c\ln c-c+1\\&=c(\ln c-1)+1\\&={\frac {e\ln n}{\ln \ln n}}\left(\ln \ln n-\ln \ln \ln n\right)+1\\&\geq {\frac {e\ln n}{\ln \ln n}}\cdot {\frac {2}{e}}\ln \ln n+1\\&\geq 2\ln n.\end{aligned}}}

Thus,

${\displaystyle \Pr \left[Y_{i}>{\frac {e\ln n}{\ln \ln n}}\right]\leq {\frac {1}{n^{2}}}.}$

Applying the union bound, the probability that there exists a bin with load ${\displaystyle >12\ln n}$ is

${\displaystyle n\cdot \Pr \left[Y_{1}>{\frac {e\ln n}{\ln \ln n}}\right]\leq {\frac {1}{n}}}$.

Therefore, for ${\displaystyle m=n}$, with high probability, the maximum load is ${\displaystyle O\left({\frac {e\ln n}{\ln \ln n}}\right)}$.

### The ${\displaystyle m>\ln n}$ case

When ${\displaystyle m\geq n\ln n}$, then according to ${\displaystyle (*)}$, ${\displaystyle \mu ={\frac {m}{n}}\geq \ln n}$

We can apply an easier form of the Chernoff bounds,

${\displaystyle \Pr[Y_{i}\geq 2e\mu ]\leq 2^{-2e\mu }\leq 2^{-2e\ln n}<{\frac {1}{n^{2}}}.}$

By the union bound, the probability that there exists a bin with load ${\displaystyle \geq 2e{\frac {m}{n}}}$ is,

${\displaystyle n\cdot \Pr \left[Y_{1}>2e{\frac {m}{n}}\right]=n\cdot \Pr \left[Y_{1}>2e\mu \right]\leq {\frac {1}{n}}}$.

Therefore, for ${\displaystyle m\geq n\ln n}$, with high probability, the maximum load is ${\displaystyle O\left({\frac {m}{n}}\right)}$.

# Martingales

"Martingale" originally refers to a betting strategy in which the gambler doubles his bet after every loss. Assuming unlimited wealth, this strategy is guaranteed to eventually have a positive net profit. For example, starting from an initial stake 1, after ${\displaystyle n}$ losses, if the ${\displaystyle (n+1)}$th bet wins, then it gives a net profit of

${\displaystyle 2^{n}-\sum _{i=1}^{n}2^{i-1}=1,}$

which is a positive number.

However, the assumption of unlimited wealth is unrealistic. For limited wealth, with geometrically increasing bet, it is very likely to end up bankrupt. You should never try this strategy in real life.

Suppose that the gambler is allowed to use any strategy. His stake on the next beting is decided based on the results of all the bettings so far. This gives us a highly dependent sequence of random variables ${\displaystyle X_{0},X_{1},\ldots ,}$, where ${\displaystyle X_{0}}$ is his initial capital, and ${\displaystyle X_{i}}$ represents his capital after the ${\displaystyle i}$th betting. Up to different betting strategies, ${\displaystyle X_{i}}$ can be arbitrarily dependent on ${\displaystyle X_{0},\ldots ,X_{i-1}}$. However, as long as the game is fair, namely, winning and losing with equal chances, conditioning on the past variables ${\displaystyle X_{0},\ldots ,X_{i-1}}$, we will expect no change in the value of the present variable ${\displaystyle X_{i}}$ on average. Random variables satisfying this property is called a martingale sequence.

 Definition (martingale) A sequence of random variables ${\displaystyle X_{0},X_{1},\ldots }$ is a martingale if for all ${\displaystyle i>0}$, {\displaystyle {\begin{aligned}\mathbf {E} [X_{i}\mid X_{0},\ldots ,X_{i-1}]=X_{i-1}.\end{aligned}}}

The martingale can be generalized to be with respect to another sequence of random variables.

 Definition (martingale, general version) A sequence of random variables ${\displaystyle Y_{0},Y_{1},\ldots }$ is a martingale with respect to the sequence ${\displaystyle X_{0},X_{1},\ldots }$ if, for all ${\displaystyle i\geq 0}$, the following conditions hold: ${\displaystyle Y_{i}}$ is a function of ${\displaystyle X_{0},X_{1},\ldots ,X_{i}}$; {\displaystyle {\begin{aligned}\mathbf {E} [Y_{i+1}\mid X_{0},\ldots ,X_{i}]=Y_{i}.\end{aligned}}}

Therefore, a sequence ${\displaystyle X_{0},X_{1},\ldots }$ is a martingale if it is a martingale with respect to itself.

The purpose of this generalization is that we are usually more interested in a function of a sequence of random variables, rather than the sequence itself.

## Azuma's Inequality

The Azuma's inequality is a martingale tail inequality.

 Azuma's Inequality Let ${\displaystyle X_{0},X_{1},\ldots }$ be a martingale such that, for all ${\displaystyle k\geq 1}$, ${\displaystyle |X_{k}-X_{k-1}|\leq c_{k},}$ Then {\displaystyle {\begin{aligned}\Pr \left[|X_{n}-X_{0}|\geq t\right]\leq 2\exp \left(-{\frac {t^{2}}{2\sum _{k=1}^{n}c_{k}^{2}}}\right).\end{aligned}}}

Unlike the Chernoff bounds, there is no assumption of independence, which makes the martingale inequalities more useful.

The following bounded difference condition

${\displaystyle |X_{k}-X_{k-1}|\leq c_{k}}$

says that the martingale ${\displaystyle X_{0},X_{1},\ldots }$ as a process evolving over time, never makes big change in a single step.

The Azuma's inequality says that for any martingale satisfying the bounded difference condition, it is unlikely that process wanders far from its starting point.

A special case is when the differences are bounded by a constant. The following corollary is directly implied by the Azuma's inequality.

 Corollary Let ${\displaystyle X_{0},X_{1},\ldots }$ be a martingale such that, for all ${\displaystyle k\geq 1}$, ${\displaystyle |X_{k}-X_{k-1}|\leq c,}$ Then {\displaystyle {\begin{aligned}\Pr \left[|X_{n}-X_{0}|\geq ct{\sqrt {n}}\right]\leq 2e^{-t^{2}/2}.\end{aligned}}}

This corollary states that for any martingale sequence whose diferences are bounded by a constant, the probability that it deviates ${\displaystyle \omega ({\sqrt {n}})}$ far away from the starting point after ${\displaystyle n}$ steps is bounded by ${\displaystyle o(1)}$.

### Generalization

Azuma's inequality can be generalized to a martingale with respect another sequence.

 Azuma's Inequality (general version) Let ${\displaystyle Y_{0},Y_{1},\ldots }$ be a martingale with respect to the sequence ${\displaystyle X_{0},X_{1},\ldots }$ such that, for all ${\displaystyle k\geq 1}$, ${\displaystyle |Y_{k}-Y_{k-1}|\leq c_{k},}$ Then {\displaystyle {\begin{aligned}\Pr \left[|Y_{n}-Y_{0}|\geq t\right]\leq 2\exp \left(-{\frac {t^{2}}{2\sum _{k=1}^{n}c_{k}^{2}}}\right).\end{aligned}}}

### The Proof of Azuma's Inueqality

We will only give the formal proof of the non-generalized version. The proof of the general version is almost identical, with the only difference that we work on random sequence ${\displaystyle Y_{i}}$ conditioning on sequence ${\displaystyle X_{i}}$.

The proof of Azuma's Inequality uses several ideas which are used in the proof of the Chernoff bounds. We first observe that the total deviation of the martingale sequence can be represented as the sum of deferences in every steps. Thus, as the Chernoff bounds, we are looking for a bound of the deviation of the sum of random variables. The strategy of the proof is almost the same as the proof of Chernoff bounds: we first apply Markov's inequality to the moment generating function, then we bound the moment generating function, and at last we optimize the parameter of the moment generating function. However, unlike the Chernoff bounds, the martingale differences are not independent any more. So we replace the use of the independence in the Chernoff bound by the martingale property. The proof is detailed as follows.

In order to bound the probability of ${\displaystyle |X_{n}-X_{0}|\geq t}$, we first bound the upper tail ${\displaystyle \Pr[X_{n}-X_{0}\geq t]}$. The bound of the lower tail can be symmetrically proved with the ${\displaystyle X_{i}}$ replaced by ${\displaystyle -X_{i}}$.

#### Represent the deviation as the sum of differences

We define the martingale difference sequence: for ${\displaystyle i\geq 1}$, let

${\displaystyle Y_{i}=X_{i}-X_{i-1}.}$

It holds that

{\displaystyle {\begin{aligned}\mathbf {E} [Y_{i}\mid X_{0},\ldots ,X_{i-1}]&=\mathbf {E} [X_{i}-X_{i-1}\mid X_{0},\ldots ,X_{i-1}]\\&=\mathbf {E} [X_{i}\mid X_{0},\ldots ,X_{i-1}]-\mathbf {E} [X_{i-1}\mid X_{0},\ldots ,X_{i-1}]\\&=X_{i-1}-X_{i-1}\\&=0.\end{aligned}}}

The second to the last equation is due to the fact that ${\displaystyle X_{0},X_{1},\ldots }$ is a martingale and the definition of conditional expectation.

Let ${\displaystyle Z_{n}}$ be the accumulated differences

${\displaystyle Z_{n}=\sum _{i=1}^{n}Y_{i}.}$

The deviation ${\displaystyle (X_{n}-X_{0})}$ can be computed by the accumulated differences:

{\displaystyle {\begin{aligned}X_{n}-X_{0}&=(X_{1}-X_{0})+(X_{2}-X_{1})+\cdots +(X_{n}-X_{n-1})\\&=\sum _{i=1}^{n}Y_{i}\\&=Z_{n}.\end{aligned}}}

We then only need to upper bound the probability of the event ${\displaystyle Z_{n}\geq t}$.

#### Apply Markov's inequality to the moment generating function

The event ${\displaystyle Z_{n}\geq t}$ is equivalent to that ${\displaystyle e^{\lambda Z_{n}}\geq e^{\lambda t}}$ for ${\displaystyle \lambda >0}$. Apply Markov's inequality, we have

{\displaystyle {\begin{aligned}\Pr \left[Z_{n}\geq t\right]&=\Pr \left[e^{\lambda Z_{n}}\geq e^{\lambda t}\right]\\&\leq {\frac {\mathbf {E} \left[e^{\lambda Z_{n}}\right]}{e^{\lambda t}}}.\end{aligned}}}

This is exactly the same as what we did to prove the Chernoff bound. Next, we need to bound the moment generating function ${\displaystyle \mathbf {E} \left[e^{\lambda Z_{n}}\right]}$.

#### Bound the moment generating functions

The moment generating function

{\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda Z_{n}}\right]&=\mathbf {E} \left[\mathbf {E} \left[e^{\lambda Z_{n}}\mid X_{0},\ldots ,X_{n-1}\right]\right]\\&=\mathbf {E} \left[\mathbf {E} \left[e^{\lambda (Z_{n-1}+Y_{n})}\mid X_{0},\ldots ,X_{n-1}\right]\right]\\&=\mathbf {E} \left[\mathbf {E} \left[e^{\lambda Z_{n-1}}\cdot e^{\lambda Y_{n}}\mid X_{0},\ldots ,X_{n-1}\right]\right]\\&=\mathbf {E} \left[e^{\lambda Z_{n-1}}\cdot \mathbf {E} \left[e^{\lambda Y_{n}}\mid X_{0},\ldots ,X_{n-1}\right]\right]\end{aligned}}}

The first and the last equations are due to the fundamental facts about conditional expectation which are proved by us in the first section.

We then upper bound the ${\displaystyle \mathbf {E} \left[e^{\lambda Y_{n}}\mid X_{0},\ldots ,X_{n-1}\right]}$ by a constant. To do so, we need the following technical lemma which is proved by the convexity of ${\displaystyle e^{\lambda Y_{n}}}$.

 Lemma Let ${\displaystyle X}$ be a random variable such that ${\displaystyle \mathbf {E} [X]=0}$ and ${\displaystyle |X|\leq c}$. Then for ${\displaystyle \lambda >0}$, ${\displaystyle \mathbf {E} [e^{\lambda X}]\leq e^{\lambda ^{2}c^{2}/2}.}$
Proof.
 Observe that for ${\displaystyle \lambda >0}$, the function ${\displaystyle e^{\lambda X}}$ of the variable ${\displaystyle X}$ is convex in the interval ${\displaystyle [-c,c]}$. We draw a line between the two endpoints points ${\displaystyle (-c,e^{-\lambda c})}$ and ${\displaystyle (c,e^{\lambda c})}$. The curve of ${\displaystyle e^{\lambda X}}$ lies entirely below this line. Thus, {\displaystyle {\begin{aligned}e^{\lambda X}&\leq {\frac {c-X}{2c}}e^{-\lambda c}+{\frac {c+X}{2c}}e^{\lambda c}\\&={\frac {e^{\lambda c}+e^{-\lambda c}}{2}}+{\frac {X}{2c}}(e^{\lambda c}-e^{-\lambda c}).\end{aligned}}} Since ${\displaystyle \mathbf {E} [X]=0}$, we have {\displaystyle {\begin{aligned}\mathbf {E} [e^{\lambda X}]&\leq \mathbf {E} [{\frac {e^{\lambda c}+e^{-\lambda c}}{2}}+{\frac {X}{2c}}(e^{\lambda c}-e^{-\lambda c})]\\&={\frac {e^{\lambda c}+e^{-\lambda c}}{2}}+{\frac {e^{\lambda c}-e^{-\lambda c}}{2c}}\mathbf {E} [X]\\&={\frac {e^{\lambda c}+e^{-\lambda c}}{2}}.\end{aligned}}} By expanding both sides as Taylor's series, it can be verified that ${\displaystyle {\frac {e^{\lambda c}+e^{-\lambda c}}{2}}\leq e^{\lambda ^{2}c^{2}/2}}$.
${\displaystyle \square }$

Apply the above lemma to the random variable

${\displaystyle (Y_{n}\mid X_{0},\ldots ,X_{n-1})}$

We have already shown that its expectation ${\displaystyle \mathbf {E} [(Y_{n}\mid X_{0},\ldots ,X_{n-1})]=0,}$ and by the bounded difference condition of Azuma's inequality, we have ${\displaystyle |Y_{n}|=|(X_{n}-X_{n-1})|\leq c_{n}.}$ Thus, due to the above lemma, it holds that

${\displaystyle \mathbf {E} [e^{\lambda Y_{n}}\mid X_{0},\ldots ,X_{n-1}]\leq e^{\lambda ^{2}c_{n}^{2}/2}.}$

Back to our analysis of the expectation ${\displaystyle \mathbf {E} \left[e^{\lambda Z_{n}}\right]}$, we have

{\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda Z_{n}}\right]&=\mathbf {E} \left[e^{\lambda Z_{n-1}}\cdot \mathbf {E} \left[e^{\lambda Y_{n}}\mid X_{0},\ldots ,X_{n-1}\right]\right]\\&\leq \mathbf {E} \left[e^{\lambda Z_{n-1}}\cdot e^{\lambda ^{2}c_{n}^{2}/2}\right]\\&=e^{\lambda ^{2}c_{n}^{2}/2}\cdot \mathbf {E} \left[e^{\lambda Z_{n-1}}\right].\end{aligned}}}

Apply the same analysis to ${\displaystyle \mathbf {E} \left[e^{\lambda Z_{n-1}}\right]}$, we can solve the above recursion by

{\displaystyle {\begin{aligned}\mathbf {E} \left[e^{\lambda Z_{n}}\right]&\leq \prod _{k=1}^{n}e^{\lambda ^{2}c_{k}^{2}/2}\\&=\exp \left(\lambda ^{2}\sum _{k=1}^{n}c_{k}^{2}/2\right).\end{aligned}}}

Go back to the Markov's inequality,

{\displaystyle {\begin{aligned}\Pr \left[Z_{n}\geq t\right]&\leq {\frac {\mathbf {E} \left[e^{\lambda Z_{n}}\right]}{e^{\lambda t}}}\\&\leq \exp \left(\lambda ^{2}\sum _{k=1}^{n}c_{k}^{2}/2-\lambda t\right).\end{aligned}}}

We then only need to choose a proper ${\displaystyle \lambda >0}$.

#### Optimization

By choosing ${\displaystyle \lambda ={\frac {t}{\sum _{k=1}^{n}c_{k}^{2}}}}$, we have that

${\displaystyle \exp \left(\lambda ^{2}\sum _{k=1}^{n}c_{k}^{2}/2-\lambda t\right)=\exp \left(-{\frac {t^{2}}{2\sum _{k=1}^{n}c_{k}^{2}}}\right).}$

Thus, the probability

{\displaystyle {\begin{aligned}\Pr \left[X_{n}-X_{0}\geq t\right]&=\Pr \left[Z_{n}\geq t\right]\\&\leq \exp \left(\lambda ^{2}\sum _{k=1}^{n}c_{k}^{2}/2-\lambda t\right)\\&=\exp \left(-{\frac {t^{2}}{2\sum _{k=1}^{n}c_{k}^{2}}}\right).\end{aligned}}}

The upper tail of Azuma's inequality is proved. By replacing ${\displaystyle X_{i}}$ by ${\displaystyle -X_{i}}$, the lower tail can be treated just as the upper tail. Applying the union bound, Azuma's inequality is proved.

## The Doob martingales

The following definition describes a very general approach for constructing an important type of martingales.

 Definition (The Doob sequence) The Doob sequence of a function ${\displaystyle f}$ with respect to a sequence of random variables ${\displaystyle X_{1},\ldots ,X_{n}}$ is defined by ${\displaystyle Y_{i}=\mathbf {E} [f(X_{1},\ldots ,X_{n})\mid X_{1},\ldots ,X_{i}],\quad 0\leq i\leq n.}$ In particular, ${\displaystyle Y_{0}=\mathbf {E} [f(X_{1},\ldots ,X_{n})]}$ and ${\displaystyle Y_{n}=f(X_{1},\ldots ,X_{n})}$.

The Doob sequence of a function defines a martingale. That is

${\displaystyle \mathbf {E} [Y_{i}\mid X_{1},\ldots ,X_{i-1}]=Y_{i-1},}$

for any ${\displaystyle 0\leq i\leq n}$.

To prove this claim, we recall the definition that ${\displaystyle Y_{i}=\mathbf {E} [f(X_{1},\ldots ,X_{n})\mid X_{1},\ldots ,X_{i}]}$, thus,

{\displaystyle {\begin{aligned}\mathbf {E} [Y_{i}\mid X_{1},\ldots ,X_{i-1}]&=\mathbf {E} [\mathbf {E} [f(X_{1},\ldots ,X_{n})\mid X_{1},\ldots ,X_{i}]\mid X_{1},\ldots ,X_{i-1}]\\&=\mathbf {E} [f(X_{1},\ldots ,X_{n})\mid X_{1},\ldots ,X_{i-1}]\\&=Y_{i-1},\end{aligned}}}

where the second equation is due to the fundamental fact about conditional expectation introduced in the first section.

The Doob martingale describes a very natural procedure to determine a function value of a sequence of random variables. Suppose that we want to predict the value of a function ${\displaystyle f(X_{1},\ldots ,X_{n})}$ of random variables ${\displaystyle X_{1},\ldots ,X_{n}}$. The Doob sequence ${\displaystyle Y_{0},Y_{1},\ldots ,Y_{n}}$ represents a sequence of refined estimates of the value of ${\displaystyle f(X_{1},\ldots ,X_{n})}$, gradually using more information on the values of the random variables ${\displaystyle X_{1},\ldots ,X_{n}}$. The first element ${\displaystyle Y_{0}}$ is just the expectation of ${\displaystyle f(X_{1},\ldots ,X_{n})}$. Element ${\displaystyle Y_{i}}$ is the expected value of ${\displaystyle f(X_{1},\ldots ,X_{n})}$ when the values of ${\displaystyle X_{1},\ldots ,X_{i}}$ are known, and ${\displaystyle Y_{n}=f(X_{1},\ldots ,X_{n})}$ when ${\displaystyle f(X_{1},\ldots ,X_{n})}$ is fully determined by ${\displaystyle X_{1},\ldots ,X_{n}}$.

The following two Doob martingales arise in evaluating the parameters of random graphs.

edge exposure martingale
Let ${\displaystyle G}$ be a random graph on ${\displaystyle n}$ vertices. Let ${\displaystyle f}$ be a real-valued function of graphs, such as, chromatic number, number of triangles, the size of the largest clique or independent set, etc. Denote that ${\displaystyle m={n \choose 2}}$. Fix an arbitrary numbering of potential edges between the ${\displaystyle n}$ vertices, and denote the edges as ${\displaystyle e_{1},\ldots ,e_{m}}$. Let
${\displaystyle X_{i}={\begin{cases}1&{\mbox{if }}e_{i}\in G,\\0&{\mbox{otherwise}}.\end{cases}}}$
Let ${\displaystyle Y_{0}=\mathbf {E} [f(G)]}$ and for ${\displaystyle i=1,\ldots ,m}$, let ${\displaystyle Y_{i}=\mathbf {E} [f(G)\mid X_{1},\ldots ,X_{i}]}$.
The sequence ${\displaystyle Y_{0},Y_{1},\ldots ,Y_{n}}$ gives a Doob martingale that is commonly called the edge exposure martingale.
vertex exposure martingale
Instead of revealing edges one at a time, we could reveal the set of edges connected to a given vertex, one vertex at a time. Suppose that the vertex set is ${\displaystyle [n]}$. Let ${\displaystyle X_{i}}$ be the subgraph of ${\displaystyle G}$ induced by the vertex set ${\displaystyle [i]}$, i.e. the first ${\displaystyle i}$ vertices.
Let ${\displaystyle Y_{0}=\mathbf {E} [f(G)]}$ and for ${\displaystyle i=1,\ldots ,n}$, let ${\displaystyle Y_{i}=\mathbf {E} [f(G)\mid X_{1},\ldots ,X_{i}]}$.
The sequence ${\displaystyle Y_{0},Y_{1},\ldots ,Y_{n}}$ gives a Doob martingale that is commonly called the vertex exposure martingale.

### Chromatic number

The random graph ${\displaystyle G(n,p)}$ is the graph on ${\displaystyle n}$ vertices ${\displaystyle [n]}$, obtained by selecting each pair of vertices to be an edge, randomly and independently, with probability ${\displaystyle p}$. We denote ${\displaystyle G\sim G(n,p)}$ if ${\displaystyle G}$ is generated in this way.

 Theorem [Shamir and Spencer (1987)] Let ${\displaystyle G\sim G(n,p)}$. Let ${\displaystyle \chi (G)}$ be the chromatic number of ${\displaystyle G}$. Then {\displaystyle {\begin{aligned}\Pr \left[|\chi (G)-\mathbf {E} [\chi (G)]|\geq t{\sqrt {n}}\right]\leq 2e^{-t^{2}/2}.\end{aligned}}}
Proof.
 Consider the vertex exposure martingale ${\displaystyle Y_{i}=\mathbf {E} [\chi (G)\mid X_{1},\ldots ,X_{i}]}$ where each ${\displaystyle X_{k}}$ exposes the induced subgraph of ${\displaystyle G}$ on vertex set ${\displaystyle [k]}$. A single vertex can always be given a new color so that the graph is properly colored, thus the bounded difference condition ${\displaystyle |Y_{i}-Y_{i-1}|\leq 1}$ is satisfied. Now apply the Azuma's inequality for the martingale ${\displaystyle Y_{1},\ldots ,Y_{n}}$ with respect to ${\displaystyle X_{1},\ldots ,X_{n}}$.
${\displaystyle \square }$

For ${\displaystyle t=\omega (1)}$, the theorem states that the chromatic number of a random graph is tightly concentrated around its mean. The proof gives no clue as to where the mean is. This actually shows how powerful the martingale inequalities are: we can prove that a distribution is concentrated to its expectation without actually knowing the expectation.

### Hoeffding's Inequality

The following theorem states the so-called Hoeffding's inequality. It is a generalized version of the Chernoff bounds. Recall that the Chernoff bounds hold for the sum of independent trials. When the random variables are not trials, the Hoeffding's inequality is useful, since it holds for the sum of any independent random variables whose ranges are bounded.

 Hoeffding's inequality Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$, where ${\displaystyle X_{1},\ldots ,X_{n}}$ are independent random variables with ${\displaystyle a_{i}\leq X_{i}\leq b_{i}}$ for each ${\displaystyle 1\leq i\leq n}$. Let ${\displaystyle \mu =\mathbf {E} [X]}$. Then ${\displaystyle \Pr[|X-\mu |\geq t]\leq 2\exp \left(-{\frac {t^{2}}{2\sum _{i=1}^{n}(b_{i}-a_{i})^{2}}}\right).}$
Proof.
 Define the Doob martingale sequence ${\displaystyle Y_{i}=\mathbf {E} \left[\sum _{j=1}^{n}X_{j}\,{\Big |}\,X_{1},\ldots ,X_{i}\right]}$. Obviously ${\displaystyle Y_{0}=\mu }$ and ${\displaystyle Y_{n}=X}$. {\displaystyle {\begin{aligned}|Y_{i}-Y_{i-1}|&=\left|\mathbf {E} \left[\sum _{j=1}^{n}X_{j}\,{\Big |}\,X_{0},\ldots ,X_{i}\right]-\mathbf {E} \left[\sum _{j=1}^{n}X_{j}\,{\Big |}\,X_{0},\ldots ,X_{i-1}\right]\right|\\&=\left|\sum _{j=1}^{i}X_{i}+\sum _{j=i+1}^{n}\mathbf {E} [X_{j}]-\sum _{j=1}^{i-1}X_{i}-\sum _{j=i}^{n}\mathbf {E} [X_{j}]\right|\\&=\left|X_{i}-\mathbf {E} [X_{i}]\right|\\&\leq b_{i}-a_{i}\end{aligned}}} Apply Azuma's inequality for the martingale ${\displaystyle Y_{0},\ldots ,Y_{n}}$ with respect to ${\displaystyle X_{1},\ldots ,X_{n}}$, the Hoeffding's inequality is proved.
${\displaystyle \square }$

## The Bounded Difference Method

Combining Azuma's inequality with the construction of Doob martingales, we have the powerful Bounded Difference Method for concentration of measures.

### For arbitrary random variables

Given a sequence of random variables ${\displaystyle X_{1},\ldots ,X_{n}}$ and a function ${\displaystyle f}$. The Doob sequence constructs a martingale from them. Combining this construction with Azuma's inequality, we can get a very powerful theorem called "the method of averaged bounded differences" which bounds the concentration for arbitrary function on arbitrary random variables (not necessarily a martingale).

 Theorem (Method of averaged bounded differences) Let ${\displaystyle {\boldsymbol {X}}=(X_{1},\ldots ,X_{n})}$ be arbitrary random variables and let ${\displaystyle f}$ be a function of ${\displaystyle X_{0},X_{1},\ldots ,X_{n}}$ satisfying that, for all ${\displaystyle 1\leq i\leq n}$, ${\displaystyle |\mathbf {E} [f({\boldsymbol {X}})\mid X_{1},\ldots ,X_{i}]-\mathbf {E} [f({\boldsymbol {X}})\mid X_{1},\ldots ,X_{i-1}]|\leq c_{i},}$ Then {\displaystyle {\begin{aligned}\Pr \left[|f({\boldsymbol {X}})-\mathbf {E} [f({\boldsymbol {X}})]|\geq t\right]\leq 2\exp \left(-{\frac {t^{2}}{2\sum _{i=1}^{n}c_{i}^{2}}}\right).\end{aligned}}}
Proof.
 Define the Doob Martingale sequence ${\displaystyle Y_{0},Y_{1},\ldots ,Y_{n}}$ by setting ${\displaystyle Y_{0}=\mathbf {E} [f(X_{1},\ldots ,X_{n})]}$ and, for ${\displaystyle 1\leq i\leq n}$, ${\displaystyle Y_{i}=\mathbf {E} [f(X_{1},\ldots ,X_{n})\mid X_{1},\ldots ,X_{i}]}$. Then the above theorem is a restatement of the Azuma's inequality holding for ${\displaystyle Y_{0},Y_{1},\ldots ,Y_{n}}$.
${\displaystyle \square }$

### For independent random variables

The condition of bounded averaged differences is usually hard to check. This severely limits the usefulness of the method. To overcome this, we introduce a property which is much easier to check, called the Lipschitz condition.

 Definition (Lipschitz condition) A function ${\displaystyle f(x_{1},\ldots ,x_{n})}$ satisfies the Lipschitz condition, if for any ${\displaystyle x_{1},\ldots ,x_{n}}$ and any ${\displaystyle y_{i}}$, {\displaystyle {\begin{aligned}|f(x_{1},\ldots ,x_{i-1},x_{i},x_{i+1},\ldots ,x_{n})-f(x_{1},\ldots ,x_{i-1},y_{i},x_{i+1},\ldots ,x_{n})|\leq 1.\end{aligned}}}

In other words, the function satisfies the Lipschitz condition if an arbitrary change in the value of any one argument does not change the value of the function by more than 1.

The diference of 1 can be replaced by arbitrary constants, which gives a generalized version of Lipschitz condition.

 Definition (Lipschitz condition, general version) A function ${\displaystyle f(x_{1},\ldots ,x_{n})}$ satisfies the Lipschitz condition with constants ${\displaystyle c_{i}}$, ${\displaystyle 1\leq i\leq n}$, if for any ${\displaystyle x_{1},\ldots ,x_{n}}$ and any ${\displaystyle y_{i}}$, {\displaystyle {\begin{aligned}|f(x_{1},\ldots ,x_{i-1},x_{i},x_{i+1},\ldots ,x_{n})-f(x_{1},\ldots ,x_{i-1},y_{i},x_{i+1},\ldots ,x_{n})|\leq c_{i}.\end{aligned}}}

The following "method of bounded differences" can be developed for functions satisfying the Lipschitz condition. Unfortunately, in order to imply the condition of averaged bounded differences from the Lipschitz condition, we have to restrict the method to independent random variables.

 Corollary (Method of bounded differences) Let ${\displaystyle {\boldsymbol {X}}=(X_{1},\ldots ,X_{n})}$ be ${\displaystyle n}$ independent random variables and let ${\displaystyle f}$ be a function satisfying the Lipschitz condition with constants ${\displaystyle c_{i}}$, ${\displaystyle 1\leq i\leq n}$. Then {\displaystyle {\begin{aligned}\Pr \left[|f({\boldsymbol {X}})-\mathbf {E} [f({\boldsymbol {X}})]|\geq t\right]\leq 2\exp \left(-{\frac {t^{2}}{2\sum _{i=1}^{n}c_{i}^{2}}}\right).\end{aligned}}}
Proof.
 For convenience, we denote that ${\displaystyle {\boldsymbol {X}}_{[i,j]}=(X_{i},X_{i+1},\ldots ,X_{j})}$ for any ${\displaystyle 1\leq i\leq j\leq n}$. We first show that the Lipschitz condition with constants ${\displaystyle c_{i}}$, ${\displaystyle 1\leq i\leq n}$, implies another condition called the averaged Lipschitz condition (ALC): for any ${\displaystyle a_{i},b_{i}}$, ${\displaystyle 1\leq i\leq n}$, ${\displaystyle \left|\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a_{i}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=b_{i}\right]\right|\leq c_{i}.}$ And this condition implies the averaged bounded difference condition: for all ${\displaystyle 1\leq i\leq n}$, ${\displaystyle \left|\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]}\right]\right|\leq c_{i}.}$ Then by applying the method of averaged bounded differences, the corollary can be proved. For any ${\displaystyle a}$, by the law of total expectation, {\displaystyle {\begin{aligned}&\quad \,\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a\right]\\&=\sum _{a_{i+1},\ldots ,a_{n}}\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a,{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\cdot \Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a\right]\\&=\sum _{a_{i+1},\ldots ,a_{n}}\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a,{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\cdot \Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\qquad ({\mbox{independence}})\\&=\sum _{a_{i+1},\ldots ,a_{n}}f({\boldsymbol {X}}_{[1,i-1]},a,{\boldsymbol {a}}_{[i+1,n]})\cdot \Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right].\end{aligned}}} Let ${\displaystyle a=a_{i}}$ and ${\displaystyle b_{i}}$, and take the diference. Then {\displaystyle {\begin{aligned}&\quad \,\left|\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a_{i}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=b_{i}\right]\right|\\&=\left|\sum _{a_{i+1},\ldots ,a_{n}}\left(f({\boldsymbol {X}}_{[1,i-1]},a_{i},{\boldsymbol {a}}_{[i+1,n]})-f({\boldsymbol {X}}_{[1,i-1]},b_{i},{\boldsymbol {a}}_{[i+1,n]})\right)\Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\right|\\&\leq \sum _{a_{i+1},\ldots ,a_{n}}\left|f({\boldsymbol {X}}_{[1,i-1]},a_{i},{\boldsymbol {a}}_{[i+1,n]})-f({\boldsymbol {X}}_{[1,i-1]},b_{i},{\boldsymbol {a}}_{[i+1,n]})\right|\Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\\&\leq \sum _{a_{i+1},\ldots ,a_{n}}c_{i}\Pr \left[{\boldsymbol {X}}_{[i+1,n]}={\boldsymbol {a}}_{[i+1,n]}\right]\qquad ({\mbox{Lipschitz condition}})\\&=c_{i}.\end{aligned}}} Thus, the Lipschitz condition is transformed to the ALC. We then deduce the averaged bounded difference condition from ALC. By the law of total expectation, ${\displaystyle \mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]}\right]=\sum _{a}\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a\right]\cdot \Pr[X_{i}=a\mid {\boldsymbol {X}}_{[1,i-1]}].}$ We can trivially write ${\displaystyle \mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]}$ as ${\displaystyle \mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]=\sum _{a}\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]\cdot \Pr \left[X_{i}=a\mid {\boldsymbol {X}}_{[1,i-1]}\right].}$ Hence, the difference is {\displaystyle {\begin{aligned}&\quad \left|\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]}\right]\right|\\&=\left|\sum _{a}\left(\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a\right]\right)\cdot \Pr \left[X_{i}=a\mid {\boldsymbol {X}}_{[1,i-1]}\right]\right|\\&\leq \sum _{a}\left|\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i]}\right]-\mathbf {E} \left[f({\boldsymbol {X}})\mid {\boldsymbol {X}}_{[1,i-1]},X_{i}=a\right]\right|\cdot \Pr \left[X_{i}=a\mid {\boldsymbol {X}}_{[1,i-1]}\right]\\&\leq \sum _{a}c_{i}\Pr \left[X_{i}=a\mid {\boldsymbol {X}}_{[1,i-1]}\right]\qquad ({\mbox{due to ALC}})\\&=c_{i}.\end{aligned}}} The averaged bounded diference condition is implied. Applying the method of averaged bounded diferences, the corollary follows.
${\displaystyle \square }$

### Applications

#### Occupancy problem

Throwing ${\displaystyle m}$ balls uniformly and independently at random to ${\displaystyle n}$ bins, we ask for the occupancies of bins by the balls. In particular, we are interested in the number of empty bins.

This problem can be described equivalently as follows. Let ${\displaystyle f:[m]\rightarrow [n]}$ be a uniform random function from ${\displaystyle [m]\rightarrow [n]}$. We ask for the number of ${\displaystyle i\in [n]}$ that ${\displaystyle f^{-1}(i)}$ is empty.

For any ${\displaystyle i\in [n]}$, let ${\displaystyle X_{i}}$ indicate the emptiness of bin ${\displaystyle i}$. Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$ be the number of empty bins.

${\displaystyle \mathbf {E} [X_{i}]=\Pr[{\mbox{bin }}i{\mbox{ is empty}}]=\left(1-{\frac {1}{n}}\right)^{m}.}$

By the linearity of expectation,

${\displaystyle \mathbf {E} [X]=\sum _{i=1}^{n}\mathbf {E} [X_{i}]=n\left(1-{\frac {1}{n}}\right)^{m}.}$

We want to know how ${\displaystyle X}$ deviates from this expectation. The complication here is that ${\displaystyle X_{i}}$ are not independent. So we alternatively look at a sequence of independent random variables ${\displaystyle Y_{1},\ldots ,Y_{m}}$, where ${\displaystyle Y_{j}\in [n]}$ represents the bin into which the ${\displaystyle j}$th ball falls. Clearly ${\displaystyle X}$ is function of ${\displaystyle Y_{1},\ldots ,Y_{m}}$.

We than observe that changing the value of any ${\displaystyle Y_{i}}$ can change the value of ${\displaystyle X}$ by at most 1, because one ball can affect the emptiness of at most one bin. Thus as a function of independent random variables ${\displaystyle Y_{1},\ldots ,Y_{m}}$, ${\displaystyle X}$ satisfies the Lipschitz condition. Apply the method of bounded differences, it holds that

${\displaystyle \Pr \left[\left|X-n\left(1-{\frac {1}{n}}\right)^{m}\right|\geq t{\sqrt {m}}\right]=\Pr[|X-\mathbf {E} [X]|\geq t{\sqrt {m}}]\leq 2e^{-t^{2}/2}}$

Thus, for sufficiently large ${\displaystyle n}$ and ${\displaystyle m}$, the number of empty bins is tightly concentrated around ${\displaystyle n\left(1-{\frac {1}{n}}\right)^{m}\approx {\frac {n}{e^{m/n}}}}$

#### Pattern Matching

Let ${\displaystyle {\boldsymbol {X}}=(X_{1},\ldots ,X_{n})}$ be a sequence of characters chosen independently and uniformly at random from an alphabet ${\displaystyle \Sigma }$, where ${\displaystyle m=|\Sigma |}$. Let ${\displaystyle \pi \in \Sigma ^{k}}$ be an arbitrarily fixed string of ${\displaystyle k}$ characters from ${\displaystyle \Sigma }$, called a pattern. Let ${\displaystyle Y}$ be the number of occurrences of the pattern ${\displaystyle \pi }$ as a substring of the random string ${\displaystyle X}$.

By the linearity of expectation, it is obvious that

${\displaystyle \mathbf {E} [Y]=(n-k+1)\left({\frac {1}{m}}\right)^{k}.}$

We now look at the concentration of ${\displaystyle Y}$. The complication again lies in the dependencies between the matches. Yet we will see that ${\displaystyle Y}$ is well tightly concentrated around its expectation if ${\displaystyle k}$ is relatively small compared to ${\displaystyle n}$.

For a fixed pattern ${\displaystyle \pi }$, the random variable ${\displaystyle Y}$ is a function of the independent random variables ${\displaystyle (X_{1},\ldots ,X_{n})}$. Any character ${\displaystyle X_{i}}$ participates in no more than ${\displaystyle k}$ matches, thus changing the value of any ${\displaystyle X_{i}}$ can affect the value of ${\displaystyle Y}$ by at most ${\displaystyle k}$. ${\displaystyle Y}$ satisfies the Lipschitz condition with constant ${\displaystyle k}$. Apply the method of bounded differences,

${\displaystyle \Pr \left[\left|Y-{\frac {n-k+1}{m^{k}}}\right|\geq tk{\sqrt {n}}\right]=\Pr \left[\left|Y-\mathbf {E} [Y]\right|\geq tk{\sqrt {n}}\right]\leq 2e^{-t^{2}/2}}$

#### Combining unit vectors

Let ${\displaystyle u_{1},\ldots ,u_{n}}$ be ${\displaystyle n}$ unit vectors from some normed space. That is, ${\displaystyle \|u_{i}\|=1}$ for any ${\displaystyle 1\leq i\leq n}$, where ${\displaystyle \|\cdot \|}$ denote the vector norm (e.g. ${\displaystyle \ell _{1},\ell _{2},\ell _{\infty }}$) of the space.

Let ${\displaystyle \epsilon _{1},\ldots ,\epsilon _{n}\in \{-1,+1\}}$ be independently chosen and ${\displaystyle \Pr[\epsilon _{i}=-1]=\Pr[\epsilon _{i}=1]=1/2}$.

Let

${\displaystyle v=\epsilon _{1}u_{1}+\cdots +\epsilon _{n}u_{n},}$

and

${\displaystyle X=\|v\|.}$

This kind of construction is very useful in combinatorial proofs of metric problems. We will show that by this construction, the random variable ${\displaystyle X}$ is well concentrated around its mean.

${\displaystyle X}$ is a function of independent random variables ${\displaystyle \epsilon _{1},\ldots ,\epsilon _{n}}$. By the triangle inequality for norms, it is easy to verify that changing the sign of a unit vector ${\displaystyle u_{i}}$ can only change the value of ${\displaystyle X}$ for at most 2, thus ${\displaystyle X}$ satisfies the Lipschitz condition with constant 2. The concentration result follows by applying the method of bounded differences:

${\displaystyle \Pr[|X-\mathbf {E} [X]|\geq 2t{\sqrt {n}}]\leq 2e^{-t^{2}/2}.}$