# Striking applications of linearity of expectation

Linearity of expectation is a very simple and “obvious” statement, but has many non-trivial applications, e.g., to analyze randomized algorithms (for instance, the coupon collector’s problem), or in some proofs where dealing with non-independent random variables would otherwise make any calculation daunting.

What are the cleanest, most elegant, or striking applications of the linearity of expectation you’ve encountered?

Buffon’s needle: rule a surface with parallel lines a distance $$dd$$ apart. What is the probability that a randomly dropped needle of length $$ℓ≤d\ell\leq d$$ crosses a line?
Consider dropping any (continuous) curve of length $$ℓ\ell$$ onto the surface. Imagine dividing up the curve into $$NN$$ straight line segments, each of length $$ℓ/N\ell/N$$. Let $$XiX_i$$ be the indicator for the $$ii$$-th segment crossing a line. Then if $$XX$$ is the total number of times the curve crosses a line,
$$E[X]=E[∑Xi]=∑E[Xi]=N⋅E[X1].\mathbb E[X]=\mathbb E\left[\sum X_i\right]=\sum\mathbb E[X_i]=N\cdot\mathbb E[X_1].$$
Now we need to fix the constant of proportionality. Take the curve to be a circle of diameter $$dd$$. Almost surely, this curve will cross a line twice. The length of the circle is $$πd\pi d$$, so a curve of length $$ℓ\ell$$ crosses a line $$2ℓπd\frac{2\ell}{\pi d}$$ times.
Now observe that a straight needle of length $$ℓ≤d\ell\leq d$$ can cross a line either $$00$$ or $$11$$ times. So the probability it crosses a line is precisely this expectation value $$2ℓπd\frac{2\ell}{\pi d}$$.