A sequence of random variables is a martingale with respect to another sequence if for all , the following conditions hold:
is a function of .
.
.
A sequence of random variables is called a martingale when it is a martingale with respect to itself, that is
.
.
Consider a gambler who plays a sequence of fair games. Let be the winning on the game, that is either or , and be the gambler’s total winning of the first games. Since and
then by linearity of expectation,
where the second equality holds as on any input of by fair game.
Thus, is a martingale with respect to the sequence .
Let be a sequence of random variables, and let . Show that is a martingale with respect to , then for all , .
If is a martingale with respect to , then by definition 1.13.1,
where the second equality holds by linearity of expectation, then for all ,
Hence, on an and any , conditioned that ,
Therefore, we conclude the proof by
∎
Show that if is a martingale with respect to , then it is a martingale with respect to itself.
By definition 1.2.6 and lemma 1.2.7, we use the tower property
for random variables such that is determined by , or carries at least as much information as , or can be obtained from from some function.
Since is a martingale with respect to , then by definition 1.13.1, for all ,
By the prior fact,
Yet by definition 1.13.1,
Therefore we conclude by . ∎
Let be independent identically distributed random variables with expectation 0 and variance . Let
Show that is a martingale.
Let , then . Since , then . We show as follows: For ,
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. ∎
Let be a sequence of random variables, and be a random variable depending on with , then for ,
gives a martingale with respect to , as
where the second equality holds by lemma 1.2.7 and definition 1.2.6.
One can view the Doob Martingale as a sequence of refined predictions to , where each element is the expectation of when the values of are known. Hence, the refined predictions gradually using more information on the values of the random variables .
Let and for , is chosen uniformly over real interval . Show that, for , the sequence is a martingale.
Since depends only on , then
Moreover, since , then
By , we show that
which concludes the proof. ∎
If is a martingale with respect to , then for any .
By definition 1.13.1, for any
Given that
we have
By induction, we have , then
which concludes the proof. ∎
The Galton-Watson process was used in theorem 1.6.60, but was originally used to statistically investigate the extinction of family names. Let be the random variable for the individuals in the generation, and be the number of offspring of the individual in the generation. Each individual gives birth to offspring independently, and their numbers of offspring are identically distributed. Hence,
and let . By linearity of expectation,
Let , then
and we have
On the other hand,
which makes a martingale.
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 where there are balls in the urn. Let be the number of black balls in the urn, and be the ratio of black balls in the urn. Then for all ,
which makes a martingale.
By lemma 1.13.9, if the number of games is fixed initially, then the expected gain from the fair games is , if . 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.
A nonnegative integer-valued random variable is a stopping time for the sequence if the probability of the event is independent of the variables , which are the random variables conditioned on the values of .
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 that maintain the property . The subtle problem is that, 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 .
If is a martingale with respect to and if is a stopping time for , then
whenever one of the following holds:
The is bounded, such that there exists constant for all , .
is bounded.
, and there is a constant such that .
Consider the gambler’s ruin example 1.7.51, stopping by either losing or winning . Let be the winning in the game, be the winning by the end of the game, and . Show that is a martingale, and let be a stopping time, determine and .
Since and , by 1.13.5, is a martingale.
We have shown in 1.7.68 that .
The theorem 1.13.13 applies by
then , which means . Since can either be or , by example 1.7.51 161616 Now we can show by is a martingale in example 1.13.2, then , to derive the winning or losing probabilities. ,
which derives in a martingale way. ∎
Consider the gambler’s ruin example 1.7.51, stopping by either losing or winning , and winning probability . Let be the winning in the game, and be the winning by the end of the game.
Show that
is a martingale with mean 1.
Determine the probability that the player wins before losing .
Show that is a martingale with mean 0.
Let be the stopping time when the player finishes playing. Determine and .
With this martingale, then let be the probability of being absorbed into , and
such that
Since , then by linearity of expectation,
the second equality holds by the independence of the games. Hence, is a martingale by 1.13.4.
Suppose there are 2 candidates running an election, where candidate A obtains votes, and candidate B obtains 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 .
Let , and let be the leading votes of A to B after votes. Then . For , let
We first show that is a martingale. Since
where the first equality holds by is only related to counting backwards, and the second equality holds by the probability of the vote being A or B, conditioned on , then
and
which completes the proof of martingale.
Moreover, define a stopping for the first , otherwise , then since is bounded, and is also bounded, by theorem 1.13.13,
By the stopping time , the voting is either A and B are drawing, or A leads throughout the votes. In the first case, as , otherwise, as . Hence,
which completes the proof.
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 moves, the particle moves from to . An observation is, if A is ahead in the count throughout, then the particle is constantly below the line (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 at least once. The reflection trick is: we can always reflect a trajectory above the diagonal to the symmetry one below the diagonal , such that the move is still a bad move, but the move is beginning with a vote for A to .
Since all the valid trajectories begin with a vote for A, we just exclude all the bad trajectories beginning with , and all such bad trajectories can be reflected to the trajectories beginning with .
Therefore, the number of valid trajectories is
When , this deteriorates to lemma 1.7.67, which are Dycks path and Catalans number .
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.
Let be independent, identically distributed random variables with distribution , and be a stopping time for this sequence. If and have bounded expectation, then
We first show a version for the nonnegative random variables. For , let
then is a martingale with respect to , with by 1.13.15.
Since , and
| (1.25) |
then by theorem 1.13.13,
Therefore, by linearity of expectation,
which completes the proof.
In general case, where is any random variable, the main trick is writing , where
Hence, write for all , and by the prior nonnegative case,
By linearity of expectation,
we conclude the proof for the general case. ∎
Since is a stopping time for , then event is dependent only on by definition 1.13.12. The mutual independence over ensures that is independent of past , hence is independent of . 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.
Let be a sequence of independent random variables. A nonnegative, integer-valued random variable is a stopping time for the sequence if the event is independent of .
Consider a gambling game where a player first rolls a die. If the outcome is then roll new standard dice and gain , which is the sum of the outcome of the 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 be the stopping time, and be i.i.d. random variables for dice rolling scores with distribution . Then by theorem 1.13.18,
if the die is a faced fair die.
Consider 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 .
Let be the independent 0-1 random variables for a successful packet transmission on the time slot with distribution , then
Similar to section 1.5.1, let
then
Let , and means , then . Therefore, when , since
then is a lower bound by
Let 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,
Let be the number of time slots between the successful transmission and the successful transmission. Then are independent and geometrically distributed with success probability , therefore . Moreover, whichever server successfully transmitted a packet is independent of the waiting times , so the Wald argument applies to this sum. By theorem 1.13.18,
A parking-lot attendant has mixed up keys for cars. The 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 be the number of rounds until all car owners receive their keys, and let be the number of owners who receive their car keys in the round. Show that
is a martingale, and use theorem 1.13.13 to derive .
To show that is a martingale, we have
Since both and are in , then by triangle inequality and tower property,
we can apply theorem 1.13.13, that
Moreover, by 1.2.4, for ,
Hence, by the stopping time , we have
Since by stopping time ,
we have . ∎
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 , independent of other games. The number of minutes for each game is uniformly distributed over the integers in , again independent of other games. What is the expected time they spend playing this match?
Let be the time used in the game with distribution , then .
Let be the stopping time, and WLOG let Alice win, as Bob wins symmetrically. Since Alice wins the final game, then there are ways to finish in 4 games, ways to finish in 5 games, ways to finish in 6 games, ways to finish in 7 games. The expected number of games is
By theorem 1.13.18,
∎
Consider the following algorithm for sorting numbers. Start by choosing one of the numbers uniformly at random, and place it first. Then choose one of the remaining 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 numbers uniformly at random, place it third, and so on. The algorithm starts over from the beginning whenever it finds that the item placed is smaller than the item. Determine the expected number of times the algorithm tries to place a number, assuming that the input consists of distinct numbers.
Let be the random variables of the lengths of the incremental sequences drawn from the distinct numbers, then by the stopping time , . Since the success probability of drawing an incremental sequence of length is , then .
Let be the random variables for the prefix sequence of length , then we have
as each permutation is uniformly distributed. Hence,
and the expectation of the length of incremental sequence is
the upper bound can be seen in section 1.5.1.
Suppose we are arranging a chain of 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 . 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 components, each of size , 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.
Let be the longest length of a domino arrangement, and be the stopping time, such that . Since is geometrically distributed for the number of steps to the first failure, and are i.i.d., then . On the other hand, is also geometrically distributed with success probability , therefore .
Hence, by theorem 1.13.18,
When there are segments of sub-arrangements, the expected number of trials to finish a segment is , and by linearity of expectation, the expected number of trials to finish all pieces is . ∎
Use theorem 1.13.18 to derive the following .
Let be independent exponential random variables with . Given , define
Let be independent uniform random variables in . Given , define
Let . Since , by theorem 1.13.18,
Moreover, since are exponential random variables, then by the memorylessness property, for any ,
Given that , and , we have , then
holds for any , therefore .
For , let , then the stopping time is defined as
and by
Let , by theorem 1.13.18,
Since , while , we have . Moreover,
as they are the same event. Hence, for all ,
which proves that .
Another way of showing is, is an exponential random variable with probability density function , hence . Applying the prior result, the threshold is , and . ∎
Azuma-Hoeffding says a martingale with bounded increment per step has total gain concentrating around 0, even if the steps are not independent.
Let be a martingale such that
then for all and ,
The proof is similar to theorem 1.4.10, using moment-generating functions.
Start by bounding the upper tail. Let , such that , and since is a martingale,
| (1.26) |
Write
Since is a convex function, by theorem 1.2.5,
Now consider
| (1.27) |
By section 1.5.1,
Since ,
| (1.28) |
To bound the exponential moment used in Markov’s inequality, similar to the Chernoff and Hoeffding bounds,
| (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,
| (1.30) |
where the last inequality is by minimizing at .
Let be a martingale such that
for some constant and random variables that may be functions of . Then for all and ,
Start with the upper tail. Let , and by eq. 1.26. Consider bounding the exponential moment as in eq. 1.29:
By lemma 1.4.8,
By induction,
| (1.31) |
We conclude by
| (1.32) |
where the last inequality is by minimizing at .
To bound the lower tail, let , then by the same proof in eq. 1.26, and
by lemma 1.4.8. We conclude the lower bound by eq. 1.31 and eq. 1.32. ∎
Given a bag with red balls and green balls, suppose that we uniformly sample balls from the bag without replacement. Use Azuma-Hoeffding to show that the number of red balls in the sample concentrates tightly around .
Let be 0-1 random variables indicating if the draw is a red ball, and let be the random variable for the total number of red balls drawn. Then
is a Doob martingale. Let , such that . Then
The difference is
The upper bound is
The lower bound is
Given that , and by linearity of expectation, we conclude with theorem 1.13.28
∎
Interestingly, if we let be the fraction of the remaining red balls in 1.13.30, it is also a martingale. Indeed,
Moreover, is a Doob martingale with respect to itself, and lemma 1.13.9,
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.
A function is said to satisfy a Lipschitz condition with bound if for any and any set of values and ,
That is, changing the value of any single coordinate can change the function value by at most .
Let
The sequence is a Doob martingale. Moreover, we claim if are mutually independent, then there exist random variables such that for all ,
We have a counterexample for the dependent case: Let be the random variables drawn from the same fair coin toss , and , with a Lipschitz condition bound . Then,
Now has a range much larger than , so the claim of existence of does not hold.
Another counterexample is as follows. Let be independent random variables drawn from fair coin tosses, and let be random variables equal to the same fair coin toss . Let , so
The difference has a range , so the claim fails.
Let be a function on variables that satisfies the Lipschitz condition in definition 1.13.32 with bound . Let be independent random variables that are in the domain of . Then
Let denote , simplify as , and let .
Consider the upper bound and the lower bound of , where is upper bounded by
and is lower bounded by , defined as 171717 If here have support (the possible value taken) being finite number of values, we can use and to substitute and .
Then consider the range between the upper and lower bound of :
| (1.33) |
where the last equality holds because is independent of ; this follows from conditional probability,
Since satisfies the Lipschitz condition with bound , and are independent, eq. 1.33 is at most . We conclude the proof with theorem 1.13.29. ∎
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 . Independence says that revealing does not alter the conditional probability distribution of the unrevealed random variables, as they do not depend on . Therefore, the effect of revealing can be compared as if only the coordinate changes, such that the martingale difference is bounded by the same .
In the bin-packing problem, we are given items with sizes with . 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 is chosen independently according to some distribution, let be the number of bins required in the best packing of the resulting items. Prove that
Let be the minimum number of bins needed to pack items. Then the Lipschitz condition bound of is at most 1, since a bin has capacity at most 1. Starting with bins, and changing to , the worst one can do is to put in a separate bin and preserve the arrangement for the other items. Hence
We then conclude the proof with theorem 1.13.33 with . ∎
Consider an -cube with . Let with , and . Let be the minimum number of coordinates in which and differ over all points . Give a bound on
Let be independent fair coin tosses, , and . Let be the Hamming distance from to , which is , and we have the following:
If is still the closest element in , then either and , or and .
, where , but there is an element that disagrees in coordinates with , and .
Alternatively, changing one coordinate either increases or decreases the distance to any element in by 1. Thus, the Lipschitz condition bound . We conclude with theorem 1.13.33 that
∎
Consider generalizing Hoeffding’s bound to independent random variables ranging in , and derive a tail bound for .
Consider a Doob martingale over
and has Lipschitz condition bound . Immediately by theorem 1.13.33,
∎
Let be a sequence of characters sampled independently and uniformly at random over an alphabet , and let be a fixed pattern string of characters. Let be the number of occurrences of in the random string . By linearity of expectation, . Let
be a Doob martingale. Using , theorem 1.13.28 gives
Taking a closer look, is rather wasteful, as as a function over has Lipschitz condition bound . Thus, by theorem 1.13.33 or theorem 1.13.29,
A subsequence of a string is any string that can be obtained by deleting characters. Consider , and the longest common subsequence (LCS) of and . Show that the expected length of the LCS is in where and when 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.
Let be the length of the LCS of two binary strings of length . Then we have
as with probability , and with non-zero probability when .
Let for the bit in and . The Doob martingale is constructed by
The Lipschitz condition bound is , as any common subsequence’s length increases or decreases by 1:
Either the previous LCS remains, no matter what new assignment to the coordinate.
Or the LCS length is unchanged, but altering the bits improves another common subsequence.
Hence, we conclude with theorem 1.13.33 by
∎
Recall in balls and bins model, we let be the random variables for the bin into which the ball falls, and let be the number of empty bins after bins are thrown. Then
is a Doob martingale. Moreover, the Lipschitz condition bound is 1, as changing which bin the ball lands increases or decreases the number of empty bins after balls at most by 1. We conclude with theorem 1.13.33 that
and the expected number of empty bins is .
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 , where is the number of data items, is the number of hash functions, and is the size of the Bloom filter in bits. Derive a similar concentration result using a martingale inequality.
This is a direct adaptation of example 1.13.40, using a balls and bins model. Let be the 0-1 random variables for which bit the hash hits, and be the number of 0 bits after items, then , and
is a Doob martingale, and is a function over with Lipschitz condition bound . By theorem 1.13.33,
∎
We improve the bound in example 1.13.40 and reuse all defined notations. Let denote the number of bins that are empty after the ball is thrown.
Show that .
Show that, if the ball lands in a bin that is empty, .
Show that, if the ball lands in a bin that is not empty, .
Show that theorem 1.13.29 applies with , and
The probability of a bin remaining empty after balls is . By linearity of expectation,
Whether the ball lands into an empty bin or not determines the number of empty bins onwards after the ball. If the ball lands into an empty bin, ; otherwise, . Still by linearity of expectation,
Let , then such that . By theorem 1.13.29,
which proves
∎
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.
Given a random graph in , the chromatic number is the minimum number of colors needed to color all vertices of the graph, so no adjacent vertices have the same color.
Let be the random subgraph induced by the set of vertices , so depends on . Then
forms a Doob martingale.
Now consider bounding . For , formed by removing the vertex,
| (1.34) |
where the first inequality holds because has one less vertex than , and the second inequality holds because adding to introduces at most one more new color.
Hence, consider and differing only on the edges between and . Then . By eq. 1.34, it is immediate that
Moreover, since for any and differing on the edges to , , for any ,
Thus for theorem 1.13.29, and we conclude that
Consider a random graph in where for . Let be the number of isolated vertices, namely vertices of degree 0. Determine and show
Let be the 0-1 random variable for the vertex being unconnected to any of edges, and is the total number of possible edges. Then there are
graphs isolating the vertex, and
By linearity of expectation,
Let be random variables in for the location of the edge, and
is a Doob martingale. An edge can decrease by 2 by joining 2 isolated vertices, so , and we conclude with theorem 1.13.28
An alternative way to further bound follows. Let be the number of isolated vertices removed by the , be the number of isolated vertices after the , such that . A vertex remains isolated with probability
Moreover, we have the following iteration
By linearity of expectation, . Then
| (1.35) |
Notice that
and conditioned on is in . Hence eq. 1.35 is of interval length , and we conclude with theorem 1.13.29
A few notes from prior attempts follow. We have
Let be the number of isolated vertices for a graph in . We have
since the edge can still remove isolated vertices by
Let be the number of edges removing 2 isolated vertices, be the number of edges removing 1 isolated vertex, and be the number of edges removing 0 isolated vertex. For and , the invariant is
Then, we have
as , , and in this case. Similarly,
as , , and . Then, we have
where , , and . and have edges to go, but has one fewer edge not decreasing the number of isolated vertices, making it more likely to decrease the number of isolated vertices. ∎