1.13 Martingales

1.13.1 Martingales

Definition 1.13.1 (Martingale).

A sequence of random variables Z0,Z1,… is a martingale with respect to another sequence X0,X1,… if for all n≥0, the following conditions hold:

  • •

    Zn is a function of X0,…,Xn.

  • •

    𝔼[|Zn|]<∞.

  • •

    𝔼[Zn+1∣X0,…,Xn]=Zn.

A sequence of random variables Z0,Z1,… is called a martingale when it is a martingale with respect to itself, that is

  • •

    𝔼[|Zn|]<∞.

  • •

    𝔼[Zn+1∣Z0,…,Zn]=Zn.

Example 1.13.2 (Martingale from Fair Games).

Consider a gambler who plays a sequence of fair games. Let Xi be the winning on the ith game, that is either +1 or −1, and Zi be the gambler’s total winning of the first i games. Since Z0=0 and

Zi=Z0+∑j∈[1,i]Xj,

then by linearity of expectation,

𝔼[Zi+1∣X1,…,Xi]=Zi+𝔼[Xi+1∣X1,…,Xi]=Zi,

where the second equality holds as 𝔼[Xi+1∣X1,…,Xi]=0 on any input of X1,…,Xi by fair game.

Thus, Z1,…,Zn is a martingale with respect to the sequence X1,…,Xn.

Exercise 1.13.3 (Exercise 13.2 [MU17]).

Let X0,X1,… be a sequence of random variables, and let Si=∑j∈[1,i]Xj. Show that S0,S1,… is a martingale with respect to X0,X1,…, then for all i≠j, 𝔼[Xi⁢Xj]=0.

Proof.

If S0,S1,… is a martingale with respect to X0,X1,…, then by definition 1.13.1,

Si=𝔼[Si+1∣X0,…,Xi]=Si+𝔼[Xi+1∣X0,…,Xi],

where the second equality holds by linearity of expectation, then for all i≥0,

𝔼[Xi+1∣X0,…,Xi]=0.

Hence, on an i≥1 and any j<i, conditioned that Xj=x,

𝔼[Xi∣Xj=x]=𝔼[𝔼[Xi∣X0,…,Xj=x,…,Xi−1]]=0.

Therefore, we conclude the proof by

𝔼[Xi⁢Xj] =𝔼[𝔼[Xi⁢Xj∣Xj]]
=∑x∈Ω𝔼[Xi⁢Xj∣Xj=x]⁢Pr⁡[Xj=x]
=∑x∈Ωx⁢𝔼[Xi∣Xj=x]⁢Pr⁡[Xj=x]=0.

∎

Exercise 1.13.4 (Exercise 13.1 [MU17]).

Show that if Z0,Z1,… is a martingale with respect to X0,X1,…, then it is a martingale with respect to itself.

Proof.

By definition 1.2.6 and lemma 1.2.7, we use the tower property

𝔼[𝔼[Y∣X]∣Z]=𝔼[Y∣Z]

for random variables X,Y,Z such that Z is determined by X, or X carries at least as much information as Z, or Z can be obtained from X from some function.

Since Z0,…,Zn is a martingale with respect to X0,…,Xn, then by definition 1.13.1, for all i∈[0,n],

Zi=𝔼[Zi+1∣X0,…,Xi].

By the prior fact,

𝔼[𝔼[Zi+1∣X0,…,Xi]∣Z0,…,Zi]=𝔼[Zi+1∣Z0,…,Zi].

Yet by definition 1.13.1,

𝔼[𝔼[Zi+1∣X0,…,Xi]∣Z0,…,Zi]=𝔼[Zi∣Z0,…,Zi]=Zi.

Therefore we conclude by 𝔼[Zi+1∣Z0,…,Zi]=Zi. ∎

Exercise 1.13.5 (Exercise 13.4 [MU17]).

Let X1,X2,… be independent identically distributed random variables with expectation 0 and variance σ2<∞. Let

Zn=(∑i∈[1,n]Xi)2−n⁢σ2.

Show that Z1,Z2,… is a martingale.

Proof.

Let Yn=∑i∈[1,n]Xi, then Zn=Yn2−n⁢σ2. Since 𝔼[Xi]=0, then σ2=𝔼[Xi2]. We show as follows: For n≥1,

𝔼[Zn+1∣X1,…,Xn] =𝔼[Zn+Xn+12+2⁢Xn+1⁢Yn−σ2∣X1,…,Xn]
=Zn+𝔼[Xn+12]+2⁢𝔼[Xn+1⁢Yn]−σ2
=Zn+𝔼[Xn+12]+2⁢𝔼[Xn+1]⁢𝔼[Yn]−σ2
=Zn+𝔼[Xn+12]−σ2=Zn,

where the second and the third equality are from the independence, and the last two equalities are from expectation being 0. By 1.13.4, we conclude the proof. ∎

Definition 1.13.6 (Doob Martingale [Doo40]).

Let X0,…,Xn be a sequence of random variables, and Y be a random variable depending on X0,…,Xn with 𝔼[|Y|]<∞, then for i∈[0,n],

Zi=𝔼[Y∣X0,…,Xi]

gives a martingale with respect to X0,…,Xn, as

𝔼[Zi+1∣X0,…,Xi] =𝔼[𝔼[Y∣X0,…,Xi+1]∣X0,…,Xi]
=𝔼[Y∣X0,…,Xi]
=Zi,

where the second equality holds by lemma 1.2.7 and definition 1.2.6.

Remark 1.13.7.

One can view the Doob Martingale as a sequence of refined predictions to Y, where each element Zi is the expectation of Y when the values of X0,…,Xi are known. Hence, the refined predictions gradually using more information on the values of the random variables X0,…,Xn.

Exercise 1.13.8 (Exercise 13.3 [MU17]).

Let X0=0 and for j≥0, Xj+1 is chosen uniformly over real interval [Xj,1]. Show that, for k≥0, the sequence Yk=2k⁢(1−Xk) is a martingale.

Proof.

Since Yk+1 depends only on Yk, then

𝔼[Yk+1∣Y0,…,Yk]=𝔼[Yk+1∣Yk].

Moreover, since 𝔼[Xk+1∣Xk]=(1+Xk)/2, then

𝔼[Yk+1∣Xk]=𝔼[2k+1⁢(1−Xk+1)∣Xk]=2k+1−2k+1⁢𝔼[Xk+1∣Xk]=2k⁢(1−Xk)=Yk.

By 𝔼[Yk∣Yk]=Yk, we show that

𝔼[𝔼[Yk+1∣Xk]∣Yk]=𝔼[Yk+1∣Yk]=Yk,

which concludes the proof. ∎

Lemma 1.13.9.

If Z0,Z1,… is a martingale with respect to X0,X1,…, then 𝔼[Zn]=𝔼[Z0] for any n≥0.

Proof.

By definition 1.13.1, for any n≥1

𝔼[Zn∣X0,…,Xn−1]=Zn−1.

Given that

𝔼[Zn−1∣X0,…,Xn−2]=Zn−2,

we have

Zn−2 =𝔼[Zn−1∣X0,…,Xn−2]
=𝔼[𝔼[Zn∣X0,…,Xn−1]∣X0,…,Xn−2]
=𝔼[Zn∣X0,…,Xn−2].

By induction, we have Z0=𝔼[Zn∣X0], then

𝔼[Z0]=𝔼[𝔼[Zn∣X0]]=𝔼[Zn],

which concludes the proof. ∎

Example 1.13.10 (Galton-Watson Process).

The Galton-Watson process was used in theorem 1.6.60, but was originally used to statistically investigate the extinction of family names. Let Gt be the random variable for the individuals in the tth generation, and Xt,k be the number of offspring of the kth individual in the tth generation. Each individual gives birth to offspring independently, and their numbers of offspring are identically distributed. Hence,

Gt=∑k∈[1,Gt−1]Xt−1,k,

and let μ=𝔼[Xt,k]. By linearity of expectation,

𝔼[Gt+1∣G1,…,Gt]=μ⁢Gt.

Let Mt=μ−t⋅Gt, then

𝔼[Mt+1∣G1,…,Gt]=𝔼[μ−(t+1)⋅Gt+1∣G1,…,Gt]=μ−t⋅Gt=Mt,

and we have

𝔼[𝔼[Mt+1∣G1,…,Gt]∣M1,…,Mt]=𝔼[Mt+1∣M1,…,Mt].

On the other hand,

𝔼[𝔼[Mt+1∣G1,…,Gt]∣M1,…,Mt]=𝔼[Mt∣M1,…,Mt]=Mt,

which makes M1,… a martingale.

Example 1.13.11 (Pólya’s Urn).

Suppose there are black balls and white balls in an urn, that are identical except for the colors. Each time pick a ball, and put it back with another identical ball with same color. For simplicity, we start at round 2, and ends at round n where there are n balls in the urn. Let Xn be the number of black balls in the urn, and Zn=Xn/n be the ratio of black balls in the urn. Then for all n≥2,

𝔼[Zn+1∣Z2,…,Zn]=Zn⋅n⁢Zn+1n+1+(1−Zn)⋅n⁢Znn+1=Zn,

which makes Z2,Z3,… a martingale.

1.13.2 Stopping Times

By lemma 1.13.9, if the number of games is fixed initially, then the expected gain from the fair games is 0, if Z0=0. But suppose the number of games is not fixed initially, for example the gambler choose to play a random number of games, by deciding when to quit based on the outcome of the games already played.

Definition 1.13.12 (Stopping Time).

A nonnegative integer-valued random variable T is a stopping time for the sequence Z0,Z1,… if the probability of the event T=n is independent of the variables {Zn+j∣Z0,…,Zn}j≥1, which are the random variables Zn+1,Zn+2,… conditioned on the values of Z0,…,Zn.

A stopping time is corresponding to a strategy of when to stop based only on the outcome seen so far. But given that one can stop by strategy such as “winning reaches 10 for the first time”, it would be helpful to characterize the conditions on the stopping time T that maintain the property 𝔼[ZT]=𝔼[Z0]=0. The subtle problem is that, T might not be finite in this case, that the gambler will gamble infinite number of times with non-zero probability. The martingale stopping time theorem shows that, under certain conditions, and in particular when the stopping time is bounded or has bounded expectation, the expected value of the martingale at the stopping time is 𝔼[Z0].

Theorem 1.13.13 (Martingale Stopping Time Theorem).

If Z0,Z1,… is a martingale with respect to X0,X1,… and if T is a stopping time for X0,X1,…, then

𝔼[ZT]=𝔼[Z0]

whenever one of the following holds:

  • •

    The Zi is bounded, such that there exists constant c for all i≥0, |Zi|≤c.

  • •

    T is bounded.

  • •

    𝔼[T]<∞, and there is a constant c such that 𝔼[|Zi+1−Zi|∣X0,…,Xi]≤c.

Exercise 1.13.14 (Exercise 13.5 [MU17]).

Consider the gambler’s ruin example 1.7.51, stopping by either losing ℓ1 or winning ℓ2. Let Xn be the winning in the nth game, Yn be the winning by the end of the nth game, and Zn=Yn2−n. Show that Z1,Z2,… is a martingale, and let T be a stopping time, determine 𝔼[ZT] and 𝔼[T].

Proof.

Since Var⁢[Xi]=1 and 𝔼[Xi]=0, by 1.13.5, Z1,Z2,… is a martingale.

We have shown in 1.7.68 that 𝔼[T]=ℓ1⁢ℓ2.

The theorem 1.13.13 applies by

|Zi+1−Zi|=|(Yi+1−Yi)⁢(Yi+1+Yi)−1|≤|Yi+1−Yi|⋅|Yi+1+Yi|+1≤2⁢max⁡(ℓ1,ℓ2)+1,

then 𝔼[ZT]=𝔼[Z1]=0, which means 𝔼[YT2]=𝔼[T]. Since YT2 can either be ℓ12 or ℓ22, by example 1.7.51 161616 Now we can show by Yi is a martingale in example 1.13.2, then 𝔼[YT]=0, to derive the winning or losing probabilities. ,

𝔼[YT2]=ℓ12⋅ℓ2ℓ1+ℓ2+ℓ22⋅ℓ1ℓ1+ℓ2=ℓ1⁢ℓ2,

which derives 𝔼[T] in a martingale way. ∎

Exercise 1.13.15 (Exercise 13.6 [MU17]).

Consider the gambler’s ruin example 1.7.51, stopping by either losing ℓ1 or winning ℓ2, and winning probability p<1/2. Let Xn be the winning in the nth game, and Zn be the winning by the end of the nth game.

  • •

    Show that

    An=(1−pp)Zn

    is a martingale with mean 1.

  • •

    Determine the probability that the player wins ℓ2 before losing ℓ1.

  • •

    Show that Bn=Zn−(2⁢p−1)⁢n is a martingale with mean 0.

  • •

    Let T be the stopping time when the player finishes playing. Determine 𝔼[ZT] and 𝔼[T].

Proof.

We have shown in 1.7.69 that

An=(1−pp)Zn,

we have 𝔼[An+1]=𝔼[An]=1. Since Zn+1=Zn+Xn+1,

𝔼[An+1∣X1,…,Xn]=p⁢(1−pp)Zn+1+(1−p)⁢(1−pp)Zn−1=(1−pp)Zn=An,

which proves that A1,A2,… is a martingale by 1.13.4.

With this A1,A2,… martingale, then let q be the probability of being absorbed into ℓ2, and

𝔼[AT]=q⁢(1−pp)ℓ2+(1−q)⁢(1−pp)−ℓ1=1,

such that

q=(1−(1−pp)ℓ1)⋅(1−(1−pp)ℓ1+ℓ2)−1.

Since 𝔼[Xi]=p−(1−p)=2⁢p−1, then by linearity of expectation,

𝔼[Bn+1∣X1,…,Xn]=Bn+𝔼[Xn+1−(2⁢p−1)∣X1,…,Xn]=Bn,

the second equality holds by the independence of the games. Hence, B1,B2,… is a martingale by 1.13.4.

Since An is bounded, then by theorem 1.13.13, 𝔼[AT]=𝔼[A1]=1. Therefore,

𝔼[ZT]=−ℓ1⋅(1−q)+ℓ2⋅q=(ℓ1+ℓ2)⋅q−ℓ1.

By 𝔼[BT]=0=𝔼[ZT]−(2⁢p−1)⁢𝔼[T], we have

𝔼[T]=𝔼[ZT]2⁢p−1=ℓ1−(ℓ1+ℓ2)⋅q1−2⁢p.

∎

Example 1.13.16 (A Ballot Theorem).

Suppose there are 2 candidates running an election, where candidate A obtains a votes, and candidate B obtains b<a votes. The votes come in random order, and can be viewed as sampled from uniformly random permutations. Candidate A always with higher votes has probability (a−b)/(a+b).

Let n=a+b, and let Sk be the leading votes of A to B after k votes. Then Sn=a−b. For 0≤k≤n−1, let

Xk=Sn−kn−k.

We first show that X1,X2,…,Xn is a martingale. Since

𝔼[Sn−k−1∣Sn,…,Sn−k]=𝔼[Sn−k−1∣Sn−k]=n−k+Sn−k2⁢(n−k)⋅(Sn−k−1)+n−k−Sn−k2⁢(n−k)⋅(Sn−k+1)=n−k−1n−k⋅Sn−k,

where the first equality holds by Sn−k−1 is only related to Sn−k counting backwards, and the second equality holds by the probability of the (n−k)th vote being A or B, conditioned on Sn−k, then

𝔼[Xk+1∣Sn,…,Sn−k]=Sn−kn−k=Xk,

and

𝔼[Xk+1∣X1,…,Xk]=𝔼[𝔼[Xk+1∣Sn,…,Sn−k]∣X1,…,Xk]=Xk,

which completes the proof of martingale.

Moreover, define a stopping T for the first XT=0, otherwise T=n−1, then since T is bounded, and X0,…,Xn−1 is also bounded, by theorem 1.13.13,

𝔼[XT]=𝔼[X0]=Snn=a−ba+b.

By the stopping time T, the voting is either A and B are drawing, or A leads throughout the n votes. In the first case, XT=0 as ST=0, otherwise, XT=1 as ST=n. Hence,

𝔼[XT]=Pr⁡[A leads throughout]⋅1+Pr⁡[A and B are drawing]⋅0=a−ba+b,

which completes the proof.

Remark 1.13.17.

The example 1.13.16 is also called Bertrand’s ballot theorem, which can be proved in other ways.

One of the earliest proofs [And87] solved the problem directly, but the “geometric reflection” trick derives from his work. Consider a 2-dimensional lattice, a vote for A moves is a step right, and a vote for B is a step up. Hence, after n moves, the particle moves from (0,0) to (a,b). An observation is, if A is ahead in the count throughout, then the particle is constantly below the line y=x (except for the initial state with no vote).

Moreover, for any permutation that start with a vote for B, then it has to be at the diagonal y=x at least once. The reflection trick is: we can always reflect a trajectory above the diagonal to the symmetry one below the diagonal y=x, such that the move is still a bad move, but the move is beginning with a vote for A to (1,0).

Since all the valid trajectories begin with a vote for A, we just exclude all the bad trajectories beginning with (1,0), and all such bad trajectories can be reflected to the trajectories beginning with (0,1).

Diagram

Therefore, the number of valid trajectories is

(a+b−1a−1)−(a+b−1b−1)=a−ba+b⋅(a+ba).

When a=b+1, this deteriorates to lemma 1.7.67, which are Dycks path and Catalans number Cb.

1.13.3 Wald’s Equation

Wald’s equation is an important corollary of theorem 1.13.13, which handles the expectation of the sum of independent random variables, where the number of random variables being summed is itself a random variable.

Theorem 1.13.18 (Wald’s Equation [Wal47]).

Let X1,X2,… be independent, identically distributed random variables with distribution X, and T be a stopping time for this sequence. If T and X have bounded expectation, then

𝔼[∑i∈[1,T]Xi]=𝔼[T]⋅𝔼[X].
Proof.

We first show a version for the nonnegative random variables. For i≥1, let

Zi=∑j∈[1,i](Xj−𝔼[Xj]),

then Z1,Z2,… is a martingale with respect to X1,X2,…, with 𝔼[Zi]=0 by 1.13.15.

Since 𝔼[T]<∞, and

𝔼[|Zi+1−Zi|∣X1,…,Xi]=𝔼[|Xi+1−𝔼[X]|]≤2⁢𝔼[X], (1.25)

then by theorem 1.13.13,

𝔼[ZT]=𝔼[Z1]=0.

Therefore, by linearity of expectation,

𝔼[ZT]=𝔼[∑i∈[1,T](Xi−𝔼[X])]=𝔼[∑i∈[1,T]Xi]−𝔼[T]⋅𝔼[X],

which completes the proof.

In general case, where X is any random variable, the main trick is writing X=X+−X−, where

X+=max⁡(X,0),X−=max⁡(−X,0).

Hence, write Xi=Xi+−Xi− for all i≥1, and by the prior nonnegative case,

𝔼[∑i∈[1,T]Xi+]=𝔼[T]⋅𝔼[X+],𝔼[∑i∈[1,T]Xi−]=𝔼[T]⋅𝔼[X−].

By linearity of expectation,

𝔼[∑i∈[1,T]Xi] =𝔼[∑i∈[1,T]Xi+−∑i∈[1,T]Xi−]=𝔼[∑i∈[1,T]Xi+]−𝔼[∑i∈[1,T]Xi−]
=𝔼[T]⋅(𝔼[X+]−𝔼[X−])
=𝔼[T]⋅𝔼[X],

we conclude the proof for the general case. ∎

Remark 1.13.19.

Since T is a stopping time for X1,X2,…, then event {T≥i} is dependent only on X1,…,Xi−1 by definition 1.13.12. The mutual independence over Xi ensures that Xi is independent of past X1,…,Xi−1, hence Xi is independent of {T≥i}. The independence is a convenient sufficient condition, that can be used to construct martingale in 1.13.15 and used here, and help simplify the third condition of the theorem 1.13.13 in eq. 1.25.

After theorems 1.13.18, 1.13.19 and 1.13.15, for the stopping time in the case of independent random variables, we have an equivalent, yet simpler version of stopping time as follows.

Definition 1.13.20 (Stopping Time for Independent Random Variables).

Let Z0,Z1,… be a sequence of independent random variables. A nonnegative, integer-valued random variable T is a stopping time for the sequence if the event {T=n} is independent of Zn+1,Zn+2,….

Example 1.13.21 (Dice Rolling).

Consider a gambling game where a player first rolls a die. If the outcome is X then roll X new standard dice and gain Z, which is the sum of the outcome of the X dice. This is exactly an application of theorem 1.13.18 to derive the expected outcome. By definition 1.13.20 and theorem 1.13.18, let X be the stopping time, and Y1,Y2,… be i.i.d. random variables for dice rolling scores with distribution Y. Then by theorem 1.13.18,

𝔼[∑i∈[1,X]Yi]=𝔼[X]⋅𝔼[Y]=(1+n2)2,

if the die is a n faced fair die.

Example 1.13.22 (Server Message Transmission).

Consider n servers communicating using a shared channel, where time is divided in discrete slots. At each time slot, any server that needs to send a packet can transmit it through the channel. If exactly one packet is sent at that time, the transmission is successful, otherwise none are successful. At a time slot, a server transmits a packet with probability 1/n.

Let X1,X2,… be the independent 0-1 random variables for a successful packet transmission on the ith time slot with distribution X, then

Pr⁡[X=1]=(n1)⋅1n⋅(1−1n)n−1=(1−1n)n−1.

Similar to section 1.5.1, let

φg⁢(n)=(n−1)⁢ln⁡(1−1n),

then

φg′⁢(n)=ln⁡(1−1n)+1n.

Let t=1−1/n, and n≥2 means 1/2≤t<1, then φg′⁢(n)<0. Therefore, when n≥2, since

limn→∞(1−1n)n−1=e−1,

then e−1 is a lower bound by

p=Pr⁡[X=1]=(1−1n)n−1≥e−1.

Let N be the random variable for the number of packets successfully sent until each server has successfully sent at least 1 packet. By the Coupon’s Collector’s Problem,

𝔼[N]=n⁢∑i∈[1,n]i−1=n⁢H⁢(n)=n⁢ln⁡n+c⁢n.

Let Yi be the number of time slots between the (i−1)th successful transmission and the ith successful transmission. Then Y1,Y2,… are independent and geometrically distributed with success probability p, therefore 𝔼[Yi]=1/p≤e. Moreover, whichever server successfully transmitted a packet is independent of the waiting times Yi, so the Wald argument applies to this sum. By theorem 1.13.18,

𝔼[∑i∈[1,N]Yi]=𝔼[N]⋅𝔼[Y1]≤e⁢(n⁢ln⁡n+c⁢n).
Exercise 1.13.23 (Exercise 13.11 [MU17]).

A parking-lot attendant has mixed up n keys for n cars. The n car owners arrive together. The attendant gives each owner a key according to a permutation chosen uniformly at random from all permutations. If an owner receives his key, he takes it and leaves; otherwise, he returns the key to the attendant. The attendant repeats the process with the remaining keys and car owners. This continues until all owners receive the keys to their cars. Let R be the number of rounds until all car owners receive their keys, and let Xi be the number of owners who receive their car keys in the ith round. Show that

Yi=∑j∈[1,i](Xj−𝔼[Xj∣X1,…,Xj−1])

is a martingale, and use theorem 1.13.13 to derive 𝔼[R].

Proof.

To show that Y1,Y2,… is a martingale, we have

𝔼[Yi∣Y1,…,Yi−1] =Yi−1+𝔼[Xi−𝔼[Xi∣X1,…,Xi−1]∣Y1,…,Yi−1]
=Yi−1+𝔼[Xi∣Y1,…,Yi−1]−𝔼[Xi∣Y1,…,Yi−1]=Yi−1.

Since both Xi+1 and 𝔼[Xi+1∣X1,…,Xi] are in [0,n], then by triangle inequality and tower property,

𝔼[|Yi+1−Yi|∣Y1,…,Yi] =𝔼[|Xi+1−𝔼[Xi+1∣X1,…,Xi]|∣Y1,…,Yi]
≤2⁢𝔼[Xi+1∣Y1,…,Yi]≤2⁢n,

we can apply theorem 1.13.13, that

𝔼[YR]=𝔼[Y1]=0.

Moreover, by 1.2.4, for i≥1,

𝔼[Xi∣X1,…,Xi−1]=1.

Hence, by the stopping time R, we have

𝔼[YR]=𝔼[∑i∈[1,R]Xi−∑i∈[1,R]𝔼[Xi∣X1,…,Xi−1]]=𝔼[∑i∈[1,R]Xi]−𝔼[R]=0.

Since by stopping time R,

∑i∈[1,R]Xi=n,

we have 𝔼[R]=n. ∎

Exercise 1.13.24 (Exercise 13.12 [MU17]).

Alice and Bob play each other in a chess tournament, where the first player to win four games wins the match. The players are evenly matched, so the probability that each player wins each game is 1/2, independent of other games. The number of minutes for each game is uniformly distributed over the integers in [30,60], again independent of other games. What is the expected time they spend playing this match?

Proof.

Let X1,X2,… be the time used in the ith game with distribution X, then 𝔼[X]=45.

Let T be the stopping time, and WLOG let Alice win, as Bob wins symmetrically. Since Alice wins the final game, then there are (30) ways to finish in 4 games, (41) ways to finish in 5 games, (52) ways to finish in 6 games, (63) ways to finish in 7 games. The expected number of games is

𝔼[T]=((30)+(41)+(52)+(63))−1⋅((30)⋅4+(41)⋅5+(52)⋅6+(63)⋅7)=325.

By theorem 1.13.18,

𝔼[∑i∈[1,T]Xi]=𝔼[X]⋅𝔼[T]=288.

∎

Exercise 1.13.25 (Exercise 13.13 [MU17]).

Consider the following algorithm for sorting n numbers. Start by choosing one of the n numbers uniformly at random, and place it first. Then choose one of the remaining n−1 numbers uniformly at random, and place it second. If the second number is smaller than the first, start over again from the beginning. Otherwise, next choose one of the remaining n−2 numbers uniformly at random, place it third, and so on. The algorithm starts over from the beginning whenever it finds that the kth item placed is smaller than the (k−1)th item. Determine the expected number of times the algorithm tries to place a number, assuming that the input consists of n distinct numbers.

Proof.

Let X1,X2,… be the random variables of the lengths of the incremental sequences drawn from the n distinct numbers, then by the stopping time T, XT=n. Since the success probability of drawing an incremental sequence of length n is (n!)−1, then 𝔼[T]=n!.

Let Y[1,k] be the random variables for the prefix sequence of length k, then we have

Pr⁡[Y[1,k]=𝐲[1,k]]=(n−k)!n!,

as each permutation is uniformly distributed. Hence,

Pr⁡[X≥k]=(nk)⁢(n−k)!n!=1k!,

and the expectation of the length of incremental sequence is

𝔼[X]=∑k∈[1,n]Pr⁡[X≥k]=∑k∈[1,n]1k!≤e,

the upper bound can be seen in section 1.5.1.

Since Xi are i.i.d., then we can apply theorem 1.13.18, the expected number of draws is

𝔼[∑i∈[1,T]Xi]=𝔼[T]⋅𝔼[X]=n!⁢∑k∈[1,n]1k!.

∎

Exercise 1.13.26 (Exercise 13.14 [MU17]).

Suppose we are arranging a chain of n dominoes so that, once we are done, we can have them fall sequentially by knocking down the lead domino. Each time one tries to place a domino in the chain, there is some probability that it falls. In this case, one must start over from the very first domino.

  • •

    Call each time placing a domino a trial, succeeding with probability p. Use theorem 1.13.18, find the expected number of trials necessary before the arrangement is ready.

  • •

    Suppose instead that one can break the arrangement in k components, each of size n/k, in such a way so that once a component is complete, it will not fall for further dominoes. Find the expected number of trials necessary before the arrangement is ready.

Proof.

Let X1,X2,… be the longest length of a domino arrangement, and T be the stopping time, such that XT=n. Since Xi is geometrically distributed for the number of steps to the first failure, and Xi are i.i.d., then 𝔼[Xi]=(1−p)−1. On the other hand, T is also geometrically distributed with success probability pn, therefore 𝔼[T]=p−n.

Hence, by theorem 1.13.18,

𝔼[∑i∈[1,T]Xi]=𝔼[X1]⋅𝔼[T]=1(1−p)⁢pn.

When there are k segments of sub-arrangements, the expected number of trials to finish a segment is (1−p)−1⁢p−n/k, and by linearity of expectation, the expected number of trials to finish all pieces is k⁢(1−p)−1⁢p−n/k. ∎

Exercise 1.13.27 (Exercise 13.15 [MU17]).

Use theorem 1.13.18 to derive the following 𝔼[N].

  • •

    Let X1,X2,… be independent exponential random variables with 𝔼[Xi]=1. Given k∈ℝ+, define

    N=min⁡{n:∑i∈[1,n]Xi>k}.
  • •

    Let Y1,Y2,… be independent uniform random variables in (0,1). Given k∈(0,1), define

    N=min⁡{n:∏i∈[1,n]Yi<k}.
Proof.

Let Sm=∑i∈[1,m]Xi. Since 𝔼[Xi]=1, by theorem 1.13.18,

𝔼[SN]=𝔼[X1]⋅𝔼[N]=𝔼[N].

Moreover, since Xi are exponential random variables, then by the memorylessness property, for any a≥0,

𝔼[Xi−a⁢∣Xi>⁢a]=1.

Given that SN−1≤k, and SN>k, we have XN>k−SN−1, then

𝔼[XN−(k−s)⁢∣XN>⁢k−s,SN−1=s]=1

holds for any 0≤s≤k, therefore 𝔼[N]=k+1.

For Y1,Y2,…, let Zi=−ln⁡Yi, then the stopping time is defined as

N=min⁡{n:∑i∈[1,n]Zi>−ln⁡k},

and 𝔼[Zi]=1 by

𝔼[Zi]=∫01−ln⁡x⁢d⁢x=1.

Let Qm=∑i∈[1,m]Zi, by theorem 1.13.18,

𝔼[QN]=𝔼[Z1]⋅𝔼[N]=𝔼[N].

Since QN−1≤−ln⁡k, while QN>−ln⁡k, we have ZN>−ln⁡k−QN−1. Moreover,

Pr⁡[Zi>a]=Pr⁡[Yi<e−a]=e−a,

as they are the same event. Hence, for all 0<s≤−ln⁡k,

𝔼[ZN−(−ln⁡k−s)⁢∣ZN>−ln⁡k−s,QN−1=s]=1Pr⁡[YN<k⋅es]⁢∫0k⋅es(−ln⁡x−(−ln⁡k−s))⁢𝑑x=1,

which proves that 𝔼[QN]=𝔼[N]=−ln⁡k+1.

Another way of showing is, Zi is an exponential random variable with probability density function f⁢(x)=e−x, hence 𝔼[Zi]=1. Applying the prior result, the threshold is −ln⁡k, and 𝔼[N]=−ln⁡k+1. ∎

1.13.4 Azuma-Hoeffding’s Inequality

Azuma-Hoeffding says a martingale with bounded increment per step has total gain Xt−X0 concentrating around 0, even if the steps are not independent.

Theorem 1.13.28 (Azuma-Hoeffding’s Inequality [Azu67]).

Let X0,X1,… be a martingale such that

|Xk−Xk−1|≤ck,

then for all t≥1 and ε>0,

Pr⁡[|Xt−X0|≥ε]≤2⁢exp⁡(−ε22⁢∑i∈[1,t]ci2).
Proof.

The proof is similar to theorem 1.4.10, using moment-generating functions.

Start by bounding the upper tail. Let Yi=Xi−Xi−1, such that |Yi|≤ci, and since X0,X1,… is a martingale,

𝔼[Yi∣X0,…,Xi−1]=𝔼[Xi−Xi−1∣X0,…,Xi−1]=𝔼[Xi∣X0,…,Xi−1]−Xi−1=0. (1.26)

Write

Yi=−ci⋅1−Yi/ci2+ci⋅1+Yi/ci2.

Since exp⁡(λ⁢Yi) is a convex function, by theorem 1.2.5,

exp⁡(λ⁢Yi) =exp⁡(−ci⁢λ⋅1−Yi/ci2+ci⁢λ⋅1+Yi/ci2)
≤1−Yi/ci2⋅exp⁡(−ci⁢λ)+1+Yi/ci2⋅exp⁡(ci⁢λ)
=12⁢(exp⁡(λ⁢ci)+exp⁡(−λ⁢ci))+Yi2⁢ci⁢(exp⁡(λ⁢ci)−exp⁡(−λ⁢ci)).

Now consider

𝔼[exp⁡(λ⁢Yi)∣X0,…,Xi−1]≤12⁢(exp⁡(λ⁢ci)+exp⁡(−λ⁢ci)). (1.27)

By section 1.5.1,

12⁢(exp⁡(λ⁢ci)+exp⁡(−λ⁢ci))=∑k≥0(λ⁢ci)2⁢k(2⁢k)!.

Since (2⁢k)!≥2k⋅k!,

12⁢(exp⁡(λ⁢ci)+exp⁡(−λ⁢ci))=∑k≥0(λ⁢ci)2⁢k(2⁢k)!≤∑k≥0(λ⁢ci)2⁢k2k⋅k!=∑k≥01k!⋅((λ⁢ci)22)k=exp⁡((λ⁢ci)22). (1.28)

To bound the exponential moment used in Markov’s inequality, similar to the Chernoff and Hoeffding bounds,

𝔼[exp⁡(λ⁢(Xt−X0))]=𝔼[exp⁡(λ⁢∑i∈[1,t]Yi)]=𝔼[∏i∈[1,t]exp⁡(λ⁢Yi)]=𝔼[𝔼[∏i∈[1,t]exp⁡(λ⁢Yi)|X1,…,Xt−1]]=𝔼[𝔼[exp⁡(λ⁢Yt)⋅∏i∈[1,t−1]exp⁡(λ⁢Yi)|X1,…,Xt−1]]=𝔼[∏i∈[1,t−1]exp⁡(λ⁢Yi)⋅𝔼[exp⁡(λ⁢Yt)∣X0,…,Xt−1]]≤exp⁡(λ2⁢ct22)⋅𝔼[∏i∈[1,t−1]exp⁡(λ⁢Yi)]≤exp⁡(λ22⁢∑i∈[1,t]ci2), (1.29)

where the last inequality is by induction of eq. 1.27 and eq. 1.28. The rest follows the same method as the Chernoff or Hoeffding bounds,

Pr⁡[Xt−X0≥ε]=Pr⁡[exp⁡(λ⁢(Xt−X0))≥exp⁡(λ⁢ε)]≤𝔼[exp⁡(λ⁢(Xt−X0))]⋅exp⁡(−λ⁢ε)≤exp⁡(λ22⁢∑i∈[1,t]ci2−λ⁢ε)≤exp⁡(−ε22⁢∑i∈[1,t]ci2), (1.30)

where the last inequality is by minimizing at λ=ε/∑i∈[1,t]ci2.

To bound the lower tail, let Zi=Xi−1−Xi, then 𝔼[Zi∣X0,…,Xi−1]=0 by the same proof in eq. 1.26, and

𝔼[exp⁡(λ⁢Zi)∣X0,…,Xi−1]≤exp⁡((λ⁢ci)22)

by eq. 1.27 and eq. 1.28. We conclude the lower bound by eq. 1.29 and eq. 1.30. ∎

Theorem 1.13.29 (Generalized Azuma-Hoeffding’s Inequality [Azu67]).

Let X0,X1,… be a martingale such that

Bk≤Xk−Xk−1≤Bk+dk,

for some constant dk and random variables Bk that may be functions of X0,…,Xk−1. Then for all t≥1 and ε>0,

Pr⁡[|Xt−X0|≥ε]≤2⁢exp⁡(−2⁢ε2∑i∈[1,t]di2).
Proof.

Start with the upper tail. Let Yi=Xi−Xi−1, and 𝔼[Yi∣X0,…,Xi−1]=0 by eq. 1.26. Consider bounding the exponential moment as in eq. 1.29:

𝔼[exp⁡(λ⁢(Xt−X0))]=𝔼[∏i∈[1,t−1]exp⁡(λ⁢Yi)⋅𝔼[exp⁡(λ⁢Yt)∣X0,…,Xt−1]].

By lemma 1.4.8,

𝔼[exp⁡(λ⁢Yt)∣X0,…,Xt−1]≤exp⁡(λ2⁢dt28).

By induction,

𝔼[exp⁡(λ⁢(Xt−X0))]≤exp⁡(λ28⁢∑i∈[1,t]di2). (1.31)

We conclude by

Pr⁡[Xt−X0≥ε]=Pr⁡[exp⁡(λ⁢(Xt−X0))≥exp⁡(λ⁢ε)]≤𝔼[exp⁡(λ⁢(Xt−X0))]⋅exp⁡(−λ⁢ε)≤exp⁡(λ28⁢∑i∈[1,t]di2−λ⁢ε)≤exp⁡(−2⁢ε2∑i∈[1,t]di2), (1.32)

where the last inequality is by minimizing at λ=4⁢ε/∑i∈[1,t]di2.

To bound the lower tail, let Zi=Xi−1−Xi, then 𝔼[Zi∣X0,…,Xi−1]=0 by the same proof in eq. 1.26, and

𝔼[exp⁡(λ⁢Zi)∣X0,…,Xi−1]≤exp⁡(λ2⁢di28)

by lemma 1.4.8. We conclude the lower bound by eq. 1.31 and eq. 1.32. ∎

Exercise 1.13.30 (Exercise 13.17 [MU17]).

Given a bag with r red balls and g green balls, suppose that we uniformly sample n balls from the bag without replacement. Use Azuma-Hoeffding to show that the number of red balls in the sample concentrates tightly around n⁢r/(r+g).

Proof.

Let X1,…,Xn be 0-1 random variables indicating if the ith draw is a red ball, and let Y=∑i∈[1,n]Xi be the random variable for the total number of red balls drawn. Then

Z0=𝔼[Y],Zk=𝔼[Y∣X1,…,Xk]

is a Doob martingale. Let Yk=∑i∈[1,k]Xi, such that Yn=Y. Then

Zk−1 =𝔼[Y∣X1,…,Xk−1]=Yk−1+(n−k+1)⋅r−Yk−1r+g−k+1,
Zk =𝔼[Y∣X1,…,Xk]=Yk+(n−k)⋅r−Ykr+g−k.

The difference is

Zk−Zk−1 =Yk+(n−k)⋅r−Ykr+g−k−(Yk−1+(n−k+1)⋅r−Yk−1r+g−k+1)
=r+g−nr+g−k⁢(Xk+Yk−1−rr+g−k+1)=r+g−nr+g−k+1⁢(Xk+Yk−rr+g−k)

The upper bound is

Zk−Zk−1 =r+g−nr+g−k⁢(Xk+Yk−1−rr+g−k+1)
≤Xk+Yk−1−rr+g−k+1≤Xk≤1.

The lower bound is

Zk−Zk−1 =r+g−nr+g−k+1⁢(Xk+Yk−rr+g−k)
≥r+g−nr+g−k+1⋅Yk−rr+g−k≥−r−Ykr+g−k≥−1.

Given that |Zk−Zk−1|≤1, and 𝔼[Y]=n⋅r/(r+g) by linearity of expectation, we conclude with theorem 1.13.28

Pr⁡[|Y−𝔼[Y]|≥ε]≤2⁢exp⁡(−ε22⁢n).

∎

Remark 1.13.31.

Interestingly, if we let X0,…,Xn be the fraction of the remaining red balls in 1.13.30, it is also a martingale. Indeed,

𝔼[Xk+1∣X0,…,Xk] =Xk⋅(r+g−k)⁢Xk−1r+g−k−1+(1−Xk)⋅(r+g−k)⁢Xkr+g−k−1
=−Xkr+g−k−1+(r+g−k)⁢Xkr+g−k−1=Xk.

Moreover, X0,…,Xn is a Doob martingale with respect to itself, and lemma 1.13.9,

𝔼[Xn]=𝔼[X0]=rr+g.

The fractional martingale can be viewed as an inverse of example 1.13.11.

McDiarmid’s inequality says that, for a function that is not too sensitive, namely changing any one of its inputs will not change its value by much, if the input variables are mutually independent, then the function value depending on the independent random inputs should concentrate around its expectation.

Definition 1.13.32 (Lipschitz Condition [Mcd89]).

A function f⁢(X1,…,Xn) is said to satisfy a Lipschitz condition with bound c if for any i and any set of values x1,…,xn and yi,

|f⁢(x1,…,yi,…,xn)−f⁢(x1,…,xi,…,xn)|≤c.

That is, changing the value of any single coordinate can change the function value by at most c.

Let

Z0 =𝔼[f⁢(X1,…,Xn)],
Zk =𝔼[f⁢(X1,…,Xn)∣X1,…,Xk].

The sequence Z0,Z1,…,Zn is a Doob martingale. Moreover, we claim if X1,…,Xn are mutually independent, then there exist random variables B1,…,Bn such that for all k∈[1,n],

Bk≤Zk−Zk−1≤Bk+c.

We have a counterexample for the dependent case: Let X1,…,Xn be the random variables drawn from the same fair coin toss Y, and f⁢(X1,…,Xn)=(∑i∈[1,n]Xi)/n, with a Lipschitz condition bound c=1/n. Then,

Z0=𝔼[1n⁢∑i∈[1,n]Xi]=12,Z1=𝔼[1n⁢∑i∈[1,n]Xi|X1]=Y.

Now Y−1/2 has a range much larger than 1/n, so the claim of existence of B1,…,Bn does not hold.

Another counterexample is as follows. Let X1,…,Xk−1 be independent random variables drawn from fair coin tosses, and let Xk,…,Xn be random variables equal to the same fair coin toss Y. Let ℓ=n−k+1, so

Zk−1=𝔼[1n⁢∑i∈[1,n]Xi|X1,…,Xk−1]=1n⁢∑i∈[1,k−1]Xi+ℓ2⁢n,Zk=𝔼[1n⁢∑i∈[1,n]Xi|X1,…,Xk]=1n⁢∑i∈[1,k−1]Xi+ℓ⁢Yn.

The difference ℓ/n⋅(Y−1/2) has a range ℓ/n≥1/n, so the claim fails.

Theorem 1.13.33 (McDiarmid’s Inequality [Mcd89]).

Let f be a function on n variables that satisfies the Lipschitz condition in definition 1.13.32 with bound c. Let X1,…,Xn be independent random variables that are in the domain of f. Then

Pr⁡[|f⁢(X1,…,Xn)−𝔼[f⁢(X1,…,Xn)]|≥ε]≤2⁢exp⁡(−2⁢ε2n⁢c2).
Proof.

Let Sk denote X1,…,Xk, simplify f⁢(X1,…,Xn) as f⁢(X‾), and let fk⁢(X‾,x)=f⁢(X1,…,Xk−1,x,Xk+1,…,Xn).

Consider the upper bound and the lower bound of Zk−Zk−1, where Zk−Zk−1 is upper bounded by

supx𝔼[f⁢(X‾)|Sk−1,Xk=x]−𝔼[f⁢(X‾)|Sk−1]=supx((Zk∣Xk=x)−Zk−1),

and Zk−Zk−1 is lower bounded by Bk, defined as 171717 If X‾ here have support (the possible value taken) being finite number of values, we can use max and min to substitute sup and inf.

infx𝔼[f⁢(X‾)|Sk−1,Xk=x]−𝔼[f⁢(X‾)|Sk−1]=infx((Zk∣Xk=x)−Zk−1).

Then consider the range between the upper and lower bound of Zk−Zk−1:

supx(Zk∣Xk=x)−infx(Zk∣Xk=x)=supx𝔼[f⁢(X‾)|Sk−1,Xk=x]−infx𝔼[f⁢(X‾)|Sk−1,Xk=x]=supx,y(𝔼[f⁢(X‾)|Sk−1,Xk=x]−𝔼[f⁢(X‾)|Sk−1,Xk=y])=supx,y𝔼[fk⁢(X‾,x)−fk⁢(X‾,y)|Sk−1], (1.33)

where the last equality holds because Xk is independent of X‾∖Xk; this follows from conditional probability,

Pr⁡[X‾=(z1,…,zk−1,x,…,zn)|Sk−1=(z1,…,zk−1),Xk=x]=Pr⁡[X‾∖Xk=(z1,…,zk−1,zk+1,…,zn)|Sk−1=(z1,…,zk−1)].

Since f satisfies the Lipschitz condition with bound c, and X1,…,Xn are independent, eq. 1.33 is at most c. We conclude the proof with theorem 1.13.29. ∎

Remark 1.13.34.

McDiarmid is an instance of Azuma-Hoeffding with a Doob martingale from independent random variables and a function satisfying the Lipschitz condition. The condition to apply Azuma-Hoeffding is to have bounded increments, which are guaranteed by independence and Lipschitz condition bound c. Independence says that revealing Xk does not alter the conditional probability distribution of the unrevealed random variables, as they do not depend on Xk. Therefore, the effect of revealing Xk can be compared as if only the kth coordinate changes, such that the martingale difference is bounded by the same c.

Exercise 1.13.35 (Exercise 13.8 [MU17]).

In the bin-packing problem, we are given items with sizes a1,…,an with ai∈[0,1]. The goal is to pack them into minimum number of bins, with each bin being able to hold any collection of items whose total sizes sum to at most 1. Suppose that each of the ai is chosen independently according to some distribution, let P be the number of bins required in the best packing of the resulting items. Prove that

Pr⁡[|P−𝔼[P]|≥ε]≤2⁢exp⁡(−2⁢ε2/n).
Proof.

Let f⁢(a1,…,an) be the minimum number of bins needed to pack n items. Then the Lipschitz condition bound of f is at most 1, since a bin has capacity at most 1. Starting with f(a1,…,ak=0,…,an) bins, and changing to ak=1, the worst one can do is to put ak in a separate bin and preserve the arrangement for the other items. Hence

f(a1,…,ak=1,…,an)≤f(a1,…,ak=0,…,an)+1.

We then conclude the proof with theorem 1.13.33 with c=1. ∎

Exercise 1.13.36 (Exercise 13.9 [MU17]).

Consider an n-cube with |V|=2n. Let S⊆V with |S|>0, and x←rV. Let D⁢(x,S) be the minimum number of coordinates in which x and y differ over all points y∈S. Give a bound on

Pr⁡[|D⁢(x,S)−𝔼[D⁢(x,S)]|>ε].
Proof.

Let X‾=(X1,…,Xn) be independent fair coin tosses, f⁢(X‾)=D⁢(X‾,S), and fk⁢(x‾,y)=f⁢(x1,…,xk−1,y,…,xn). Let d be the Hamming distance from x‾←r{0,1}n to w‾∈S, which is f⁢(x‾), and we have the following:

  • •

    If w‾ is still the closest element in S, then either wk=y and fk⁢(x‾,y)=d−1, or wk≠y and fk⁢(x‾,y)=d+1.

  • •

    fk⁢(x‾,y)=d, where y≠wk, but there is an element w‾′∈S that disagrees in d+1 coordinates with x‾, and wk′=y.

Alternatively, changing one coordinate either increases or decreases the distance to any element in S by 1. Thus, the Lipschitz condition bound c=1. We conclude with theorem 1.13.33 that

Pr⁡[|D⁢(x,S)−𝔼[D⁢(x,S)]|>ε]<2⁢exp⁡(−2⁢ε2/n).

∎

Exercise 1.13.37 (Exercise 13.10 [MU17]).

Consider generalizing Hoeffding’s bound to independent random variables ranging in [0,1], and derive a tail bound for Sn=∑i∈[1,n]Xi.

Proof.

Consider a Doob martingale over

Z0=𝔼[Sn],Zk=𝔼[Sn∣X1,…,Xk],

and Sn has Lipschitz condition bound c=1. Immediately by theorem 1.13.33,

Pr⁡[|Sn−𝔼[Sn]|≥ε]≤2⁢exp⁡(−2⁢ε2/n).

∎

Example 1.13.38 (DNA Pattern Matching).

Let X‾=(X1,…,Xn) be a sequence of characters sampled independently and uniformly at random over an alphabet Σ, and let 𝐛∈Σk be a fixed pattern string of k characters. Let F be the number of occurrences of 𝐛 in the random string X‾. By linearity of expectation, 𝔼[F]=(n−k+1)⋅s−k. Let

Z0=𝔼[F],Zi=𝔼[F∣X1,…,Xi]

be a Doob martingale. Using |Zi−Zi−1|≤k, theorem 1.13.28 gives

Pr⁡[|F−𝔼[F]|≥ε]≤2⁢exp⁡(−ε22⁢n⁢k2).

Taking a closer look, |Zi−Zi−1|≤k is rather wasteful, as F as a function over X‾ has Lipschitz condition bound c=k. Thus, by theorem 1.13.33 or theorem 1.13.29,

Pr⁡[|F−𝔼[F]|≥ε]≤2⁢exp⁡(−2⁢ε2n⁢k2).
Exercise 1.13.39 (Exercise 13.16 [MU17]).

A subsequence of a string is any string that can be obtained by deleting characters. Consider 𝐱,𝐲←r{0,1}n, and the longest common subsequence (LCS) of 𝐱 and 𝐲. Show that the expected length of the LCS is in (c1⁢n,c2⁢n) where c1>1/2 and c2<1 when n is sufficiently large 181818There are interesting open problems on pushing the bounds closer.. Use theorem 1.13.33 to show that the length of the LCS is sharply concentrated around its mean.

Proof.

Let Lℓ be the length of the LCS of two binary strings of length ℓ. Then we have

Lℓ+1>𝔼[Lℓ+1∣Lℓ]>Lℓ+12,

as xℓ+1=yℓ+1 with probability 1/2, and Lℓ+1=Lℓ+1 with non-zero probability when xℓ+1≠yℓ+1.

Let Zi=(Xi,Yi) for the ith bit in 𝐱 and 𝐲. The Doob martingale is constructed by

Z0=𝔼[Ln],Zk=𝔼[Ln∣Z1,…,Zk].

The Lipschitz condition bound is 1, as any common subsequence’s length increases or decreases by 1:

  • •

    Either the previous LCS remains, no matter what new assignment to the kth coordinate.

  • •

    Or the LCS length is unchanged, but altering the kth bits improves another common subsequence.

Hence, we conclude with theorem 1.13.33 by

Pr⁡[|Ln−𝔼[Ln]|≥ε]≤2⁢exp⁡(−2⁢ε2/n).

∎

Example 1.13.40 (Balls and Bins).

Recall in m balls and n bins model, we let {Xi}i∈[1,m] be the random variables for the bin into which the ith ball falls, and let F be the number of empty bins after m bins are thrown. Then

Z0=𝔼[F],Zk=𝔼[F∣X1,…,Xk]

is a Doob martingale. Moreover, the Lipschitz condition bound is 1, as changing which bin the ith ball lands increases or decreases the number of empty bins after m balls at most by 1. We conclude with theorem 1.13.33 that

Pr⁡[|F−𝔼[F]|≥ε]≤2⁢exp⁡(−2⁢ε2/m),

and the expected number of empty bins is 𝔼[F]=n⁢(1−1/n)m.

Exercise 1.13.41 (Exercise 13.18 [MU17]).

We have shown before in Bloom filter (e.g., 1.5.29) that the fractions of entries that are 0 in a Bloom filter is concentrated around p′=(1−1/n)k⁢m, where m is the number of data items, k is the number of hash functions, and n is the size of the Bloom filter in bits. Derive a similar concentration result using a martingale inequality.

Proof.

This is a direct adaptation of example 1.13.40, using a k⁢m balls and n bins model. Let {Xi}i∈[1,k⁢m] be the 0-1 random variables for which bit the hash hits, and Y be the number of 0 bits after m items, then 𝔼[Y]=p′⁢n, and

Z0=𝔼[Y],Zk=𝔼[Y∣X1,…,Xk]

is a Doob martingale, and Y is a function over {Xi}i∈[1,k⁢m] with Lipschitz condition bound c=1. By theorem 1.13.33,

Pr⁡[|Y−𝔼[Y]|≥ε]≤2⁢exp⁡(−2⁢ε2k⁢m).

∎

Exercise 1.13.42 (Exercise 13.20 [MU17]).

We improve the bound in example 1.13.40 and reuse all defined notations. Let Ai denote the number of bins that are empty after the ith ball is thrown.

  • •

    Show that Zi−1=Ai−1⁢(1−1/n)m−i+1.

  • •

    Show that, if the ith ball lands in a bin that is empty, Zi=(Ai−1−1)⁢(1−1/n)m−i.

  • •

    Show that, if the ith ball lands in a bin that is not empty, Zi=Ai−1⁢(1−1/n)m−i.

  • •

    Show that theorem 1.13.29 applies with di=(1−1/n)m−i, and

    Pr⁡[|F−𝔼[F]|≥ε]≤2⁢exp⁡(−2⁢ε2⁢(2⁢n−1)n2−𝔼[F]2).
Proof.

The probability of a bin remaining empty after m−i+1 balls is (1−1/n)m−i+1. By linearity of expectation,

Zi−1=𝔼[F∣X1,…,Xi−1]=Ai−1⁢(1−1/n)m−i+1.

Whether the ith ball lands into an empty bin or not determines the number of empty bins onwards after the ith ball. If the ith ball lands into an empty bin, Ai=Ai−1−1; otherwise, Ai=Ai−1. Still by linearity of expectation,

Zi=𝔼[F∣X1,…,Xi]=Ai⁢(1−1/n)m−i.

Let Bi=(Ai−1/n−1)⋅(1−1/n)m−i, then di=(1−1/n)m−i such that Bi≤Zi−Zi−1≤Bi+di. By theorem 1.13.29,

∑i∈[1,m]di2=∑j∈[0,m−1](1−1n)2⁢j=(1−(1−1n)2⁢m)⋅(1−(1−1n)2)−1=n2−n2⁢(1−1/n)2⁢m2⁢n−1=n2−𝔼[F]22⁢n−1,

which proves

Pr⁡[|F−𝔼[F]|≥ε]≤2⁢exp⁡(−2⁢ε2⁢(2⁢n−1)n2−𝔼[F]2).

∎

Remark 1.13.43.

The key step is not McDiarmid itself, but showing the bounded increment in the martingale; it can either be directly shown, or by independence and Lipschitz condition bound.

Example 1.13.44 (Chromatic Number [SS87]).

Given a random graph G in Gn,p, the chromatic number χ⁢(G) is the minimum number of colors needed to color all vertices of the graph, so no adjacent vertices have the same color.

Let Gi⊆G be the random subgraph induced by the set of vertices [1,i], so Gi depends on Gi−1. Then

Z0=𝔼[χ⁢(G)],Zk=𝔼[χ⁢(G)∣G1,…,Gk]

forms a Doob martingale.

Now consider bounding Zk−Zk−1. For H=G−vk, formed by removing the kth vertex,

χ⁢(H)≤χ⁢(G)≤χ⁢(H)+1, (1.34)

where the first inequality holds because H has one less vertex than G, and the second inequality holds because adding vk to H introduces at most one more new color.

Hence, consider G and G′ differing only on the edges between vk and V∖{vk}. Then χ⁢(G),χ⁢(G′)∈[χ⁢(H),χ⁢(H)+1]. By eq. 1.34, it is immediate that

𝔼[χ⁢(H)∣G1,…,Gk−1]≤𝔼[χ⁢(G)∣G1,…,Gk−1]≤𝔼[χ⁢(H)∣G1,…,Gk−1]+1.

Moreover, since for any G and G′ differing on the edges to vk, χ⁢(G),χ⁢(G′)∈[χ⁢(H),χ⁢(H)+1], for any Gk,

𝔼[χ⁢(H)∣G1,…,Gk−1]≤𝔼[χ⁢(G)∣G1,…,Gk]≤𝔼[χ⁢(H)∣G1,…,Gk−1]+1.

Thus di=1 for theorem 1.13.29, and we conclude that

Pr⁡[|χ⁢(G)−𝔼[χ⁢(G)]|≥ε⁢n]≤2⁢exp⁡(−2⁢ε2).
Exercise 1.13.45 (Exercise 13.19 [MU17]).

Consider a random graph G in Gn,N where N=c⁢n for c>0. Let X be the number of isolated vertices, namely vertices of degree 0. Determine 𝔼[X] and show

Pr⁡[|X−𝔼[X]|≥2⁢ε⁢c⁢n]≤2⁢exp⁡(−ε2/2).
Proof.

Let Xi be the 0-1 random variable for the ith vertex being unconnected to any of N edges, and (n2) is the total number of possible edges. Then there are

((n2)−(n−1)N)=((n−12)N)

graphs isolating the ith vertex, and

Pr⁡[Xi=1]=((n−12)N)⁢((n2)N)−1.

By linearity of expectation,

𝔼[X=∑i∈[1,n]Xi]=n⁢((n−12)N)⁢((n2)N)−1.

Let {Ei}i∈[1,N] be random variables in [1,(n2)] for the location of the edge, and

Z0=𝔼[X],Zk=𝔼[X∣E1,…,Ek]

is a Doob martingale. An edge can decrease Zk−1 by 2 by joining 2 isolated vertices, so |Zk−Zk−1|≤c=2, and we conclude with theorem 1.13.28

Pr⁡[|X−𝔼[X]|≥2⁢ε⁢c⁢n]≤2⁢exp⁡(−4⁢ε2⁢N2⁢∑i∈[1,N]c2)=2⁢exp⁡(−ε2/2).

An alternative way to further bound Zk−Zk−1 follows. Let Ik be the number of isolated vertices removed by the Ek, Ak be the number of isolated vertices after the Ek, such that Ak=Ak−1−Ik. A vertex remains isolated with probability

Pr⁡[Xi=1∣E1,…,Ek]=((n−12)−kN−k)⁢((n2)−kN−k)−1=qk.

Moreover, we have the following iteration

qk−1=(n−12)−(k−1)(n2)−(k−1)⋅qk.

By linearity of expectation, Zk=Ak⋅qk. Then

Zk−Zk−1=(Ak−1−Ik)⋅qk−Ak−1⋅(n−12)−(k−1)(n2)−(k−1)⋅qk=qk⋅(n−1(n2)−(k−1)⋅Ak−1−Ik). (1.35)

Notice that

𝔼[Ik∣E1,…,Ek−1]=n−1(n2)−(k−1)⋅Ak−1,

and Ik conditioned on E1,…,Ek−1 is in [0,2]. Hence eq. 1.35 is of interval length dk=2⁢qk≤2, and we conclude with theorem 1.13.29

Pr⁡[|X−𝔼[X]|≥2⁢ε⁢c⁢n]≤2⁢exp⁡(−2⋅4⁢ε2⁢N∑k∈[1,N]dk2)=2⁢exp⁡(−2⁢ε2).

A few notes from prior attempts follow. We have

𝔼[X∣E1,…,Ek−1] =𝔼[X∣E1,…,Ek−1,Ik=2]⋅Pr⁡[Ik=2∣E1,…,Ek−1]
+𝔼[X∣E1,…,Ek−1,Ik=1]⋅Pr⁡[Ik=1∣E1,…,Ek−1]
+𝔼[X∣E1,…,Ek−1,Ik=0]⋅Pr⁡[Ik=0∣E1,…,Ek−1].

Let Y be the number of isolated vertices for a graph in Gn,N−1. We have

𝔼[X∣E1,…,Ek−1]≤𝔼[Y∣E1,…,Ek−1],

since the Nth edge can still remove isolated vertices by

𝔼[X∣E1,…,EN−1]≤𝔼[Y∣E1,…,EN−1].

Let Bk be the number of edges removing 2 isolated vertices, Ck be the number of edges removing 1 isolated vertex, and Dk be the number of edges removing 0 isolated vertex. For Gn,N and Gn,N−1, the invariant is

Bk+Ck+Dk+k=(n2).

Then, we have

𝔼[X∣E1,…,Ek−1,Ik=2]≥𝔼[Y∣E1,…,Ek−1]−2,

as Dk≥Dk−1, Bk≤Bk−1, and Bk−1+Ck−1+Dk−1=Bk+Ck+Dk+1 in this case. Similarly,

𝔼[X∣E1,…,Ek−1,Ik=1]≥𝔼[Y∣E1,…,Ek−1]−1,

as Dk≥Dk−1, Bk≤Bk−1, and Bk−1+Ck−1+Dk−1=Bk+Ck+Dk+1. Then, we have

𝔼[X∣E1,…,Ek−1,Ik=0]≤𝔼[Y∣E1,…,Ek−1],

where Bk=Bk−1, Ck=Ck−1, and Dk=Dk−1−1. X and Y have N−k edges to go, but X has one fewer edge not decreasing the number of isolated vertices, making it more likely to decrease the number of isolated vertices. ∎