ArticleslgStudy

mathematics

Stein discrepancy

Stein discrepancy is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Stein discrepancy rather than just read about it. In short: 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, but has since been used in diverse settings in statistics, machine learning and computer science.

Key takeaways

  • Stein discrepancy belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Stein discrepancy to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Stein discrepancy from memory before moving on to harder problems.

Reference excerpt

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, but has since been used in diverse settings in statistics, machine learning and computer science.

Definition Let 𝒳 be a measurable space and let ℳ be a set of measurable functions of the form m:𝒳→ℝ. A natural notion of distance between two probability distributions P, Q, defined on 𝒳, is provided by an integral probability metric

(1.1)dℳ(P,Q):=supm∈ℳ|𝔼X∼P[m(X)]−𝔼Y∼Q[m(Y)]|, where for the purposes of exposition we assume that the expectations exist, and that the set ℳ is sufficiently rich that (1.1) is indeed a metric on the set of probability distributions on 𝒳, i.e. dℳ(P,Q)=0 if and only if P=Q. The choice of the set ℳ 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. Stein's method is a theoretical tool that can be used to bound (1.1). Specifically, we suppose that we can identify an operator 𝒜P and a set ℱP of real-valued functions in the domain of 𝒜P, both of which may be P-dependent, such that for each m∈ℳ there exists a solution fm∈ℱP to the Stein equation

(1.2)m(x)−𝔼X∼P[m(X)]=𝒜Pfm(x). The operator 𝒜P is termed a Stein operator and the set ℱP is called a Stein set. Substituting (1.2) into (1.1), we obtain an upper bound

dℳ(P,Q)=supm∈ℳ|𝔼Y∼Q[m(Y)]−𝔼X∼P[m(X)]|=supm∈ℳ|𝔼Y∼Q[𝒜Pfm(Y)]|≤supf∈ℱP|𝔼Y∼Q[𝒜Pf(Y)]| . This resulting bound

DP(Q):=supf∈ℱP|𝔼Y∼Q[𝒜Pf(Y)]| is called a Stein discrepancy. In contrast to the original integral probability metric dℳ(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 𝒳⊆ℝd, whose boundary is denoted ∂𝒳, the combination of the Langevin–Stein operator 𝒜Pf=∇⋅f+f⋅∇log⁡p and the classical Stein set

ℱP={f:𝒳→ℝd|supx≠ymax⁡(‖f(x)‖,‖∇f(x)‖,‖∇f(x)−∇f(y)‖‖x−y‖)≤1,⟨f(x),n(x)⟩=0∀x∈∂𝒳} yields the classical Stein discrepancy. Here ‖⋅‖ denotes the Euclidean norm and ⟨⋅,⋅⟩ the Euclidean inner product. Here ‖M‖=supv∈ℝd,‖v‖=1‖Mv‖ is the associated operator norm for matrices M∈ℝd×d, and n(x) denotes the outward unit normal to ∂𝒳 at location x∈∂𝒳. If 𝒳=ℝd then we interpret ∂𝒳=∅︀. 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=∑i=1nwiδ(xi), one can define the graph G with vertex set V={x1,…,xn} and edge set E⊆V×V. From this graph, one can define the graph Stein set as

ℱP={f:𝒳→ℝd|max⁡(‖f(v)‖∞,‖∇f(v)‖∞,‖f(x)−f(y)‖∞‖x−y‖1,‖∇f(x)−∇f(y)‖∞‖x−y‖1)≤1,‖f(x)−f(y)−∇(x)(x−y)‖∞12‖x−y‖12≤1,‖f(x)−f(y)−∇f(y)(x−y)‖∞12‖x−y‖12≤1,∀v∈supp⁡(Qn),(x,y)∈E}. The 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 ℱP={f∈H(K):‖f‖H(K)≤1} 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 𝒜P. Suppose that

For each fixed x∈𝒳, the map f↦𝒜P[f](x) is a continuous linear functional on ℱP. 𝔼X∼Q[𝒜P𝒜P′K(X,X)]<∞. where the Stein operator 𝒜P acts on the first argument of K(⋅,⋅) and 𝒜P′ acts on the second argument. Then it can be shown that

DP(Q)=𝔼X,X′∼Q[𝒜P𝒜P′K(X,X′)], where the random variables X and X′ in the expectation are independent. In particular, if Q=∑i=1nwiδ(xi) is a discrete distribution on 𝒳, then the Stein discrepancy takes the closed form

DP(Q)=∑i=1n∑j=1nwiwj𝒜P𝒜P′K(xi,xj). A Stein discrepancy constructed in this manner is called a kernel Stein discrepancy and the construction is closely connected to the theory of kernel embedding of probability distributions. Let k:𝒳×𝒳→ℝ be a reproducing kernel. For a probability distribution P with positive and differentiable density function p on 𝒳=ℝd, the combination of the Langevin—Stein operator 𝒜Pf=∇⋅f+f⋅∇log⁡p and the Stein set

ℱP={f∈H(k)×⋯×H(k):∑i=1d‖fi‖H(k)2≤1}, associated to the matrix-valued reproducing kernel K(x,x′)=k(x,x′)Id×d, yields a kernel Stein discrepancy with

𝒜P𝒜P′K(x,x′)=∇x⋅∇x′k(x,x′)+∇xk(x,x′)⋅∇x′log⁡p(x′)+∇x′k(x,x′)⋅∇xlog⁡p(x)+k(x,x′)∇xlog⁡p(x)⋅∇x′log⁡p(x′) where ∇x (resp. ∇x′) 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′)⊤Σ−1(x−x′))−β with parameters β>0 and Σ∈ℝd×d a symmetric positive definite matrix, and if we denote u(x)=∇log⁡p(x), then we have (2.1)𝒜P𝒜P′K(x,x′)=−4β(β+1)(x−x′)⊤Σ−2(x−x′)(1+(x−x′)⊤Σ−1(x−x′))β+2+2β[tr(Σ−1)+[u(x)−u(x′)]⊤Σ−1(x−x′)(1+(x−x′)⊤Σ−1(x−x′))1+β]+u(x)⊤u(x′)(1+(x−x′)⊤Σ−1(x−x′))β.

Diffusion Stein discrepancy Diffusion Stein discrepancies generalize the Langevin Stein operator 𝒜Pf=∇⋅f+f⋅∇log⁡p=1p∇⋅(fp) to a class of diffusion Stein operators 𝒜Pf=1p∇⋅(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, non-Euclidean domains, discrete domains, improved scalability., and gradient-free Stein discrepancies where derivatives of the density p are circumvented. Furthermore, this approach is expanded into the Gradient-Free Kernel Conditional Stein Discrepancy, which targets conditional distributions.

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.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Stein discrepancy

Start with the simplest possible case. Write down what Stein discrepancy claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Stein discrepancy before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Stein discrepancy ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Stein discrepancy

In research
Stein discrepancy appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Stein discrepancy in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Stein discrepancy is common in secondary-school and first-year university syllabi. It links to neighbouring topics Statistical distance, Theory of probability distributions, so understanding it makes those chapters shorter.
In everyday life
Look for Stein discrepancy outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Stein discrepancy” →

How to study Stein discrepancy in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Stein discrepancy means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Stein discrepancy out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Stein discrepancy in simple terms?

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, but has since been used in diverse settings in statistics, machine learning and computer s…

Why does Stein discrepancy matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Stein discrepancy?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Stein discrepancy.

Tags

  • Statistical distance
  • Theory of probability distributions

Keep exploring