Indicator Variables and Expected Work

Convert a count into a sum of events and use linearity of expectation even when those events are dependent.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Decompose a statistic into yes-or-no contributions
  2. Attach the count to actual operations

Decompose a statistic into yes-or-no contributions

For a uniformly random permutation of \(n\) distinct values, let \(I_{ij}\) indicate that positions \(i<j\) are inverted. Swapping those two positions pairs permutations with and without that inversion, so each indicator has mean one-half. The expected total inversion count is

\[ \mathbb E\left[\sum_{i<j}I_{ij}\right]=\frac{n(n-1)}4. \]

The indicators can be dependent. Knowing several comparisons can imply another through transitivity. Linearity of expectation does not require independence.

Attach the count to actual operations

Insertion sort swaps adjacent inverted elements until order is restored. Each adjacent swap removes exactly one inversion, so the expected swap count on a random permutation equals the value above. Reverse order realizes twice that expectation. An expectation alone gives no good estimate of tail frequency. Markov and Chebyshev bounds use more information about the random variable. Randomized selection instead designs the sampling so that typical subproblems shrink quickly.[1][2]

References

  1. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩
  2. Michael Mitzenmacher and Eli Upfal, Probability and Computing ↩