Conditional Expectations

The conditional expectation of a random variable $\displaystyle{ Y }$ with respect to an event $\displaystyle{ \mathcal{E} }$ is defined by

$\displaystyle{ \mathbf{E}[Y\mid \mathcal{E}]=\sum_{y}y\Pr[Y=y\mid\mathcal{E}]. }$

In particular, if the event $\displaystyle{ \mathcal{E} }$ is $\displaystyle{ X=a }$, the conditional expectation

$\displaystyle{ \mathbf{E}[Y\mid X=a] }$

defines a function

$\displaystyle{ f(a)=\mathbf{E}[Y\mid X=a]. }$

Thus, $\displaystyle{ \mathbf{E}[Y\mid X] }$ can be regarded as a random variable $\displaystyle{ f(X) }$.

Example
Suppose that we uniformly sample a human from all human beings. Let $\displaystyle{ Y }$ be his/her height, and let $\displaystyle{ X }$ be the country where he/she is from. For any country $\displaystyle{ a }$, $\displaystyle{ \mathbf{E}[Y\mid X=a] }$ gives the average height of that country. And $\displaystyle{ \mathbf{E}[Y\mid X] }$ is the random variable which can be defined in either ways:
• We choose a human uniformly at random from all human beings, and $\displaystyle{ \mathbf{E}[Y\mid X] }$ is the average height of the country where he/she comes from.
• We choose a country at random with a probability proportional to its population, and $\displaystyle{ \mathbf{E}[Y\mid X] }$ is the average height of the chosen country.

The following proposition states some fundamental facts about conditional expectation.

 Proposition (fundamental facts about conditional expectation) Let $\displaystyle{ X,Y }$ and $\displaystyle{ Z }$ be arbitrary random variables. Let $\displaystyle{ f }$ and $\displaystyle{ g }$ be arbitrary functions. Then $\displaystyle{ \mathbf{E}[X]=\mathbf{E}[\mathbf{E}[X\mid Y]] }$. $\displaystyle{ \mathbf{E}[X\mid Z]=\mathbf{E}[\mathbf{E}[X\mid Y,Z]\mid Z] }$. $\displaystyle{ \mathbf{E}[\mathbf{E}[f(X)g(X,Y)\mid X]]=\mathbf{E}[f(X)\cdot \mathbf{E}[g(X,Y)\mid X]] }$.

The proposition can be formally verified by computing these expectations. Although these equations look formal, the intuitive interpretations to them are very clear.

The first equation:

$\displaystyle{ \mathbf{E}[X]=\mathbf{E}[\mathbf{E}[X\mid Y]] }$

says that there are two ways to compute an average. Suppose again that $\displaystyle{ X }$ is the height of a uniform random human and $\displaystyle{ Y }$ is the country where he/she is from. There are two ways to compute the average human height: one is to directly average over the heights of all humans; the other is that first compute the average height for each country, and then average over these heights weighted by the populations of the countries.

The second equation:

$\displaystyle{ \mathbf{E}[X\mid Z]=\mathbf{E}[\mathbf{E}[X\mid Y,Z]\mid Z] }$

is the same as the first one, restricted to a particular subspace. As the previous example, inaddition to the height $\displaystyle{ X }$ and the country $\displaystyle{ Y }$, let $\displaystyle{ Z }$ be the gender of the individual. Thus, $\displaystyle{ \mathbf{E}[X\mid Z] }$ is the average height of a human being of a given sex. Again, this can be computed either directly or on a country-by-country basis.

The third equation:

$\displaystyle{ \mathbf{E}[\mathbf{E}[f(X)g(X,Y)\mid X]]=\mathbf{E}[f(X)\cdot \mathbf{E}[g(X,Y)\mid X]] }$.

looks obscure at the first glance, especially when considering that $\displaystyle{ X }$ and $\displaystyle{ Y }$ are not necessarily independent. Nevertheless, the equation follows the simple fact that conditioning on any $\displaystyle{ X=a }$, the function value $\displaystyle{ f(X)=f(a) }$ becomes a constant, thus can be safely taken outside the expectation due to the linearity of expectation. For any value $\displaystyle{ X=a }$,

$\displaystyle{ \mathbf{E}[f(X)g(X,Y)\mid X=a]=\mathbf{E}[f(a)g(X,Y)\mid X=a]=f(a)\cdot \mathbf{E}[g(X,Y)\mid X=a]. }$

The proposition holds in more general cases when $\displaystyle{ X, Y }$ and $\displaystyle{ Z }$ are a sequence of random variables.

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. And remember: gambling is bad!

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\gt 0 }$, \displaystyle{ \begin{align} \mathbf{E}[X_{i}\mid X_0,\ldots,X_{i-1}]=X_{i-1}. \end{align} }

Examples

coin flips
A fair coin is flipped for a number of times. Let $\displaystyle{ Z_j\in\{-1,1\} }$ denote the outcome of the $\displaystyle{ j }$th flip. Let
$\displaystyle{ X_0=0\quad \mbox{ and } \quad X_i=\sum_{j\le i}Z_j }$.
The random variables $\displaystyle{ X_0,X_1,\ldots }$ defines a martingale.
Proof
We first observe that $\displaystyle{ \mathbf{E}[X_i\mid X_0,\ldots,X_{i-1}] = \mathbf{E}[X_i\mid X_{i-1}] }$, which intuitively says that the next number of HEADs depends only on the current number of HEADs. This property is also called the Markov property in statistic processes.
\displaystyle{ \begin{align} \mathbf{E}[X_i\mid X_0,\ldots,X_{i-1}] &= \mathbf{E}[X_i\mid X_{i-1}]\\ &= \mathbf{E}[X_{i-1}+Z_{i}\mid X_{i-1}]\\ &= \mathbf{E}[X_{i-1}\mid X_{i-1}]+\mathbf{E}[Z_{i}\mid X_{i-1}]\\ &= X_{i-1}+\mathbf{E}[Z_{i}\mid X_{i-1}]\\ &= X_{i-1}+\mathbf{E}[Z_{i}] &\quad (\mbox{independence of coin flips})\\ &= X_{i-1} \end{align} }
Polya's urn scheme
Consider an urn (just a container) that initially contains $\displaystyle{ b }$ balck balls and $\displaystyle{ w }$ white balls. At each step, we uniformly select a ball from the urn, and replace the ball with $\displaystyle{ c }$ balls of the same color. Let $\displaystyle{ X_0=b/(b+w) }$, and $\displaystyle{ X_i }$ be the fraction of black balls in the urn after the $\displaystyle{ i }$th step. The sequence $\displaystyle{ X_0,X_1,\ldots }$ is a martingale.
edge exposure in a random graph
Consider a random graph $\displaystyle{ G }$ generated as follows. Let $\displaystyle{ [n] }$ be the set of vertices, and let $\displaystyle{ [m]={[n]\choose 2} }$ be the set of all possible edges. For convenience, we enumerate these potential edges by $\displaystyle{ e_1,\ldots, e_m }$. For each potential edge $\displaystyle{ e_j }$, we independently flip a fair coin to decide whether the edge $\displaystyle{ e_j }$ appears in $\displaystyle{ G }$. Let $\displaystyle{ I_j }$ be the random variable that indicates whether $\displaystyle{ e_j\in G }$. We are interested in some graph-theoretical parameter, say chromatic number, of the random graph $\displaystyle{ G }$. Let $\displaystyle{ \chi(G) }$ be the chromatic number of $\displaystyle{ G }$. Let $\displaystyle{ X_0=\mathbf{E}[\chi(G)] }$, and for each $\displaystyle{ i\ge 1 }$, let $\displaystyle{ X_i=\mathbf{E}[\chi(G)\mid I_1,\ldots,I_{i}] }$, namely, the expected chromatic number of the random graph after fixing the first $\displaystyle{ i }$ edges. This process is called edges exposure of a random graph, as we "exposing" the edges one by one in a random grpah.
File:Edge-exposure.png
As shown by the above figure, the sequence $\displaystyle{ X_0,X_1,\ldots,X_m }$ is a martingale. In particular, $\displaystyle{ X_0=\mathbf{E}[\chi(G)] }$, and $\displaystyle{ X_m=\chi(G) }$. The martingale $\displaystyle{ X_0,X_1,\ldots,X_m }$ moves from no information to full information (of the random graph $\displaystyle{ G }$) in small steps.

It is nontrivial to formally verify that the edge exposure sequence for a random graph is a martingale. However, we will later see that this construction can be put into a more general context.

Generalizations

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\ge 0 }$, the following conditions hold: $\displaystyle{ Y_i }$ is a function of $\displaystyle{ X_0,X_1,\ldots,X_i }$; \displaystyle{ \begin{align} \mathbf{E}[Y_{i+1}\mid X_0,\ldots,X_{i}]=Y_{i}. \end{align} }

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

We introduce a martingale tail inequality, called Azuma's inequality.

 Azuma's Inequality Let $\displaystyle{ X_0,X_1,\ldots }$ be a martingale such that, for all $\displaystyle{ k\ge 1 }$, $\displaystyle{ |X_{k}-X_{k-1}|\le c_k, }$ Then \displaystyle{ \begin{align} \Pr\left[|X_n-X_0|\ge t\right]\le 2\exp\left(-\frac{t^2}{2\sum_{k=1}^nc_k^2}\right). \end{align} }

Before formally proving this theorem, some comments are in order. First, unlike the Chernoff bounds, there is no assumption of independence. This shows the power of martingale inequalities.

Second, the condition that

$\displaystyle{ |X_{k}-X_{k-1}|\le c_k }$

is central to the proof. This condition is sometimes called the bounded difference condition. If we think of the martingale $\displaystyle{ X_0,X_1,\ldots }$ as a process evolving through time, where $\displaystyle{ X_i }$ gives some measurement at time $\displaystyle{ i }$, the bounded difference condition states that the process does not make big jumps. The Azuma's inequality says that if so, then 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\ge 1 }$, $\displaystyle{ |X_{k}-X_{k-1}|\le c, }$ Then \displaystyle{ \begin{align} \Pr\left[|X_n-X_0|\ge ct\sqrt{n}\right]\le 2 e^{-t^2/2}. \end{align} }

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\ge 1 }$, $\displaystyle{ |Y_{k}-Y_{k-1}|\le c_k, }$ Then \displaystyle{ \begin{align} \Pr\left[|Y_n-Y_0|\ge t\right]\le 2\exp\left(-\frac{t^2}{2\sum_{k=1}^nc_k^2}\right). \end{align} }

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|\ge t }$, we first bound the upper tail $\displaystyle{ \Pr[X_n-X_0\ge 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\ge 1 }$, let

$\displaystyle{ Y_i=X_i-X_{i-1}. }$

It holds that

\displaystyle{ \begin{align} \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{align} }

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{align} 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{align} }

We then only need to upper bound the probability of the event $\displaystyle{ Z_n\ge t }$.

Apply Markov's inequality to the moment generating function

The event $\displaystyle{ Z_n\ge t }$ is equivalent to that $\displaystyle{ e^{\lambda Z_n}\ge e^{\lambda t} }$ for $\displaystyle{ \lambda\gt 0 }$. Apply Markov's inequality, we have

\displaystyle{ \begin{align} \Pr\left[Z_n\ge t\right] &=\Pr\left[e^{\lambda Z_n}\ge e^{\lambda t}\right]\\ &\le \frac{\mathbf{E}\left[e^{\lambda Z_n}\right]}{e^{\lambda t}}. \end{align} }

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{align} \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{align} }

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|\le c }$. Then for $\displaystyle{ \lambda\gt 0 }$, $\displaystyle{ \mathbf{E}[e^{\lambda X}]\le e^{\lambda^2c^2/2}. }$
Proof.
 Observe that for $\displaystyle{ \lambda\gt 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{align} e^{\lambda X} &\le \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{align} } Since $\displaystyle{ \mathbf{E}[X]=0 }$, we have \displaystyle{ \begin{align} \mathbf{E}[e^{\lambda X}] &\le \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{align} } By expanding both sides as Taylor's series, it can be verified that $\displaystyle{ \frac{e^{\lambda c}+e^{-\lambda c}}{2}\le e^{\lambda^2c^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})|\le 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}]\le e^{\lambda^2c_n^2/2}. }$

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

\displaystyle{ \begin{align} \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]\\ &\le \mathbf{E}\left[e^{\lambda Z_{n-1}}\cdot e^{\lambda^2c_n^2/2}\right]\\ &= e^{\lambda^2c_n^2/2}\cdot\mathbf{E}\left[e^{\lambda Z_{n-1}}\right] . \end{align} }

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

\displaystyle{ \begin{align} \mathbf{E}\left[e^{\lambda Z_n}\right] &\le \prod_{k=1}^n e^{\lambda^2c_k^2/2}\\ &= \exp\left(\lambda^2\sum_{k=1}^n c_k^2/2\right). \end{align} }

Go back to the Markov's inequality,

\displaystyle{ \begin{align} \Pr\left[Z_n\ge t\right] &\le \frac{\mathbf{E}\left[e^{\lambda Z_n}\right]}{e^{\lambda t}}\\ &\le \exp\left(\lambda^2\sum_{k=1}^n c_k^2/2-\lambda t\right). \end{align} }

We then only need to choose a proper $\displaystyle{ \lambda\gt 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{align} \Pr\left[X_n-X_0\ge t\right] &=\Pr\left[Z_n\ge t\right]\\ &\le \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{align} }

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\le i\le 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\le i\le 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{align} \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{align} }

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{align} \Pr\left[|\chi(G)-\mathbf{E}[\chi(G)]|\ge t\sqrt{n}\right]\le 2e^{-t^2/2}. \end{align} }
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}|\le 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}^nX_i }$, where $\displaystyle{ X_1,\ldots,X_n }$ are independent random variables with $\displaystyle{ a_i\le X_i\le b_i }$ for each $\displaystyle{ 1\le i\le n }$. Let $\displaystyle{ \mu=\mathbf{E}[X] }$. Then $\displaystyle{ \Pr[|X-\mu|\ge t]\le 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{align} |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|\\ &\le b_i-a_i \end{align} } 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 }$