TExcelTAD
Home › Randomized Algorithms & Probabilistic Analysis › Markov and Chebyshev: A Short Recap

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 X≥0X \ge 0 and a>0a > 0, then

Pr⁡[X≥a]≤E[X]a.\Pr[X \ge a] \le \frac{\mathbb{E}[X]}{a}.

Proof: a⋅IX≥a≤Xa \cdot I_{X \ge a} \le X pointwise; take expectations.

Chebyshev. If XX has finite variance and a>0a > 0, then

Pr⁡[∣X−E[X]∣≥a]≤Var⁡[X]a2.\Pr\bigl[\lvert X - \mathbb{E}[X] \rvert \ge a\bigr] \le \frac{\operatorname{Var}[X]}{a^2}.

Proof: apply Markov to the nonnegative variable (X−E[X])2(X - \mathbb{E}[X])^2 and the threshold a2a^2.

The proof of Chebyshev is a template: apply Markov to a well-chosen nonnegative function of XX. Chebyshev uses the square; using etXe^{tX} instead will give the Chernoff bounds of the next lesson.

Variance of a sum, and why pairwise independence suffices

For X=X1+⋯+XnX = X_1 + \cdots + X_n,

Var⁡[X]=∑iVar⁡[Xi]+∑i≠jCov⁡[Xi,Xj].\operatorname{Var}[X] = \sum_{i} \operatorname{Var}[X_i] + \sum_{i \ne j} \operatorname{Cov}[X_i, X_j].

If the XiX_i 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: nn pairwise independent bits can be generated from about lg⁡n\lg n truly random bits (Pairwise Independence and Small Sample Spaces). The program checks this on a classical construction: from 3 random bits b1,b2,b3b_1, b_2, b_3, take the 7 XORs of their nonempty subsets.

python · try it yourself
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 a=E[X]a = \mathbb{E}[X],

Pr⁡[X=0]≤Pr⁡[∣X−E[X]∣≥E[X]]≤Var⁡[X]E[X]2.\Pr[X = 0] \le \Pr\bigl[\lvert X - \mathbb{E}[X] \rvert \ge \mathbb{E}[X]\bigr] \le \frac{\operatorname{Var}[X]}{\mathbb{E}[X]^2}.

So if the variance is small compared with the squared mean, X>0X > 0 almost surely. This is the standard way to prove lower bounds in random structures: to show that the fullest of nn bins gets at least about ln⁡n/ln⁡ln⁡n\ln n / \ln \ln n balls, let XX count the bins with that many balls and show that Var⁡[X]=o(E[X]2)\operatorname{Var}[X] = o(\mathbb{E}[X]^2) (Balls into Bins: The Maximum Load).

How good are they?

For XX = the number of heads in nn fair coin flips, μ=n/2\mu = n/2 and Var⁡[X]=n/4\operatorname{Var}[X] = n/4. The program compares the exact probability of at least 60% heads with the two bounds as nn grows.

python · try it yourself
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 nn at all, since it knows only the mean. Chebyshev improves like 1/n1/n. The true probability falls exponentially in nn. For algorithms that must succeed in every one of nn independent places at once, a 1/n1/n bound per place is useless under a union bound, while e−cne^{-cn} is plenty. The lab shows the same comparison for any nn, pp and threshold (1+δ)μ(1 + \delta)\mu; the Chernoff bar in it is the subject of the next lesson. With the default 100 fair flips and δ=0.2\delta = 0.2 the exact tail is about 0.028, Markov gives 0.83 and Chebyshev 0.25.

00.0800μ = 50100heads kP(X = k)a = 60P(X ≥ a) vs bounds, log scaleexact0.0284Chernoff0.4029Chebyshev0.2500Markov0.8333

When Chebyshev is the right tool

Chebyshev is tight for some distributions (put mass 12a2\frac{1}{2a^2} at ±a\pm a 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?

  1. XX is a sum of independent variables
  2. X≥0X \ge 0
  3. XX has finite variance
  4. XX is bounded

Which independence assumption is enough for Var⁡[X1+⋯+Xn]=∑iVar⁡[Xi]\operatorname{Var}[X_1 + \cdots + X_n] = \sum_i \operatorname{Var}[X_i]?

  1. Full mutual independence only
  2. Pairwise independence
  3. No assumption at all
  4. 3-wise independence

For nn fair coin flips, how does Chebyshev's bound on Pr⁡[X≥0.6n]\Pr[X \ge 0.6n] behave as nn grows?

  1. It stays constant
  2. It decreases like 1/n1/n
  3. It decreases exponentially
  4. It increases

The second-moment method bounds Pr⁡[X=0]\Pr[X = 0] by which quantity?

  1. E[X]\mathbb{E}[X]
  2. Var⁡[X]/E[X]2\operatorname{Var}[X]/\mathbb{E}[X]^2
  3. 1/E[X]1/\mathbb{E}[X] always
  4. e−E[X]e^{-\mathbb{E}[X]}