Markov and Chebyshev: A Short Recap
A tail bound turns information about a random variable (its mean, its variance, its moment-generating function) into an upper bound on the probability that it is far from typical. The two classical bounds, Markov's and Chebyshev's inequalities, are proved and practised in Markov's and Chebyshev's Inequalities and Deviation from the Mean. This lesson restates them in the form algorithms use, adds two facts that matter later (Chebyshev needs only pairwise independence, and the second-moment method proves that something exists), and shows why they are not enough for most randomized algorithms.
The two inequalities
Markov. If and , then
Proof: pointwise; take expectations.
Chebyshev. If has finite variance and , then
Proof: apply Markov to the nonnegative variable and the threshold .
The proof of Chebyshev is a template: apply Markov to a well-chosen nonnegative function of . Chebyshev uses the square; using instead will give the Chernoff bounds of the next lesson.
Variance of a sum, and why pairwise independence suffices
For ,
If the are pairwise independent (every two of them are independent, but triples need not be), all covariances vanish and the variances simply add. So Chebyshev's bound for a sum holds under pairwise independence, which is much cheaper to produce than full independence: pairwise independent bits can be generated from about truly random bits (Pairwise Independence and Small Sample Spaces). The program checks this on a classical construction: from 3 random bits , take the 7 XORs of their nonempty subsets.
from itertools import product, combinations
subsets = [s for r in range(1, 4) for s in combinations(range(3), r)]
rows = []
for bits in product([0, 1], repeat=3): # all 8 equally likely seeds
rows.append([sum(bits[i] for i in s) % 2 for s in subsets])
n = len(subsets)
pairwise = all(sum(r[i] == a and r[j] == b for r in rows) == 2
for i, j in combinations(range(n), 2) for a in (0, 1) for b in (0, 1))
print(f"{n} bits from 3 fair coin flips; each pair uniform on {{0,1}}^2: {pairwise}")
print("subsets:", subsets)
print("but bit 3 is always bit 0 xor bit 1:", all(r[3] == r[0] ^ r[1] for r in rows))
sums = [sum(r) for r in rows]
mean = sum(sums) / 8
var = sum((s - mean) ** 2 for s in sums) / 8
print(f"sum of the 7 bits: mean {mean}, variance {var}, sum of variances {n * 0.25}")7 bits from 3 fair coin flips; each pair uniform on {0,1}^2: True
subsets: [(0,), (1,), (2,), (0, 1), (0, 2), (1, 2), (0, 1, 2)]
but bit 3 is always bit 0 xor bit 1: True
sum of the 7 bits: mean 3.5, variance 1.75, sum of variances 1.75
The variance of the sum equals the sum of the variances, exactly as for independent bits, although the seven bits are far from independent.
The second-moment method
Chebyshev also proves that a nonnegative integer variable is positive with good probability. With ,
So if the variance is small compared with the squared mean, almost surely. This is the standard way to prove lower bounds in random structures: to show that the fullest of bins gets at least about balls, let count the bins with that many balls and show that (Balls into Bins: The Maximum Load).
How good are they?
For = the number of heads in fair coin flips, and . The program compares the exact probability of at least 60% heads with the two bounds as grows.
from math import comb
print(" n exact Pr[X >= 0.6n] Markov Chebyshev")
for n in [50, 100, 200, 500, 1000]:
k = (6 * n + 9) // 10 # smallest integer >= 0.6 n
exact = sum(comb(n, j) for j in range(k, n + 1)) / 2 ** n
markov = (n / 2) / k
cheb = (n / 4) / (k - n / 2) ** 2
print(f"{n:5} {exact:19.3e} {markov:9.4f} {cheb:9.4f}") n exact Pr[X >= 0.6n] Markov Chebyshev
50 1.013e-01 0.8333 0.5000
100 2.844e-02 0.8333 0.2500
200 2.843e-03 0.8333 0.1250
500 4.470e-06 0.8333 0.0500
1000 1.364e-10 0.8333 0.0250
Markov does not improve with at all, since it knows only the mean. Chebyshev improves like . The true probability falls exponentially in . For algorithms that must succeed in every one of independent places at once, a bound per place is useless under a union bound, while is plenty. The lab shows the same comparison for any , and threshold ; the Chernoff bar in it is the subject of the next lesson. With the default 100 fair flips and the exact tail is about 0.028, Markov gives 0.83 and Chebyshev 0.25.
When Chebyshev is the right tool
Chebyshev is tight for some distributions (put mass at and the rest at 0), so it cannot be improved without more information. It is the right tool when:
- the summands are only pairwise independent, as in hashing with a 2-universal family;
- only the variance is known, as for many streaming estimators, where the median trick then supplies the exponential decay;
- a lower bound is wanted via the second-moment method.
When the summands are fully independent and bounded, Chernoff and Hoeffding bounds give far more.
Test yourself
Markov's inequality requires which assumption?
- is a sum of independent variables
- has finite variance
- is bounded
Which independence assumption is enough for ?
- Full mutual independence only
- Pairwise independence
- No assumption at all
- 3-wise independence
For fair coin flips, how does Chebyshev's bound on behave as grows?
- It stays constant
- It decreases like
- It decreases exponentially
- It increases
The second-moment method bounds by which quantity?
- always