Testing the Gaussian Stein identity

Change the mixture's shape and position. The bars show which integration-by-parts identities it fails.

−1 · separated0 · one Gaussian+1 · separated
left0 · centeredright

Density

mixture N(0, 1)

Faint curves show the weighted components.

Signed Stein residuals

Raw values above; tiny sketches of f below. Each bar is divided by its own fixed scale.

The plotted height is E[f′(X) − Xf(X)] divided by the number beneath its sketch. Zero is centered, with positive values above and negative values below. Scales stay fixed as either slider moves; heights are not comparable raw magnitudes.

Exact expectations and scale factors

These values use the full real line. Scroll the table sideways on small screens.

Exact expectations of six test functions. Residual means E[f′(X)] minus E[X f(X)], not E[f(X)].
Test fE[f(X)]E[f′(X)]E[X f(X)]ResidualDivisor
Mixture and numerical method

The weights are (0.2, 0.5, 0.3). With a = 2θ, the component means are 1.5b + a × (−1.1, −0.1, 0.9), and every component has standard deviation σ = 1 − 0.75|θ|. The first slider changes their separation and width; the second translates them. At θ = 0 they coincide into N(1.5b, 1). Only at θ = b = 0 is this the reference N(0, 1).

All expectations are evaluated from exact Gaussian moments or characteristic functions, not random samples. The fixed per-test divisors are (1.5, 3.3, 8.4, 20.7, 1, 1.03), calibrated over the whole two-slider range. Each bar can approach a full half-axis without its scale changing from frame to frame. These are plotting scales, not norms of the functions or a rigorously optimized discrepancy.

The density plot shows x between −5 and 5. Each miniature shows its test function on [−2, 2], with its own symmetric vertical scale. The ordinary expectation E[f(X)] need not vanish under a Gaussian; the Stein residual does. These six tests are a finite illustration, not a characterization of all distributions.