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.

The canonical RBIG loop

Alternating marginal Gaussianization and rotation to drive a distribution to N(0, I) — forward for density, inverse for generation

00 — The canonical RBIG loop

We now have both halves of Gaussianization. Part 1 turns one coordinate into a standard normal; Part 2 mixes coordinates with a rotation so the next marginal pass has something to do. Rotation-Based Iterative Gaussianization Laparra et al. (2011) is the algorithm that stacks them:

x(k+1)=Qk Ψk(x(k)),x^{(k+1)} = Q_k\,\Psi_k\big(x^{(k)}\big),

where Ψk\Psi_k is the per-coordinate marginal Gaussianization and QkQ_k is an orthogonal rotation. Iterate, and the distribution flows to N(0,I)\mathcal{N}(0,I) — a density destructor in the sense of Inouye & Ravikumar Inouye & Ravikumar (2018) (Part 0 04). Because every block is invertible, the whole stack is invertible: run it forward to evaluate density, backward to generate.

What you will see

1. One RBIG layer

A single layer does two things in sequence. First, marginal Gaussianization (Ψ): map each coordinate through Φ−1(F^i(xi))\Phi^{-1}(\hat F_i(x_i)) so every axis becomes standard normal — but the joint stays dependent (Part 2 00 showed this alone stalls). Then a rotation (QQ): re-frame the coordinates so the next marginal pass sees fresh non-Gaussian structure. rbig.MarginalGaussianize and rbig.PCARotation are the two pieces.

after marginal: per-axis std = [1. 1.]  (each ~1, but joint still moon-shaped)
<Figure size 1350x420 with 3 Axes>

The marginal step makes each axis standard normal, but the cloud is still clearly two crescents — a separable map cannot remove that. The rotation mixes the axes; now the next layer’s marginal step has new structure to attack. Stacking this block is the whole algorithm.

2. The morph: two-moons → N(0,I)\mathcal{N}(0,I)

We build the loop from scratch — fit a layer, transform, repeat — keeping each intermediate state and the total correlation TC\mathrm{TC} (Part 2’s dependence measure, 0 iff independent). Watch the crescents dissolve into an isotropic Gaussian blob.

final latent: mean = -0.000, std = 1.000, |TC| = 0.0002  (independent)
rbig.AnnealedRBIG latent: mean = -0.000, std = 1.000, |TC| = 0.0002
<Figure size 1600x300 with 6 Axes>

By a dozen layers the moons are an isotropic Gaussian and the total correlation has collapsed to (estimator) zero. Each layer chips away a little more non-Gaussianity — the formal monotone-decrease guarantee is the subject of notebook 01. Note the latent reaches N(0,I)\mathcal{N}(0,I) in distribution; individual points are not preserved across the morph (it is a transport, not a labelling).

3. Forward for density, inverse for generation

Every block is invertible, so the stack runs both ways. Forward (x→zx\to z) is what we just did — Gaussianize the data. Inverse (z→xz\to x) runs the layers in reverse, each undoing its rotation then its marginal map; feed it z∼N(0,I)z\sim\mathcal{N}(0,I) and it generates new two-moons.

round-trip error: median = 2.83e-03, max = 2.09e-01 (tails are worst — see notebook 04)

The round-trip is near machine precision in the bulk and degrades only in the tails (max ∼0.2\sim0.2), the boundary effect notebook 04 is devoted to. So the inverse mechanism is correct. Generation quality, though, depends on how smooth the marginal map is. Our from-scratch loop uses histogram marginals (Part 1 00): their inverse is piecewise-flat, so sampling N(0,I)\mathcal{N}(0,I) and inverting yields a diffuse cloud — the moons are there but smeared. Swap in the smooth mixture-CDF marginals of gauss_flows’ RBIG (Part 1 01) and the same procedure generates crisp crescents. We sample both and compare.

<Figure size 1350x460 with 3 Axes>

Same algorithm, same number of effective passes — the only difference is the marginal estimator. The histogram inverse scatters samples because its quantile function is a staircase; the smooth mixture-CDF inverse traces the manifold cleanly. The lesson generalises: for generation, use a smooth marginal; histograms are fine for a quick Gaussianization but blocky to sample from. This is also why the next notebooks lean on gauss_flows whenever sample/density quality matters.

4. The density

The same smooth gauss_flows RBIG gives a trustworthy density: with mixture-CDF marginals and an exact autodiff log-det, log⁡p(x)\log p(x) is well-defined (unlike the histogram version, whose pointwise Jacobian is rough). On N(0,I)\mathcal{N}(0,I) data its mean log-density matches the analytic value to two decimals; on two-moons its density concentrates on the crescents the generator samples.

gf.fit_rbig log p on N(0,I): mean = -2.849 (analytic -2.838)
<Figure size 560x500 with 1 Axes>

The learned density concentrates on the two crescents — the same object the generator samples from. Two takeaways for the rest of Part 3: rbig gives the canonical iterative algorithm and the information-theoretic measures (used next for convergence), while gauss_flows gives the smooth differentiable version whose exact log-det we trust for likelihoods and which Part 4 (parametric Gaussianization flows) fine-tunes end-to-end.

Recap

piecerole
marginal Ψ (Part 1)makes each axis N(0,1)\mathcal{N}(0,1); alone it stalls
rotation QQ (Part 2)mixes axes so the next marginal pass progresses
stack x(k+1)=QkΨk(x(k))x^{(k+1)}=Q_k\Psi_k(x^{(k)})drives the joint to N(0,I)\mathcal{N}(0,I) — a density destructor
forward x→zx\to zdensity / Gaussianization
inverse z→xz\to xgeneration (sample N(0,I)\mathcal{N}(0,I), invert)

Next up. We morphed for a fixed 12 layers. How many do we actually need, and how do we know we are done? 01 — Convergence & stopping shows that each layer provably reduces a non-Gaussianity measure (negentropy / total correlation), turning that into a principled stopping criterion.

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. Inouye, D. I., & Ravikumar, P. (2018). Deep Density Destructors. International Conference on Machine Learning (ICML).