McDiarmid's inequality

In probability theory and theoretical computer science, McDiarmid's inequality (named after Colin McDiarmid ) is a concentration inequality which bounds the deviation between the sampled value and the expected value of certain functions when they are evaluated on independent random variables. McDiarmid's inequality applies to functions that satisfy a bounded differences property, meaning that replacing a single argument to the function while leaving all other arguments unchanged cannot cause too large of a change in the value of the function.

Statement
A function $$f: \mathcal{X}_1 \times \mathcal{X}_2 \times \cdots \times \mathcal{X}_n \rightarrow \mathbb{R} $$ satisfies the bounded differences property if substituting the value of the $$i$$th coordinate $$x_i$$ changes the value of $$f$$ by at most $$c_i$$. More formally, if there are constants $$c_1, c_2, \dots, c_n$$ such that for all $$i\in[n]$$, and all $$x_1\in \mathcal{X}_1,\,x_2\in \mathcal{X}_2,\, \ldots,\, x_n \in \mathcal{X}_n$$,

\sup_{x_i' \in \mathcal{X}_i} \left|f(x_1, \dots, x_{i-1}, x_i, x_{i+1}, \ldots, x_n) - f(x_1, \dots, x_{i-1}, x_i', x_{i+1}, \ldots, x_n)\right| \leq c_i. $$

$$

Unbalanced distributions
A stronger bound may be given when the arguments to the function are sampled from unbalanced distributions, such that resampling a single argument rarely causes a large change to the function value.

$$

This may be used to characterize, for example, the value of a function on graphs when evaluated on sparse random graphs and hypergraphs, since in a sparse random graph, it is much more likely for any particular edge to be missing than to be present.

Differences bounded with high probability
McDiarmid's inequality may be extended to the case where the function being analyzed does not strictly satisfy the bounded differences property, but large differences remain very rare.

$$

There exist stronger refinements to this analysis in some distribution-dependent scenarios, such as those that arise in learning theory.

Sub-Gaussian and sub-exponential norms
Let the $$k$$th centered conditional version of a function $$f$$ be
 * $$f_k(X)(x) := f(x_1, \ldots, x_{k-1}, X_k, x_{k+1}, \ldots, x_n) - \mathbb{E}_{X'_k}f(x_1, \ldots, x_{k-1}, X'_k, x_{k+1}, \ldots, x_n),$$

so that $$f_k(X)$$ is a random variable depending on random values of $$x_1, \ldots, x_{k-1}, x_{k+1}, \ldots, x_n$$.

$$

$$

Bennett and Bernstein forms
Refinements to McDiarmid's inequality in the style of Bennett's inequality and Bernstein inequalities are made possible by defining a variance term for each function argument. Let
 * $$\begin{align}

B &:= \max_{k \in [n]} \sup_{x_1, \dots, x_{k-1}, x_{k+1}, \dots, x_{n}} \left|f(x_1, \dots, x_{k-1}, X_k, x_{k+1}, \dots, x_n) - \mathbb{E}_{X_k}f(x_1, \dots, x_{k-1}, X_k, x_{k+1}, \dots, x_n)\right|, \\ V_k &:= \sup_{x_1, \dots, x_{k-1}, x_{k+1}, \dots, x_{n}} \mathbb{E}_{X_k} \left(f(x_1, \dots, x_{k-1}, X_k, x_{k+1}, \dots, x_n) - \mathbb{E}_{X_k}f(x_1, \dots, x_{k-1}, X_k, x_{k+1}, \dots, x_n)\right)^2, \\ \tilde \sigma^2 &:= \sum_{k=1}^n V_k. \end{align}$$

$$ $$

Proof
The following proof of McDiarmid's inequality constructs the Doob martingale tracking the conditional expected value of the function as more and more of its arguments are sampled and conditioned on, and then applies a martingale concentration inequality (Azuma's inequality). An alternate argument avoiding the use of martingales also exists, taking advantage of the independence of the function arguments to provide a Chernoff-bound-like argument.

For better readability, we will introduce a notational shorthand: $$z_{i \rightharpoondown j}$$ will denote $$z_i, \dots, z_j$$ for any $$z \in \mathcal{X}^n$$ and integers $$1 \le i \le j \le n$$, so that, for example,
 * $$f(X_{1 \rightharpoondown (i-1)}, y, x_{(i+1) \rightharpoondown n}) := f(X_1, \ldots, X_{i-1}, y, x_{i+1}, \ldots, x_n).$$

Pick any $$x_1', x_2', \ldots, x_n'$$. Then, for any $$x_1, x_2, \ldots, x_n$$, by triangle inequality,

\begin{align} &|f(x_{1 \rightharpoondown n}) - f(x'_{1 \rightharpoondown n})| \\[6pt] \leq {} & |f(x_{1 \rightharpoondown\, n}) - f(x'_{1 \rightharpoondown (n-1)}, x_n)| + c_n\\ \leq {} & |f(x_{1 \rightharpoondown n}) - f(x'_{1 \rightharpoondown (n-2)}, x_{(n-1) \rightharpoondown n})| + c_{n-1} + c_n\\ \leq {} & \ldots \\ \leq {} & \sum_{i=1}^n c_i , \end{align} $$ and thus $$f$$ is bounded.

Since $$f$$ is bounded, define the Doob martingale $$\{Z_i\}$$ (each $$Z_i$$ being a random variable depending on the random values of $$X_1, \ldots, X_i$$) as
 * $$Z_i:=\mathbb{E}[f(X_{1 \rightharpoondown n}) \mid X_{1 \rightharpoondown i} ]$$

for all $$i\geq 1$$ and $$Z_0: = \mathbb{E}[f(X_{1 \rightharpoondown n})]$$, so that $$Z_n = f(X_{1 \rightharpoondown n})$$.

Now define the random variables for each $$i$$

\begin{align} U_i &:= \sup_{x \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, x, X_{(i+1) \rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}, X_i = x] - \mathbb[f(X_{1 \rightharpoondown (i-1)}, X_{i\rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}], \\ L_i &:= \inf_{x \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, x, X_{(i+1) \rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}, X_i = x] - \mathbb[f(X_{1 \rightharpoondown (i-1)}, X_{i\rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}]. \\ \end{align} $$ Since $$X_i, \ldots, X_n$$ are independent of each other, conditioning on $$X_i = x$$ does not affect the probabilities of the other variables, so these are equal to the expressions

\begin{align} U_i &= \sup_{x \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, x, X_{(i+1) \rightharpoondown n}) - f(X_{1 \rightharpoondown (i-1)}, X_{i\rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}], \\ L_i &= \inf_{x \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, x, X_{(i+1) \rightharpoondown n}) - f(X_{1 \rightharpoondown (i-1)}, X_{i\rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}]. \\ \end{align} $$

Note that $$L_i \leq Z_i - Z_{i-1} \leq U_i$$. In addition,

\begin{align} U_i - L_i &= \sup_{u\in \mathcal{X}_i, \ell \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, u, X_{(i+1) \rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}] -\mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, \ell, X_{(i+1) \rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}] \\[6pt] &=\sup_{u\in \mathcal{X}_i, \ell \in \mathcal{X}_i} \mathbb{E}[f(X_{1 \rightharpoondown (i-1)}, u, X_{(i+1) \rightharpoondown n}) - f(X_{1 \rightharpoondown (i-1)}, l, X_{(i+1) \rightharpoondown n}) \mid X_{1 \rightharpoondown (i-1)}] \\ &\leq \sup_{x_u\in \mathcal{X}_i, x_l \in \mathcal{X}_i} \mathbb{E}[c_i \mid X_{1 \rightharpoondown (i-1)}] \\[6pt] &\leq c_i \end{align} $$ Then, applying the general form of Azuma's inequality to $$\left\{Z_i\right\}$$, we have

\text{P}(f(X_1, \ldots, X_n) - \mathbb{E}[f(X_1, \ldots, X_n) ] \geq \varepsilon ) = \operatorname{P}(Z_n - Z_0 \geq \varepsilon) \leq \exp \left(-\frac{2\varepsilon^2}{\sum_{i=1}^n c_i^2}\right). $$ The one-sided bound in the other direction is obtained by applying Azuma's inequality to $$\left\{-Z_i\right\}$$ and the two-sided bound follows from a union bound. $$\square$$