A visual exploration of Stein variational inference
One target, many particles, and a vector field with two jobs: seek probability and refuse collapse.
The particle view
From a gradient to a population
A score points uphill. A kernel lets nearby particles share that information—and gives them room to remain different.
- score
- repulsion
- particle
Ask the target
The score points uphill
The normalization constant disappears under a gradient, so an unnormalized posterior still tells every particle which direction increases density.
Used alone, score ascent sends each particle toward a mode. It finds peaks, not a distribution.
Share local information
Neighbors vote on direction
The kernel gives nearby scores more influence. Particles no longer climb independently; each receives a smoothed message from the population.
Orange arrows are kernel-weighted target messages. Attraction alone still favors collapse.
Protect diversity
The kernel also pushes apart
Differentiating the RBF kernel with respect to the sending particle produces a local repulsive message with the correct outward sign.
Blue arrows point away from close neighbors. Repulsion alone spreads mass without knowing where probability lives.
One coupled field
Attraction plus repulsion
SVGD transports the empirical distribution with the single RKHS-optimal field formed by both messages—not two unrelated objectives.
The bright arrow is the sum. The target attracts the population while interaction keeps it distributed.
The diagnostic underneath
Move q, break the balance
The Stein operator averages to zero under the target p. Move the approximation q away, and the leftover signal tells us that transport can still improve it.
A calibration test
At p, every valid field balances
The orange score contribution and blue divergence contribution must cancel when samples come from p. Shift or squeeze q, and this probe usually becomes nonzero; one balanced probe alone is not proof that q = p.
That imbalance is precisely the first-order KL descent available to a transport field:
A density in the wild
How long until Old Faithful erupts?
Real observations arrive as dots, not a probability law. A kernel density estimate turns 272 geyser records into a smooth target; Stein particles then make that target usable.
- observation
- KDE
- Stein particle
Drag the vertical line to ask: after an eruption of this duration, how long is the next wait?
Observed phenomenon
Two eruption regimes emerge
Short eruptions tend to precede shorter waits; long eruptions tend to precede longer waits. Density estimation discovers both regimes without class labels.
The side profile is a conditional slice, \(\widehat p_H(\text{wait}\mid\text{duration})\). Move the query line and watch a two-dimensional density answer a practical one-dimensional question.