# Stein's method

Stein's method is a general method in probability theory to obtain bounds on the distance between two probability distributions with respect to a probability metric. It was introduced by Charles Stein, who first published it in 1972, to obtain a bound between the distribution of a sum of $m$-dependent sequence of random variables and a standard normal distribution in the Kolmogorov (uniform) metric and hence to prove not only a central limit theorem, but also bounds on the rates of convergence for the given metric.

## History

At the end of the 1960s, unsatisfied with the by-then known proofs of a specific central limit theorem, Charles Stein developed a new way of proving the theorem for his statistics lecture. His seminal paper was presented in 1970 at the sixth Berkeley Symposium and published in the corresponding proceedings.
Later, his Ph.D. student Louis Chen Hsiao Yun modified the method so as to obtain approximation results for the Poisson distribution; therefore the Stein method applied to the problem of Poisson approximation is often referred to as the Stein–Chen method.
Probably the most important contributions are the monograph by Stein (1986), where he presents his view of the method and the concept of auxiliary randomisation, in particular using exchangeable pairs, and the articles by Barbour (1988) and Götze (1991), who introduced the so-called generator interpretation, which made it possible to easily adapt the method to many other probability distributions. An important contribution was also an article by Bolthausen (1984) on the so-called combinatorial central limit theorem.
In the 1990s the method was adapted to a variety of distributions, such as Gaussian processes by Barbour (1990), the binomial distribution by Ehm (1991), Poisson processes by Barbour and Brown (1992), the Gamma distribution by Luk (1994), and many others.
The method gained further popularity in the machine learning community in the mid 2010s, following the development of computable Stein discrepancies and the diverse applications and algorithms based on them.

## The basic approach
### Probability metrics

Stein's method is a way to bound the distance between two probability distributions using a specific probability metric.
Let the metric be given in the form
    $(1.1)\quad d(P,Q)=\sup _{h\in {\mathcal {H}}}\left|\int h\,dP-\int h\,dQ\right|=\sup _{h\in {\mathcal {H}}}\left|Eh(W)-Eh(Y)\right|$
Here, $P$ and $Q$ are probability measures on a measurable space ${\mathcal {X}}$, $W$ and $Y$ are random variables with distribution $P$ and $Q$ respectively, $E$ is the usual expectation operator and ${\mathcal {H}}$ is a set of functions from ${\mathcal {X}}$ to the set of real numbers. Set ${\mathcal {H}}$ has to be large enough, so that the above definition indeed yields a metric.
Important examples are the total variation metric, where we let ${\mathcal {H}}$ consist of all the indicator functions of measurable sets, the Kolmogorov (uniform) metric for probability measures on the real numbers, where we consider all the half-line indicator functions, and the Lipschitz (first order Wasserstein; Kantorovich) metric, where the underlying space is itself a metric space and we take the set ${\mathcal {H}}$ to be all Lipschitz-continuous functions with Lipschitz-constant 1. However, note that not every metric can be represented in the form (1.1).
In what follows $P$ is a complicated distribution (e.g., the distribution of a sum of dependent random variables), which we want to approximate by a much simpler and tractable distribution $Q$ (e.g., the standard normal distribution).

### The Stein operator

We assume now that the distribution $Q$ is a fixed distribution; in what follows we shall in particular consider the case where $Q$ is the standard normal distribution, which serves as a classical example.
First of all, we need an operator ${\mathcal {A}}$, which acts on functions $f$ from ${\mathcal {X}}$ to the set of real numbers and 'characterizes' distribution $Q$ in the sense that the following equivalence holds:
    $(2.1)\quad E[({\mathcal {A}}f)](Y):=E(({\mathcal {A}}f)(Y))=0{\text{ for all }}f\quad \iff \quad Y{\text{ has distribution }}Q.$
We call such an operator the Stein operator.
For the standard normal distribution, Stein's lemma yields such an operator:
    $(2.2)\quad E\left(f'(Y)-Yf(Y)\right)=0{\text{ for all }}f\in C_{b}^{1}\quad \iff \quad Y{\text{ has standard normal distribution.}}$
Thus, we can take
    $(2.3)\quad ({\mathcal {A}}f)(x)=f'(x)-xf(x).$
There are in general infinitely many such operators and it still remains an open question, which one to choose. However, it seems that for many distributions there is a particular good one, like (2.3) for the normal distribution.
There are different ways to find Stein operators.

### The Stein equation

$P$ is close to $Q$ with respect to $d$ if the difference of expectations in (1.1) is close to 0. We hope now that the operator ${\mathcal {A}}$ exhibits the same behavior: if $P=Q$ then $E({\mathcal {A}}f)(W)=0$, and hopefully if $P\approx Q$ we have $E({\mathcal {A}}f)(W)\approx 0$.
It is usually possible to define a function $f=f_{h}$ such that
    $(3.1)\quad ({\mathcal {A}}f)(x)=h(x)-E[h(Y)]\qquad {\text{ for all }}x.$
We call (3.1) the Stein equation. Replacing $x$ by $W$ and taking expectation with respect to $W$, we get
    $(3.2)\quad E({\mathcal {A}}f)(W)=E[h(W)]-E[h(Y)].$
Now all the effort is worthwhile only if the left-hand side of (3.2) is easier to bound than the right hand side. This is, surprisingly, often the case.
If $Q$ is the standard normal distribution and we use (2.3), then the corresponding Stein equation is
    $(3.3)\quad f'(x)-xf(x)=h(x)-E[h(Y)]\qquad {\text{for all }}x.$
If probability distribution Q has an absolutely continuous (with respect to the Lebesgue measure) density q, then
    $(3.4)\quad ({\mathcal {A}}f)(x)=f'(x)+f(x)q'(x)/q(x).$

### Solving the Stein equation

Analytic methods. Equation (3.3) can be easily solved explicitly:
    $(4.1)\quad f(x)=e^{x^{2}/2}\int _{-\infty }^{x}[h(s)-Eh(Y)]e^{-s^{2}/2}\,ds.$
Generator method. If ${\mathcal {A}}$ is the generator of a Markov process $(Z_{t})_{t\geq 0}$ (see Barbour (1988), Götze (1991)), then the solution to (3.2) is
    $(4.2)\quad f(x)=-\int _{0}^{\infty }[E^{x}h(Z_{t})-Eh(Y)]\,dt,$
where $E^{x}$ denotes expectation with respect to the process $Z$ being started in $x$. However, one still has to prove that the solution (4.2) exists for all desired functions $h\in {\mathcal {H}}$.

### Properties of the solution to the Stein equation

Usually, one tries to give bounds on $f$ and its derivatives (or differences) in terms of $h$ and its derivatives (or differences), that is, inequalities of the form
    $(5.1)\quad \|D^{k}f\|\leq C_{k,l}\|D^{l}h\|,$
for some specific $k,l=0,1,2,\dots$ (typically $k\geq l$ or $k\geq l-1$, respectively, depending on the form of the Stein operator), where often $\|\cdot \|$ is the supremum norm. Here, $D^{k}$ denotes the differential operator, but in discrete settings it usually refers to a difference operator. The constants $C_{k,l}$ may contain the parameters of the distribution $Q$. If there are any, they are often referred to as Stein factors.
In the case of (4.1) one can prove for the supremum norm that
    $(5.2)\quad \|f\|_{\infty }\leq \min \left\{{\sqrt {\pi /2}}\|h\|_{\infty },2\|h'\|_{\infty }\right\},\quad \|f'\|_{\infty }\leq \min\{2\|h\|_{\infty },4\|h'\|_{\infty }\},\quad \|f''\|_{\infty }\leq 2\|h'\|_{\infty },$
where the last bound is of course only applicable if $h$ is differentiable (or at least Lipschitz-continuous, which, for example, is not the case if we regard the total variation metric or the Kolmogorov metric!). As the standard normal distribution has no extra parameters, in this specific case the constants are free of additional parameters.
If we have bounds in the general form (5.1), we usually are able to treat many probability metrics together. One can often start with the next step below, if bounds of the form (5.1) are already available (which is the case for many distributions).

### An abstract approximation theorem

We are now in a position to bound the left hand side of (3.1). As this step heavily depends on the form of the Stein operator, we directly regard the case of the standard normal distribution.
At this point we could directly plug in random variable $W$, which we want to approximate, and try to find upper bounds. However, it is often fruitful to formulate a more general theorem. Consider here the case of local dependence.
Assume that $W=\sum _{i=1}^{n}X_{i}$ is a sum of random variables such that the $E[W]=0$ and variance $\operatorname {var} [W]=1$. Assume that, for every $i=1,\dots ,n$, there is a set $A_{i}\subset \{1,2,\dots ,n\}$, such that $X_{i}$ is independent of all the random variables $X_{j}$ with $j\not \in A_{i}$. We call this set the 'neighborhood' of $X_{i}$. Likewise let $B_{i}\subset \{1,2,\dots ,n\}$ be a set such that all $X_{j}$ with $j\in A_{i}$ are independent of all $X_{k}$, $k\not \in B_{i}$. We can think of $B_{i}$ as the neighbors in the neighborhood of $X_{i}$, a second-order neighborhood, so to speak. For a set $A\subset \{1,2,\dots ,n\}$ define now the sum $X_{A}:=\sum _{j\in A}X_{j}$.
Using Taylor expansion, it is possible to prove that
    $(6.1)\quad \left|E(f'(W)-Wf(W))\right|\leq \|f''\|_{\infty }\sum _{i=1}^{n}\left({\frac {1}{2}}E|X_{i}X_{A_{i}}^{2}|+E|X_{i}X_{A_{i}}X_{B_{i}\setminus A_{i}}|+E|X_{i}X_{A_{i}}|E|X_{B_{i}}|\right)$
Note that, if we follow this line of argument, we can bound (1.1) only for functions where $\|h'\|_{\infty }$ is bounded because of the third inequality of (5.2) (and in fact, if $h$ has discontinuities, so will $f''$). To obtain a bound similar to (6.1) which contains only the expressions $\|f\|_{\infty }$ and $\|f'\|_{\infty }$, the argument is much more involved and the result is not as simple as (6.1); however, it can be done.
Theorem A. If $W$ is as described above, we have for the Lipschitz metric $d_{W}$ that
    $(6.2)\quad d_{W}({\mathcal {L}}(W),N(0,1))\leq 2\sum _{i=1}^{n}\left({\frac {1}{2}}E|X_{i}X_{A_{i}}^{2}|+E|X_{i}X_{A_{i}}X_{B_{i}\setminus A_{i}}|+E|X_{i}X_{A_{i}}|E|X_{B_{i}}|\right).$
Proof. Recall that the Lipschitz metric is of the form (1.1) where the functions $h$ are Lipschitz-continuous with Lipschitz-constant 1, thus $\|h'\|\leq 1$. Combining this with (6.1) and the last bound in (5.2) proves the theorem.
Thus, roughly speaking, we have proved that, to calculate the Lipschitz-distance between a $W$ with local dependence structure and a standard normal distribution, we only need to know the third moments of $X_{i}$ and the size of the neighborhoods $A_{i}$ and $B_{i}$.

### Application of the theorem

We can treat the case of sums of independent and identically distributed random variables with Theorem A.
Assume that $EX_{i}=0$, $\operatorname {var} X_{i}=1$ and $W=n^{-1/2}\sum X_{i}$. We can take $A_{i}=B_{i}=\{i\}$. From Theorem A we obtain that
    $(7.1)\quad d_{W}({\mathcal {L}}(W),N(0,1))\leq {\frac {5E|X_{1}|^{3}}{n^{1/2}}}.$
For sums of random variables another approach related to Steins Method is known as the zero bias transform.

## Connections to other methods

* Lindeberg's device. Lindeberg (1922) introduced a device, where the difference $Eh(X_{1}+\cdots +X_{n})-Eh(Y_{1}+\cdots +Y_{n})$ is represented as a sum of step-by-step differences.
* Tikhomirov's method. Clearly the approach via (1.1) and (3.1) does not involve characteristic functions. However, Tikhomirov (1980) presented a proof of a central limit theorem based on characteristic functions and a differential operator similar to (2.3). The basic observation is that the characteristic function $\psi (t)$ of the standard normal distribution satisfies the differential equation $\psi '(t)+t\psi (t)=0$ for all $t$. Thus, if the characteristic function $\psi _{W}(t)$ of $W$ is such that $\psi '_{W}(t)+t\psi _{W}(t)\approx 0$ we expect that $\psi _{W}(t)\approx \psi (t)$ and hence that $W$ is close to the normal distribution. Tikhomirov states in his paper that he was inspired by Stein's seminal paper.