Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Gaussianity diagnostics

Did we actually reach N(0, I)? QQ-plots, moments, negentropy, and a multivariate energy test

06 — Gaussianity diagnostics

We can build a density destructor (notebook 04) and trust its arithmetic (notebook 05). The last foundational question is how do we know it worked? — that the pushforward z=T(x)z = T(x) really is N(0,I)\mathcal{N}(0, I). Gaussianity has two levels, and we need a diagnostic for each: per-coordinate (are the marginals standard normal?) and joint (is the whole vector multivariate normal, i.e. also independent across coordinates?).

What you will see

1. Marginal diagnostics: QQ-plots and moments

The first, cheapest check is per-coordinate. A QQ-plot sorts the samples and plots them against the matching standard-normal quantiles Φ−1((i−0.5)/n)\Phi^{-1}((i - 0.5)/n); if the coordinate is N(0,1)\mathcal{N}(0,1) the points fall on the identity line. Two scalar summaries back it up: skewness γ1\gamma_1 (asymmetry) and excess kurtosis γ2\gamma_2 (tail weight), both 0 for a Gaussian.

                skewness   excess kurtosis
data x            0.0006            1.0627
Gaussianized z      0.0003            0.0109
<Figure size 1000x460 with 2 Axes>

The data QQ-plot is S-shaped — the two-moons marginal is platykurtic (light tails, excess kurtosis <0< 0) and bends away from the line. After Gaussianization the points snap onto y=xy = x, and the mean ∣γ1∣,∣γ2∣|\gamma_1|, |\gamma_2| both collapse toward 0. QQ-plots catch what kind of non-Gaussianity remains (skew vs. tails); the moments put a number on it.

2. Negentropy: the information-theoretic stopping signal

Moments only probe the 3rd and 4th order. The complete per-coordinate non-Gaussianity is the negentropy J(p)=H(Nσ)−H(p)≥0J(p) = H(\mathcal{N}_{\sigma}) - H(p) \ge 0 from notebook 03, and the complete joint non-Gaussianity is the KL to the standard normal, which decomposes as

KL(p ∥ N(0,I))=TC(p)⏟dependence+∑iJ(pi)⏟marginal non-Gaussianity.\mathrm{KL}\big(p \,\|\, \mathcal{N}(0, I)\big) = \underbrace{\mathrm{TC}(p)}_{\text{dependence}} + \underbrace{\textstyle\sum_i J(p_i)}_{\text{marginal non-Gaussianity}}.

Driving this to 0 is the RBIG objective, and rbig uses the per-layer information reduction as its stopping criterion Laparra et al. (2011). We estimate negentropy with rbig.negentropy on the data and on the pushforward.

sum negentropy  — data        : 0.3181 nats
sum negentropy  — Gaussianized: 0.0001 nats  (~0)
<Figure size 550x400 with 1 Axes>

3. Joint normality: an energy-distance test

Marginal checks can all pass while the joint is still structured (think of a rotated non-Gaussian whose axes happen to look normal). For the joint verdict we compare the pushforward ZZ to a fresh N(0,I)\mathcal{N}(0, I) sample with the energy distance — a kernel two-sample statistic that is 0 iff the two distributions match:

E(Z,G)=2 E∥Z−G∥−E∥Z−Z′∥−E∥G−G′∥  ≥  0.\mathcal{E}(Z, G) = 2\,\mathbb{E}\lVert Z - G\rVert - \mathbb{E}\lVert Z - Z'\rVert - \mathbb{E}\lVert G - G'\rVert \;\ge\; 0.

(The classical Henze–Zirkler test is the textbook alternative Cover & Thomas (2006); the energy distance is easy to compute from scratch and needs no distributional table.) We track it as RBIG adds layers.

energy distance to N(0,I):  data = 0.0497  ->  final = 0.0030  (sampling floor)
<Figure size 750x420 with 1 Axes>

The energy distance falls steadily from the tangled two-moons toward the noise floor (the residual is the finite-sample distance between two genuine N(0,I)\mathcal{N}(0, I) samples). This is the joint analogue of the per-layer information reduction: a single, robust number that says “keep adding layers” until it stops dropping — the practical stopping rule when negentropy is too noisy to trust.

Recap

leveldiagnosticGaussian valuetool
marginal shapeQQ-plotpoints on y=xy=xnumpy + scipy.stats
marginal momentsskewness, excess kurtosis0, 00,\ 0scipy.stats.skew/kurtosis
marginal infonegentropy J(pi)J(p_i)0rbig.negentropy
dependencetotal correlation0rbig.total_correlation
jointenergy distance / Henze–Zirkler0from scratch
References
  1. Laparra, V., Camps-Valls, G., & Malo, J. (2011). Iterative Gaussianization: From ICA to Random Rotations. IEEE Transactions on Neural Networks, 22(4), 537–549. 10.1109/TNN.2011.2106511
  2. Cover, T. M., & Thomas, J. A. (2006). Elements of Information Theory (2nd ed.). Wiley-Interscience.