Stein discrepancy explained

A Stein discrepancy is a statistical divergence between two probability measures that is rooted in Stein's method. It was first formulated as a tool to assess the quality of Markov chain Monte Carlo samplers,[1] but has since been used in diverse settings in statistics, machine learning and computer science.[2]

Definition

Let

l{X}

be a measurable space and let

l{M}

be a set of measurable functions of the form

m:l{X}R

. A natural notion of distance between two probability distributions

P

,

Q

, defined on

l{X}

, is provided by an integral probability metric[3]

(1.1)dl{M

}(P, Q) := \sup_ |\mathbb_[m(X)] - \mathbb_[m(Y)]|,

where for the purposes of exposition we assume that the expectations exist, and that the set

l{M}

is sufficiently rich that (1.1) is indeed a metric on the set of probability distributions on

l{X}

, i.e.

dl{M

}(P,Q) = 0 if and only if

P=Q

. The choice of the set

l{M}

determines the topological properties of (1.1). However, for practical purposes the evaluation of (1.1) requires access to both

P

and

Q

, often rendering direct computation of (1.1) impractical.

l{A}P

and a set

l{F}P

of real-valued functions in the domain of

l{A}P

, both of which may be

P

-dependent, such that for each

m\inl{M}

there exists a solution

fm\inl{F}P

to the Stein equation

(1.2)m(x)-EX[m(X)]=l{A}Pfm(x).

The operator

l{A}P

is termed a Stein operator and the set

l{F}P

is called a Stein set. Substituting (1.2) into (1.1), we obtain an upper bound

dl{M

}(P, Q) = \sup_ |\mathbb_[m(Y) - \mathbb{E}_{X \sim P}[m(X)] ]|= \sup_ |\mathbb_[\mathcal{A}_{P} f_m(Y) ]| \leq \sup_ |\mathbb_[\mathcal{A}_{P} f(Y)]| .This resulting bound

DP(Q):=\supfP}|EY[l{A}Pf(Y)]|

is called a Stein discrepancy. In contrast to the original integral probability metric

dl{M

}(P, Q), it may be possible to analyse or compute

DP(Q)

using expectations only with respect to the distribution

Q

.

Examples

Several different Stein discrepancies have been studied, with some of the most widely used presented next.

Classical Stein discrepancy

For a probability distribution

P

with positive and differentiable density function

p

on a convex set

l{X}\subseteqRd

, whose boundary is denoted

\partiall{X}

, the combination of the Langevin–Stein operator

l{A}Pf=\nablaf+f\nablalogp

and the classical Stein set

l{F}P=\left\{f:l{X}Rdl\vert\supxmax\left(\|f(x)\|,\|\nablaf(x)\|,

\|\nablaf(x)-\nablaf(y)\|
\|x-y\|

\right)\leq1,\langlef(x),n(x)\rangle=0\forallx\in\partiall{X}\right\}

yields the classical Stein discrepancy. Here

\|\|

denotes the Euclidean norm and

\langle,\rangle

the Euclidean inner product. Here

\|M\|=

style\sup
v\inRd,\|v\|=1

\|Mv\|

is the associated operator norm for matrices

M\in\Rd

, and

n(x)

denotes the outward unit normal to

\partiall{X}

at location

x\in\partiall{X}

. If

l{X}=\Rd

then we interpret

\partiall{X}=\emptyset

.

In the univariate case

d=1

, the classical Stein discrepancy can be computed exactly by solving a quadratically constrained quadratic program.

Graph Stein discrepancy

The first known computable Stein discrepancies were the graph Stein discrepancies (GSDs). Given a discrete distribution

Q=

n
style\sum
i=1

wi\delta(xi)

, one can define the graph

G

with vertex set

V=\{x1,...,xn\}

and edge set

E\subseteqV x V

. From this graph, one can define the graph Stein set as

\begin{align} l{F}P=\{f:l{X}Rd&l\vert max\left(\|f(v)\|infty,\|\nablaf(v)\|infty,

{
style\|f(x)-f(y)\|infty
\|x-y\|1
}, \right) \le 1, \\[8pt] &,, \; \forall v \in \operatorname(Q_n), (x,y)\in E \Big\}. \endThe combination of the Langevin–Stein operator and the graph Stein set is called the graph Stein discrepancy (GSD).The GSD is actually the solution of a finite-dimensional linear program, with the size of

E

as low as linear in

n

, meaning that the GSD can be efficiently computed.

Kernel Stein discrepancy

The supremum arising in the definition of Stein discrepancy can be evaluated in closed form using a particular choice of Stein set. Indeed, let

l{F}P=\{f\inH(K):\|f\|H(K)\leq1\}

be the unit ball in a (possibly vector-valued) reproducing kernel Hilbert space

H(K)

with reproducing kernel

K

, whose elements are in the domain of the Stein operator

l{A}P

. Suppose that

x\inl{X}

, the map

f\mapstol{A}P[f](x)

is a continuous linear functional on

l{F}P

.

EX[l{A}Pl{A}P'K(X,X)]<infty

.

where the Stein operator

l{A}P

acts on the first argument of

K(,)

and

l{A}P'

acts on the second argument. Then it can be shown[4] that

DP(Q)=\sqrt{EX,X'[l{A}Pl{A}P'K(X,X')]}

,where the random variables

X

and

X'

in the expectation are independent. In particular, if Q = \sum_^n w_i \delta(x_i) is a discrete distribution on

l{X}

, then the Stein discrepancy takes the closed form

DP(Q)=\sqrt{

n
\sum
i=1
n
\sum
j=1

wiwjl{A}Pl{A}P'K(xi,xj)}.

A Stein discrepancy constructed in this manner is called a kernel Stein discrepancy[5] [6] [7] [8] and the construction is closely connected to the theory of kernel embedding of probability distributions.

Let

k:l{X} x l{X}R

be a reproducing kernel. For a probability distribution

P

with positive and differentiable density function

p

on

l{X}=\Rd

, the combination of the Langevin--Stein operator

l{A}Pf=\nablaf+f\nablalogp

and the Stein set

l{F}P=\left\{f\inH(k) x ... x H(k):

d
\sum
i=1

\|fi\|

2
H(k)

\leq1\right\},

associated to the matrix-valued reproducing kernel

K(x,x')=k(x,x')Id

, yields a kernel Stein discrepancy with

l{A}Pl{A}P'K(x,x')=\nablax\nablax'k(x,x')+\nablaxk(x,x')\nablax'logp(x')+\nablax'k(x,x')\nablaxlogp(x)+k(x,x')\nablaxlogp(x)\nablax'logp(x')

where

\nablax

(resp.

\nablax'

) indicated the gradient with respect to the argument indexed by

x

(resp.

x'

).

Concretely, if we take the inverse multi-quadric kernel

k(x,x')=(1+(x-x')\top\Sigma-1(x-x'))-\beta

with parameters

\beta>0

and

\Sigma\inRd

a symmetric positive definite matrix, and if we denote

u(x)=\nablalogp(x)

, then we have

(2.1)l{A}Pl{A}P'K(x,x')=-

4\beta(\beta+1)(x-x')\top\Sigma-2(x-x')
\left(1+(x-x')\top\Sigma-1(x-x')\right)\beta

+2\beta\left[

tr(\Sigma-1)+[u(x)-u(x')]\top\Sigma-1(x-x')
\left(1+(x-x')\top\Sigma-1(x-x')\right)1+\beta

\right]+

u(x)\topu(x')
\left(1+(x-x')\top\Sigma-1(x-x')\right)\beta

.

Diffusion Stein discrepancy

Diffusion Stein discrepancies[9] generalize the Langevin Stein operator

l{A}Pf=\nablaf+f\nablalogp=

style1
p
\nabla

(fp)

to a class of diffusion Stein operators

l{A}Pf=

style1
p
\nabla

(mfp)

, each representing an Itô diffusion that has

P

as its stationary distribution.Here,

m

is a matrix-valued function determined by the infinitesimal generator of the diffusion.

Other Stein discrepancies

Additional Stein discrepancies have been developed for constrained domains,[10] non-Euclidean domains[11] [12] , discrete domains,[13] [14] improved scalability.[15] [16], and gradient-free Stein discrepancies where derivatives of the density

p

are circumvented.[17]

Properties

The flexibility in the choice of Stein operator and Stein set in the construction of Stein discrepancy precludes general statements of a theoretical nature. However, much is known about the particular Stein discrepancies.

Computable without the normalisation constant

Stein discrepancy can sometimes be computed in challenging settings where the probability distribution

P

admits a probability density function

p

(with respect to an appropriate reference measure on

l{X}

) of the form

p(x)=style

1
Z

\tilde{p}(x)

, where

\tilde{p}(x)

and its derivative can be numerically evaluated but whose normalisation constant

Z

is not easily computed or approximated. Considering (2.1), we observe that the dependence of

l{A}Pl{A}PK(x,x')

on

P

occurs only through the term

u(x)=\nablalogp(x)=\nablalog\left(

\tilde{p
(x)}{Z}

\right)=\nablalog\tilde{p}(x)-\nablalogZ=\nablalog\tilde{p}(x)

which does not depend on the normalisation constant

Z

.

Stein discrepancy as a statistical divergence

A basic requirement of Stein discrepancy is that it is a statistical divergence, meaning that

DP(Q)\geq0

and

DP(Q)=0

if and only if

Q=P

. This property can be shown to hold for classical Stein discrepancy and kernel Stein discrepancy a provided that appropriate regularity conditions hold.

Convergence control

A stronger property, compared to being a statistical divergence, is convergence control, meaning that

DP(Qn)0

implies

Qn

converges to

P

in a sense to be specified. For example, under appropriate regularity conditions, both the classical Stein discrepancy and graph Stein discrepancy enjoy Wasserstein convergence control, meaning that

DP(Qn)0

implies that the Wasserstein metric between

Qn

and

P

converges to zero.[18] For the kernel Stein discrepancy, weak convergence control has been established[19] under regularity conditions on the distribution

P

and the reproducing kernel

K

, which are applicable in particular to (2.1). Other well-known choices of

K

, such as based on the Gaussian kernel, provably do not enjoy weak convergence control.

Convergence detection

The converse property to convergence control is convergence detection, meaning that

DP(Qn)0

whenever

Qn

converges to

P

in a sense to be specified. For example, under appropriate regularity conditions, classical Stein discrepancy enjoys a particular form of mean square convergence detection, meaning that

DP(Qn)0

whenever

Xn\simQn

converges in mean-square to

X\simP

and

\nablalogp(Xm)

converges in mean-square to

\nablalogp(X)

. For kernel Stein discrepancy, Wasserstein convergence detection has been established, under appropriate regularity conditions on the distribution

P

and the reproducing kernel

K

.

Applications of Stein discrepancy

Several applications of Stein discrepancy have been proposed, some of which are now described.

Optimal quantisation

Given a probability distribution

P

defined on a measurable space

l{X}

, the quantization task is to select a small number of states

x1,...,xn\inl{X}

such that the associated discrete distribution Q^n = \frac \sum_^n \delta(x_i) is an accurate approximation of

P

in a sense to be specified.

Stein points are the result of performing optimal quantisation via minimisation of Stein discrepancy:

(3.1)\underset{x1,...,xn\inl{X}}{\operatorname{argmin}}DP\left(

1
n
n
\sum
i=1

\delta(xi)\right)

Under appropriate regularity conditions, it can be shown that

n)
D
P(Q

0

as

ninfty

. Thus, if the Stein discrepancy enjoys convergence control, it follows that

Qn

converges to

P

. Extensions of this result, to allow for imperfect numerical optimisation, have also been derived.[20] [21]

Sophisticated optimisation algorithms have been designed to perform efficient quantisation based on Stein discrepancy, including gradient flow algorithms that aim to minimise kernel Stein discrepancy over an appropriate space of probability measures.[22]

Optimal weighted approximation

If one is allowed to consider weighted combinations of point masses, then more accurate approximation is possible compared to (3.1). For simplicity of exposition, suppose we are given a set of states

\{xi\}

n
i=1

\subsetl{X}

. Then the optimal weighted combination of the point masses

\delta(xi)

, i.e.

Qn:=

n
\sum
i=1
*
w
i

\delta(xi),    w*\in\underset{w1++wn=1}{\operatorname{argmin}}DP\left(

n
\sum
i=1

wi\delta(xi)\right),

which minimise Stein discrepancy can be obtained in closed form when a kernel Stein discrepancy is used. Some authors[23] [24] consider imposing, in addition, a non-negativity constraint on the weights, i.e.

wi\geq0

. However, in both cases the computation required to compute the optimal weights

w*

can involve solving linear systems of equations that are numerically ill-conditioned. Interestingly, it has been shown that greedy approximation of

Qn

using an un-weighted combination of

m\lln

states can reduce this computational requirement. In particular, the greedy Stein thinning algorithm

Qn,m:=

1
m
m
\sum
i=1

\delta(x\pi(i)),    \pi(m)\in \underset{j=1,...,n}{\operatorname{argmin}}DP\left(

1
m
m-1
\sum
i=1

\delta(x\pi(i))+

1
m

\delta(xj)\right)

has been shown to satisfy an error bound

DP(Qn,m)=DP(Qn)+O\left(\sqrt{

logm
m
} \right).

Non-myopic and mini-batch generalisations of the greedy algorithm have been demonstrated[25] to yield further improvement in approximation quality relative to computational cost.

Variational inference

Stein discrepancy has been exploited as a variational objective in variational Bayesian methods.[26] [27] Given a collection

\{Q\theta\}\theta

of probability distributions on

l{X}

, parametrised by

\theta\in\Theta

, one can seek the distribution in this collection that best approximates a distribution

P

of interest:

\underset{\theta\in\Theta}{\operatorname{argmin}}DP(Q\theta)

A possible advantage of Stein discrepancy in this context, compared to the traditional Kullback–Leibler variational objective, is that

Q\theta

need not be absolutely continuous with respect to

P

in order for

DP(Q\theta)

to be well-defined. This property can be used to circumvent the use of flow-based generative models, for example, which impose diffeomorphism constraints in order to enforce absolute continuity of

Q\theta

and

P

.

Statistical estimation

Stein discrepancy has been proposed as a tool to fit parametric statistical models to data. Given a dataset

\{xi\}

n
i=1

\subsetl{X}

, consider the associated discrete distribution

Qn=style

1
n
n
\sum
i=1

\delta(xi)

. For a given parametric collection

\{P\theta\}\theta

of probability distributions on

l{X}

, one can estimate a value of the parameter

\theta

which is compatible with the dataset using a minimum Stein discrepancy estimator[28]

\underset{\theta\in\Theta}{\operatorname{argmin}}

D
P\theta

(Qn).

The approach is closely related to the framework of minimum distance estimation, with the role of the "distance" being played by the Stein discrepancy. Alternatively, a generalised Bayesian approach to estimation of the parameter

\theta

can be considered where, given a prior probability distribution with density function

\pi(\theta)

,

\theta\in\Theta

, (with respect to an appropriate reference measure on

\Theta

), one constructs a generalised posterior with probability density function

\pin(\theta)\propto\pi(\theta)\exp\left(-\gamma

D
P\theta

(Qn)2\right),

for some

\gamma>0

to be specified or determined.

Hypothesis testing

The Stein discrepancy has also been used as a test statistic for performing goodness-of-fit testing and comparing latent variable models.[29] Since the aforementioned tests have a computational cost quadratic in the sample size, alternatives have been developed with (near-)linear runtimes.[30]

See also

Notes and References

  1. J. Gorham and L. Mackey. Measuring Sample Quality with Stein's Method. Advances in Neural Information Processing Systems, 2015.
  2. Anastasiou, A., Barp, A., Briol, F-X., Ebner, B., Gaunt, R. E., Ghaderinezhad, F., Gorham, J., Gretton, A., Ley, C., Liu, Q., Mackey, L., Oates, C. J., Reinert, G. & Swan, Y. (2021). Stein’s method meets statistics: A review of some recent developments. arXiv:2105.03481.
  3. Müller. Alfred. 1997. Integral Probability Metrics and Their Generating Classes of Functions. Advances in Applied Probability. en. 29. 2. 429–443. 10.2307/1428011. 0001-8678.
  4. Mastubara, T., Knoblauch, J., Briol, F-X., Oates, C. J. Robust Generalised Bayesian Inference for Intractable Likelihoods. arXiv:2104.07359.
  5. Oates, C. J., Girolami, M., & Chopin, N. (2017). Control functionals for Monte Carlo integration. Journal of the Royal Statistical Society B: Statistical Methodology, 79(3), 695–718.
  6. Liu, Q., Lee, J. D., & Jordan, M. I. (2016). A kernelized Stein discrepancy for goodness-of-fit tests and model evaluation. International Conference on Machine Learning, 276–284.
  7. Chwialkowski, K., Strathmann, H., & Gretton, A. (2016). A kernel test of goodness of fit. International Conference on Machine Learning, 2606–2615.
  8. Gorham J, Mackey L. Measuring sample quality with kernels. International Conference on Machine Learning 2017 Jul 17 (pp. 1292-1301). PMLR.
  9. Gorham, J., Duncan, A. B., Vollmer, S. J., & Mackey, L. (2019). Measuring sample quality with diffusions. The Annals of Applied Probability, 29(5), 2884-2928.
  10. Shi, J., Liu, C., & Mackey, L. (2021). Sampling with Mirrored Stein Operators. arXiv preprint arXiv:2106.12506
  11. Barp A, Oates CJ, Porcu E, Girolami M. A Riemann-Stein kernel method. arXiv preprint arXiv:1810.04946. 2018.
  12. Xu W, Matsuda T. Interpretable Stein Goodness-of-fit Tests on Riemannian Manifolds. In ICML 2021.
  13. Yang J, Liu Q, Rao V, Neville J. Goodness-of-fit testing for discrete distributions via Stein discrepancy. In ICML 2018 (pp. 5561-5570). PMLR.
  14. Shi J, Zhou Y, Hwang J, Titsias M, Mackey L. Gradient Estimation with Discrete Stein Operators. arXiv preprint arXiv:2202.09497. 2022.
  15. Huggins JH, Mackey L. Random Feature Stein Discrepancies. In NeurIPS 2018.
  16. Gorham J, Raj A, Mackey L. Stochastic Stein Discrepancies. In NeurIPS 2020.
  17. Fisher M, Oates CJ. Gradient-Free Kernel Stein Discrepancy. arXiv preprint arXiv:2207.02636. 2022.
  18. Mackey, L., & Gorham, J. (2016). Multivariate Stein factors for a class of strongly log-concave distributions. Electronic Communications in Probability, 21, 1-14.
  19. Chen WY, Mackey L, Gorham J, Briol FX, Oates CJ. Stein points. In International Conference on Machine Learning 2018 (pp. 844-853). PMLR.
  20. Chen WY, Barp A, Briol FX, Gorham J, Girolami M, Mackey L, Oates CJ. Stein Point Markov Chain Monte Carlo. International Conference on Machine Learning (ICML 2019).
  21. Riabiz M, Chen W, Cockayne J, Swietach P, Niederer SA, Mackey L, Oates CJ. Optimal thinning of MCMC output. Journal of the Royal Statistical Society B: Statistical Methodology, to appear. 2021.
  22. Korba A, Aubin-Frankowski PC, Majewski S, Ablin P. "Kernel Stein Discrepancy Descent." arXiv preprint . 2021.
  23. Liu Q, Lee J. Black-box importance sampling. In Artificial Intelligence and Statistics 2017 (pp. 952-961). PMLR.
  24. Hodgkinson L, Salomone R, Roosta F. The reproducing Stein kernel approach for post-hoc corrected sampling. arXiv preprint arXiv:2001.09266. 2020.
  25. Teymur O, Gorham J, Riabiz M, Oates CJ. Optimal quantisation of probability measures using maximum mean discrepancy. In International Conference on Artificial Intelligence and Statistics 2021 (pp. 1027-1035). PMLR.
  26. Ranganath R, Tran D, Altosaar J, Blei D. Operator variational inference. Advances in Neural Information Processing Systems. 2016;29:496-504.
  27. Fisher M, Nolan T, Graham M, Prangle D, Oates CJ. Measure transport with kernel Stein discrepancy. International Conference on Artificial Intelligence and Statistics 2021 (pp. 1054-1062). PMLR.
  28. Barp, A., Briol, F.-X., Duncan, A. B., Girolami, M., & Mackey, L. (2019). Minimum Stein discrepancy estimators. Neural Information Processing Systems, 12964–12976.
  29. Kanagawa, H., Jitkrittum, W., Mackey, L., Fukumizu, K., & Gretton, A. (2019). A kernel Stein test for comparing latent variable models. arXiv preprint arXiv:1907.00586.
  30. Jitkrittum W, Xu W, Szabó Z, Fukumizu K, Gretton A. A Linear-Time Kernel Goodness-of-Fit Test.