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.

Why a standard Gaussian?

Maximum entropy, separability and cheap primitives: three reasons the target is N(0, I)

03 · Why a standard Gaussian?

Open In Colab

Every notebook so far has mapped data to a standard Gaussian, the base pz(z)=N(z;0,I)p_z(\vect{z}) = \mathcal{N}(\vect{z}; \vect{0}, \mat{I}) of (4), without asking why that destination. Why not a uniform, a Laplace or a heavy-tailed base? The choice is not arbitrary: the standard Gaussian earns its place through three properties, and each one buys Gaussianization something concrete.

Python implementation: CPython
Python version       : 3.13.12
IPython version      : 9.12.0

jax               : 0.12.1
numpy             : 2.4.3
matplotlib        : 3.11.2
rbig              : 0.1.16
gauss_flows_models: 0.3.0

Compiler    : Clang 21.1.4 
OS          : Linux
Release     : 6.8.0-1044-azure
Machine     : x86_64
Processor   : x86_64
CPU cores   : 16
Architecture: 64bit

1. Maximum entropy at a fixed covariance

Let x∈RDx\vect{x} \in \mathbb{R}^{D_x} have density pp, mean μx∈RDx\gvect{\mu}_x \in \mathbb{R}^{D_x} and covariance Σx∈RDx×Dx\gmat{\Sigma}_x \in \mathbb{R}^{D_x \times D_x}, and write P(μx,Σx)\mathcal{P}(\gvect{\mu}_x, \gmat{\Sigma}_x) for the set of all densities with that mean and covariance. The differential entropy of pp is H[p]=−Ep(x)[log⁡p(x)]\mathbb{H}[p] = -\mathbb{E}_{p(\vect{x})}[\log p(\vect{x})], in nats.

Fixing the first two moments, the Gaussian assumes the least about everything else. That makes it the honest target: a Gaussianized dataset says “the mean and covariance are captured, and what remains is structureless”. The proof also names the gap. The negentropy of pp is

Neg[p]=H[N(μx,Σx)]−H[p]\mathrm{Neg}[p] = \mathbb{H}[\mathcal{N}(\gvect{\mu}_x, \gmat{\Sigma}_x)] - \mathbb{H}[p]

which equals KL[p∥N(μx,Σx)]\mathrm{KL}[p \Vert \mathcal{N}(\gvect{\mu}_x, \gmat{\Sigma}_x)], so it is non-negative and zero exactly when pp is Gaussian. We compare four unit-variance distributions in one dimension, Dx=1D_x = 1: their analytic entropies, the analytic negentropy, and an estimate of the negentropy from samples with rbig.negentropy. The Gaussian entropy comes from gaussian_entropy, the closed form (2).

Each distribution needs a sampler, for the estimate, and its entropy in closed form.

The analytic negentropy follows from the entropies, and rbig estimates it from 10 000 draws of each distribution.

Side by side, the analytic and estimated negentropies of the four distributions:

Neg[p] = H[N] - H[p], in nats
  Gaussian  analytic 0.0000   rbig 0.0011
  Logistic  analytic 0.0144   rbig 0.0163
  Laplace   analytic 0.0724   rbig 0.0771
  Uniform   analytic 0.1765   rbig 0.1401
<Figure size 1200x450 with 2 Axes>

Figure 1:Left: differential entropy of four unit-variance distributions; the Gaussian has the most. Right: their negentropy, analytic (bars) and estimated from 10 000 samples by rbig (black dots); only the Gaussian’s is zero.

The Gaussian bar is the tallest, and every other distribution has a positive negentropy, a number that says how non-Gaussian it is. The rbig estimates match the analytic values closely except for the uniform, which they underestimate: rbig.negentropy estimates the entropy with a kernel density estimate, which rounds off the uniform’s hard edges and so overstates its entropy. Driving the negentropy to zero is what Gaussianization does, which is why the negentropy doubles as a convergence signal in the iterative methods of later parts.

2. Separability

With identity covariance the Gaussian factorises into independent unit-variance coordinates,

N(z;0,I)=∏d=1DxN(zd;0,1)\mathcal{N}(\vect{z}; \vect{0}, \mat{I}) = \prod_{d=1}^{D_x} \mathcal{N}(z_d; 0, 1)

where zd∈Rz_d \in \mathbb{R} is coordinate dd of z\vect{z}. Independent coordinates carry no shared information, so the total correlation Watanabe, 1960, the gap between the sum of the marginal entropies and the joint entropy,

TC[pz]=∑d=1DxH[pzd]−H[pz]\mathrm{TC}[p_z] = \sum_{d=1}^{D_x} \mathbb{H}[p_{z_d}] - \mathbb{H}[p_z]

is zero. Gaussianization is therefore two jobs in one: remove the dependence between coordinates and make each margin standard normal. We watch the dependence disappear on a correlated 2-D Gaussian with correlation ρ=0.85\rho = 0.85: whiten it to N(0,I)\mathcal{N}(\vect{0}, \mat{I}) with rbig.PCARotation and estimate its total correlation with rbig.total_correlation before and after. That estimator takes the marginal entropies from kernel density estimates and the joint entropy from a Gaussian fit, which is exact here because the data are Gaussian. For a Gaussian the total correlation also has a closed form, gaussian_total_correlation, to check the estimate against.

rbig.PCARotation whitens the samples, and the total correlation is estimated before and after.

TC before whitening, closed form = 0.6410 nats
TC before whitening, rbig        = 0.6343 nats
TC after whitening, rbig         = -0.0043 nats
<Figure size 1200x550 with 2 Axes>

Figure 2:A correlated 2-D Gaussian (left) and the same samples after whitening (right), with the total correlation estimated by rbig. Whitening a Gaussian makes its coordinates independent.

The left cloud leans along the diagonal: knowing x1x_1 says a lot about x2x_2. The right cloud is round, its coordinates are independent and its total correlation has dropped to about zero. Once data reach N(0,I)\mathcal{N}(\vect{0}, \mat{I}), information-theoretic quantities split into one term per coordinate, which is what makes Gaussianized representations convenient for entropy and mutual-information estimates.

The cell below shows it on a banana-shaped dataset x=[w1,w2+0.6w12]⊤\vect{x} = [w_1, w_2 + 0.6 w_1^2]^\top, with w1,w2∼N(0,1)w_1, w_2 \sim \mathcal{N}(0, 1) independent. Its two coordinates are uncorrelated, so whitening only centres and rescales them, and its total correlation keeps the value we can compute exactly.

The exact total correlation of the banana

The map from [w1,w2]⊤[w_1, w_2]^\top to x\vect{x} has a Jacobian determinant of one, so by (3) the joint density of x\vect{x} is the standard Gaussian density at [w1,w2]⊤[w_1, w_2]^\top and H[p(x)]=log⁡(2πe)\mathbb{H}[p(\vect{x})] = \log(2 \pi e). The first coordinate x1=w1x_1 = w_1 is standard normal, with entropy 12log⁡(2πe)\frac{1}{2} \log(2 \pi e). By (5) the total correlation is therefore H[p(x2)]−12log⁡(2πe)\mathbb{H}[p(x_2)] - \frac{1}{2} \log(2 \pi e), and the density p(x2)=Ep(w1)[N(x2;0.6w12,1)]p(x_2) = \mathbb{E}_{p(w_1)}[\mathcal{N}(x_2; 0.6 w_1^2, 1)] is a 1-D integral that Gauss–Hermite quadrature evaluates to high accuracy. Rescaling a coordinate does not change the total correlation, so whitening leaves this value as it is.

The exact total correlation needs the density of x2x_2, which Gauss–Hermite quadrature over w1w_1 gives on a fine set of points.

Its entropy gives the exact total correlation, which we compare with the rbig estimate on the whitened banana.

covariance after whitening:
[[ 1. -0.]
 [-0.  1.]]
TC after whitening, exact           = 0.2337 nats
TC after whitening, rbig (Gaussian) = -0.0437 nats

The whitened covariance is the identity, yet the exact total correlation is still 0.234 nats. An estimate built on the covariance cannot see that dependence: rbig.total_correlation, whose joint entropy is a Gaussian fit, reports a value near zero. Removing the dependence that whitening leaves is the job of the marginal transforms that Gaussianization interleaves with its rotations.

3. Cheap primitives

The standard Gaussian is also the cheapest base a flow could sit on. The three things a flow needs from its base are one line each.

  • Sampling. z∼N(0,I)\vect{z} \sim \mathcal{N}(\vect{0}, \mat{I}) is jax.random.normal: no Markov chain, no rejection step.

  • Log-density. It is a squared norm,

log⁡N(z;0,I)=−Dx2log⁡(2π)−12∥z∥22\log \mathcal{N}(\vect{z}; \vect{0}, \mat{I}) = -\frac{D_x}{2} \log(2 \pi) - \frac{1}{2} \Vert \vect{z} \Vert_2^2
  • Score. The gradient of the log-density is a linear field pointing at the origin,

∇zlog⁡N(z;0,I)=−z\nabla_{\vect{z}} \log \mathcal{N}(\vect{z}; \vect{0}, \mat{I}) = -\vect{z}

A linear score is what makes the standard Gaussian the natural end point of score-based and diffusion models Song & Ermon, 2019. We read the base off a flow built by gaussianization_flow and check (6) and (7) on it, the score by autodiff.

Both checks agree to rounding:

z                    = [ 0.19977046 -1.28493524]
base.log_prob(z)     = -2.6833604690
closed form          = -2.6833604690
score, autodiff      = [-0.19977046  1.28493524]
-z                   = [-0.19977046  1.28493524]

For the figure we evaluate the score on a 13 by 13 grid of points.

<Figure size 600x600 with 1 Axes>

Figure 3:The score of the standard Gaussian on a grid, by autodiff of the flow’s base log-density: a linear field pointing at the origin (star).

Autodiff confirms (7), and the field in Figure 3 is a plain linear pull towards the origin. Cheap sampling, a squared-norm log-density and a linear score together keep the base term of every flow’s log_prob and sample cheap.

Recap

PropertyEquationWhat it buysIn code
maximum entropy(1), (2)a reference point for non-Gaussianitygaussian_entropy
negentropy(3)a non-negative distance from Gaussianrbig.negentropy
separability(4)total correlation (5) is zerorbig.total_correlation
cheap log-density(6)the base term of log_probflow.base_dist.log_prob
linear score(7)a simple end point for score-based modelsjax.grad(base.log_prob)

Next. With the target justified, the next notebook names the object we have been building: a density destructor, which frames Gaussianization as repeated whitening followed by an elementwise nonlinearity.

References
  1. Jaynes, E. T. (1957). Information Theory and Statistical Mechanics. Physical Review, 106(4), 620–630. 10.1103/PhysRev.106.620
  2. Cover, T. M., & Thomas, J. A. (2006). Elements of Information Theory (2nd ed.). Wiley-Interscience.
  3. Watanabe, S. (1960). Information Theoretical Analysis of Multivariate Correlation. IBM Journal of Research and Development, 4(1), 66–82. 10.1147/rd.41.0066
  4. Song, Y., & Ermon, S. (2019). Generative Modeling by Estimating Gradients of the Data Distribution. Advances in Neural Information Processing Systems (NeurIPS).