KDE and Gaussian-mixture CDFs
Smooth, differentiable, invertible marginal maps, and the one knob each of them has
01 · KDE and Gaussian-mixture CDFs¶
The empirical CDF of notebook 00 is consistent but jagged, a staircase with no derivative, and it knows nothing beyond the largest and smallest sample. Both problems go away if we estimate a smooth density and integrate it into a CDF. Two estimators dominate in practice: the kernel density estimate, which is nonparametric, and the Gaussian mixture, which is parametric and is the marginal layer of gauss_flows.
import warnings
warnings.filterwarnings("ignore", message=r".*IProgress.*")
import equinox as eqx
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import numpy as np
import rbig
from jaxtyping import ArrayLike, Float, Int
from scipy import stats
from sklearn.mixture import GaussianMixture
from gauss_flows_docs.environment import watermark
from gauss_flows_docs.plotting import (
DATA_COLOR,
GAUSS_KW,
LATENT_COLOR,
standard_normal_pdf,
style_ax,
use_compact_figures,
)
from gauss_flows_maps.bijections import MixtureGaussianCDF
from gauss_flows_maps.reparam import Reparametrised
# Root finds and log-determinants get float64.
jax.config.update("jax_enable_x64", True)
rng = np.random.default_rng(11)
# Figures are stored as palette PNGs to keep the notebook small.
use_compact_figures()
watermark("jax", "numpy", "scipy", "sklearn", "rbig", "gauss_flows_maps")Python implementation: CPython
Python version : 3.13.12
IPython version : 9.12.0
jax : 0.12.1
numpy : 2.4.3
scipy : 1.17.1
sklearn : 1.8.0
rbig : 0.1.16
gauss_flows_maps: 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
Throughout we use one bimodal sample of points, half from and half from , so that the bandwidth and the number of components visibly matter.
# Shapes: sample (N) = 2,000; state (D_x) = 1; half = 1,000 draws from one mode;
# test = 500 points in x, 200 in z
# x ~ 𝒩(−2, 0.5²), the left mode, (half)
left_mode: Float[ArrayLike, " half"] = rng.normal(-2.0, 0.5, 1000)
# x ~ 𝒩(1.5, 0.8²), the right mode, (half)
right_mode: Float[ArrayLike, " half"] = rng.normal(1.5, 0.8, 1000)
SampleState = Float[ArrayLike, "sample state"]
# both modes as one coordinate, (sample, state)
samples: SampleState = np.concatenate([left_mode, right_mode])[:, None]
PerTestPoint = Float[ArrayLike, " test"]
# x on [−5, 5], for curves, (test)
grid: PerTestPoint = np.linspace(-5, 5, 500)
# z on [−4, 4], for the standard-normal reference, (test)
z_axis: PerTestPoint = np.linspace(-4, 4, 200)
print(
f"N = {samples.shape[0]}, sample mean = {samples.mean():.3f}, "
f"sample std = {samples.std():.3f}"
)N = 2000, sample mean = -0.247, sample std = 1.868
1. A KDE-based CDF¶
A kernel density estimate puts a smooth bump of width , the bandwidth, on every sample . With a Gaussian kernel it reads
Integrating term by term turns every Gaussian bump into a normal CDF, so the CDF of (1) is the mixture CDF (2) with components, equal weights , means at the samples and the common scale . It is smooth and strictly increasing, which is exactly what the marginal map (3) needs, and rbig.KDEGaussianizer builds with Scott’s rule for the bandwidth, where is the sample standard deviation.
We first build the same KDE with SciPy, to draw its density and its CDF next to the empirical CDF .
# p̂_h(x) = (1/N) ∑ₙ 𝒩(x; xₙ, h²), with Scott's h
kde_scott: stats.gaussian_kde = stats.gaussian_kde(samples[:, 0])
# h = N^(−1/5) s
bandwidth_scott: float = float(np.sqrt(kde_scott.covariance[0, 0]))
TestSample = Float[ArrayLike, "test sample"]
# (x − xₙ) / h, for every test point and every sample, (test, sample)
standardized: TestSample = (grid[:, None] - samples[None, :, 0]) / bandwidth_scott
# Φ((x − xₙ) / h), one normal CDF per sample, (test, sample)
normal_cdfs: TestSample = stats.norm.cdf(standardized)
# F̂_h(x) = (1/N) ∑ₙ Φ((x − xₙ) / h), a mixture CDF, (test)
kde_cdf: PerTestPoint = normal_cdfs.mean(axis=1)
PerSample = Float[ArrayLike, " sample"]
# x₍₁₎ ≤ … ≤ x₍N₎, (sample)
sorted_samples: PerSample = np.sort(samples[:, 0])
# #{n : xₙ ≤ x} at each test point, (test)
count_below: Int[ArrayLike, " test"] = np.searchsorted(
sorted_samples, grid, side="right"
)
# F̂_N(x) = (1/N) ∑ₙ 𝟏[xₙ ≤ x], (test)
empirical_cdf: PerTestPoint = count_below / samples.shape[0]
print(f"Scott's bandwidth h = {bandwidth_scott:.3f}")Scott's bandwidth h = 0.409
rbig.KDEGaussianizer builds the marginal map on the same KDE; we Gaussianize the sample, invert it back and test the result against .
# today (rbig)
# fit T = Φ⁻¹ ∘ F̂_h with Scott's bandwidth
kde_gaussianizer = rbig.KDEGaussianizer().fit(samples)
SampleLatent = Float[ArrayLike, "sample latent"]
# today (rbig)
# z = Φ⁻¹(F̂_h(x)), (sample, latent)
latent_kde: SampleLatent = kde_gaussianizer.transform(samples)
# today (rbig)
# x̂ = F̂_h⁻¹(Φ(z)), (sample, state)
recovered_kde: SampleState = kde_gaussianizer.inverse_transform(latent_kde)
# maxₙ |xₙ − x̂ₙ|
roundtrip_kde: float = np.abs(samples - recovered_kde).max()
# Kolmogorov–Smirnov p-value of z against 𝒩(0, 1)
ks_kde: float = stats.kstest(latent_kde.ravel(), "norm").pvalue
print(f"KDE Gaussianization: std of z = {latent_kde.std():.3f}")
print(f"round-trip error = {roundtrip_kde:.1e}")
print(f"KS test against N(0, 1): p = {ks_kde:.3f}")KDE Gaussianization: std of z = 0.915
round-trip error = 5.0e-13
KS test against N(0, 1): p = 0.027
fig, axes = plt.subplots(1, 3, figsize=(15, 4.5))
axes[0].hist(
samples[:, 0], bins=60, density=True, color=DATA_COLOR, alpha=0.5, label="data"
)
axes[0].plot(grid, kde_scott(grid), color="C3", lw=2, label=r"KDE $\hat{p}_h$")
axes[0].set(title="KDE density", xlabel="$x$", ylabel="density")
axes[0].legend(fontsize=8)
axes[1].step(grid, empirical_cdf, where="post", color="0.5", lw=1.2, label="ECDF")
axes[1].plot(grid, kde_cdf, color="C3", lw=2, label=r"KDE CDF $\hat{F}_h$")
axes[1].set(title="ECDF and KDE CDF", xlabel="$x$", ylabel="CDF")
axes[1].legend(fontsize=8)
axes[2].hist(latent_kde[:, 0], bins=50, density=True, color=LATENT_COLOR, alpha=0.6)
axes[2].plot(
z_axis, standard_normal_pdf(z_axis), **GAUSS_KW, label=r"$\mathcal{N}(0, 1)$"
)
axes[2].set(title="Gaussianized sample", xlabel="$z$")
axes[2].legend(fontsize=8)
for ax in axes:
style_ax(ax)
fig.tight_layout()
plt.show()
Figure 1:Left: the Gaussian KDE with Scott’s bandwidth traces both modes of the histogram. Middle: its CDF is the smooth curve the ECDF staircase approximates. Right: the Gaussianized sample against the standard-normal density, slightly too narrow.
The KDE traces both modes, its CDF is smooth, and the inverse returns the data to better than 10-12. The output is not quite a standard normal, though: its standard deviation is below one and the KS test rejects at the 5 % level. This is the price of smoothing. is the CDF of the data blurred by the kernel, a distribution with variance , so the samples sit inside it and land too close to the centre. Shrinking removes the bias and brings back the roughness, which is the trade-off of section 3.
2. The Gaussian-mixture CDF¶
The parametric alternative fits a mixture of Gaussians, with weights , means and scales , whose density is
and whose CDF is (2). The KDE (1) is the special case with one component per sample; a mixture keeps small, so it has only free parameters, is differentiable in all of them and extrapolates into the tails through its outer components. Its forward map (3) is a closed-form sum and its inverse is the root find (4) of Part 0. This is the marginal layer MixtureGaussianCDF that every parametric Gaussianization flow in gauss_flows stacks.
# Shapes: state (D_x) = 1; component (M) = number of mixture components
StateComponent = Float[ArrayLike, "state component"]
PerComponent = Float[ArrayLike, " component"]# user
# the EM weights w_m, means μ_m and scales σ_m in the layer's storage
def layer_parameters(mixture: GaussianMixture) -> tuple[StateComponent, ...]:
"""The stored scales, means and log-weights of a 1-D GaussianMixture."""
# M, the number of components
n_mix: int = mixture.n_components
# today (gauss_flows)
# the layer stores each scale through a softplus with a floor of 0.005
scale = Reparametrised("softplus", lower=5e-3)
# σ_m², one 1 × 1 covariance per component, (component, state, state)
covariances: Float[ArrayLike, "component state state"] = jnp.asarray(
mixture.covariances_
)
# σ_m² as a (1, M) row, the layer's parameter layout, (state, component)
variances: StateComponent = covariances.reshape(1, n_mix)
# σ_m = √(σ_m²), (state, component)
sigmas: StateComponent = jnp.sqrt(variances)
# σ_m in the layer's unconstrained storage, (state, component)
stored_scales: StateComponent = scale.parameter(sigmas)
# μ_m, (state, component)
means: StateComponent = jnp.asarray(mixture.means_).reshape(1, n_mix)
# w_m, (component)
weights: PerComponent = jnp.asarray(mixture.weights_)
# log w_m as a (1, M) row, (state, component)
log_weights: StateComponent = jnp.log(weights).reshape(1, n_mix)
return stored_scales, means, log_weightsA second helper builds an -component layer and swaps those three parameters in.
# user
# load the EM weights w_m, means μ_m and scales σ_m into a MixtureGaussianCDF
def mixture_from_em(mixture: GaussianMixture) -> MixtureGaussianCDF:
"""Load a 1-D scikit-learn GaussianMixture into a MixtureGaussianCDF."""
stored_scales: StateComponent
means: StateComponent
log_weights: StateComponent
# user
# σ_m (stored), μ_m and log w_m
stored_scales, means, log_weights = layer_parameters(mixture)
# today (gauss_flows)
# an M-component layer, then its means, scales and weights replaced
layer = MixtureGaussianCDF(n_components=mixture.n_components, shape=(1,))
# today (equinox)
# replace the means μ_m
with_means: MixtureGaussianCDF = eqx.tree_at(lambda b: b.means, layer, means)
# today (equinox)
# replace the scales σ_m
with_scales: MixtureGaussianCDF = eqx.tree_at(
lambda b: b.scales, with_means, stored_scales
)
# today (equinox)
# replace the weights w_m
return eqx.tree_at(lambda b: b.log_weights, with_scales, log_weights)# Shapes: component = 2 mixture components
# fit a two-component mixture by EM
em_mixture = GaussianMixture(2, random_state=0).fit(samples)
# today (gauss_flows)
# means at quantiles, equal weights: an initialisation, not a fit
layer_init: MixtureGaussianCDF = MixtureGaussianCDF.from_data(samples, n_components=2)
# user
# the EM fit, loaded into the same layer
layer_em: MixtureGaussianCDF = mixture_from_em(em_mixture)
# the samples as a JAX array, (sample, state)
samples_jax: SampleState = jnp.asarray(samples)
layers = {"from_data (initialisation)": layer_init, "EM fit": layer_em}For each layer we Gaussianize the sample, invert it back by bisection, and score it by its mean negative log-likelihood, the change of variables (4) averaged over the samples.
latent_mix = {}
for name, layer in layers.items():
# today (gauss_flows)
# z = T(x) and log |T'(x)|, (sample, latent), (sample)
latent: SampleLatent
log_det: PerSample
latent, log_det = jax.vmap(layer.transform_and_log_det)(samples_jax)
# today (gauss_flows)
# x̂ = T⁻¹(z), by bisection, (sample, state)
recovered: SampleState = jax.vmap(layer.inverse)(latent)
# z as a NumPy vector
latent_mix[name] = np.asarray(latent)[:, 0]
# −(1/N) ∑ₙ [log 𝒩(zₙ; 0, 1) + log |T'(xₙ)|]
nll: float = -np.mean(stats.norm.logpdf(latent_mix[name]) + np.asarray(log_det))
# Kolmogorov–Smirnov p-value of z against 𝒩(0, 1)
ks_p: float = stats.kstest(latent_mix[name], "norm").pvalue
# maxₙ |xₙ − x̂ₙ|
roundtrip: float = float(jnp.max(jnp.abs(samples - recovered)))
# standard deviation of z
std: float = latent_mix[name].std()
print(
f"{name:27s} std of z = {std:.3f}, KS p = {ks_p:.2g}, "
f"NLL = {nll:.4f}, round trip = {roundtrip:.1e}"
)from_data (initialisation) std of z = 0.862, KS p = 2e-11, NLL = 1.7712, round trip = 1.6e-15
EM fit std of z = 1.000, KS p = 0.93, NLL = 1.6397, round trip = 6.8e-15
scikit-learn scores its own EM fit the same way, so its negative log-likelihood tells us whether the loaded layer computes the same density.
# −(1/N) ∑ₙ log p_x(xₙ), scikit-learn's score of the EM fit
sklearn_nll: float = -em_mixture.score(samples)
# w_m, rounded, (component)
em_weights: PerComponent = np.round(em_mixture.weights_, 3)
# μ_m, rounded, (component)
em_means: PerComponent = np.round(em_mixture.means_.ravel(), 3)
print(f"scikit-learn NLL of the EM fit = {sklearn_nll:.4f}")
print(f"EM weights {em_weights}, means {em_means}")scikit-learn NLL of the EM fit = 1.6397
EM weights [0.497 0.503], means [ 1.511 -1.986]
To draw the fitted mixture we run the EM-loaded layer over the grid and read its density off the change of variables, .
TestState = Float[ArrayLike, "test state"]
# x at the test points, as one-coordinate events, (test, state)
grid_jax: TestState = jnp.asarray(grid)[:, None]
# today (gauss_flows)
# z = T(x) and log |T'(x)| at the test points, (test, latent), (test)
layer_latent_jax: Float[ArrayLike, "test latent"]
layer_log_det: PerTestPoint
layer_latent_jax, layer_log_det = jax.vmap(layer_em.transform_and_log_det)(grid_jax)
# z as a NumPy vector, (test)
layer_latent: PerTestPoint = np.asarray(layer_latent_jax)[:, 0]
# today (gauss_flows_docs)
# 𝒩(z; 0, 1) at the latent, (test)
reference_density: PerTestPoint = standard_normal_pdf(layer_latent)
# p_x(x) = 𝒩(z; 0, 1) |T'(x)|, (test)
layer_density: PerTestPoint = reference_density * np.exp(np.asarray(layer_log_det))fig, axes = plt.subplots(1, 3, figsize=(15, 4.5))
axes[0].hist(samples[:, 0], bins=60, density=True, color=DATA_COLOR, alpha=0.5)
axes[0].plot(grid, layer_density, color="C3", lw=2, label="two-component mixture")
axes[0].set(title="mixture density", xlabel="$x$", ylabel="density")
axes[0].legend(fontsize=8)
axes[1].plot(grid, stats.norm.cdf(layer_latent), color="C3", lw=2)
axes[1].set(title="mixture CDF $F(x)$", xlabel="$x$", ylabel="$F(x)$")
axes[2].hist(
latent_mix["EM fit"],
bins=50,
density=True,
color=LATENT_COLOR,
alpha=0.6,
label="EM fit",
)
axes[2].hist(
latent_mix["from_data (initialisation)"],
bins=50,
density=True,
histtype="step",
color="C2",
lw=1.5,
label="from_data",
)
axes[2].plot(
z_axis, standard_normal_pdf(z_axis), **GAUSS_KW, label=r"$\mathcal{N}(0, 1)$"
)
axes[2].set(title="Gaussianized sample", xlabel="$z$")
axes[2].legend(fontsize=8)
for ax in axes:
style_ax(ax)
fig.tight_layout()
plt.show()
Figure 2:Left: the two-component EM fit against the histogram. Middle: the mixture CDF of the layer, read off as . Right: the Gaussianized sample of the EM-loaded layer is a standard normal, while the from_data initialisation is too narrow.
Loaded from the EM fit, the layer turns the bimodal sample into a standard normal: unit standard deviation, a KS test that does not reject, and a mean negative log-likelihood identical to scikit-learn’s, so the layer computes the same density. The round trip through the bisection inverse is exact to better than 10-14. The from_data initialisation, with equal weights and scales set from quantile spacing, gives a narrower output that the KS test clearly rejects, which is why it is a starting point for training rather than a fit.
3. Choosing the knob: bandwidth and components¶
Each estimator has one capacity knob, and choosing it is the usual trade-off between bias and variance.
The KDE bandwidth . Too small and is a spiky overfit with high variance, whose CDF has phantom wiggles and whose derivative is noisy. Too large and it smears the two modes into one, with high bias. Plug-in rules such as Scott’s and Silverman’s Silverman, 1986 give a sensible default.
The number of components . The Bayesian information criterion Schwarz, 1978 trades the log-likelihood of the fitted mixture against its free parameters,
where is the -component mixture (2) fitted by EM, and the smallest value wins. We start with three bandwidths: one too small, Scott’s, and one too large.
bandwidths = [("too small", 0.05), ("Scott", "scott"), ("too large", 0.6)]
kdes = {}
for label, bandwidth_rule in bandwidths:
# p̂_h at this bandwidth
kdes[label] = stats.gaussian_kde(samples[:, 0], bw_method=bandwidth_rule)
# today (rbig)
# fit T = Φ⁻¹ ∘ F̂_h at this bandwidth
gaussianizer = rbig.KDEGaussianizer(bw_method=bandwidth_rule).fit(samples)
# today (rbig)
# z = Φ⁻¹(F̂_h(x)), (sample, latent)
latent_bw: SampleLatent = gaussianizer.transform(samples)
# h, the bandwidth this rule gives
bandwidth: float = float(np.sqrt(kdes[label].covariance[0, 0]))
print(f"{label:9s} h = {bandwidth:.3f}, std of z = {latent_bw.std():.3f}")too small h = 0.093, std of z = 0.993
Scott h = 0.409, std of z = 0.915
too large h = 1.121, std of z = 0.765
Then BIC (3) for mixtures of one to seven components, each fitted by EM.
# Shapes: candidate = 7 numbers of components M
# M = 1, …, 7, (candidate)
n_components: Int[ArrayLike, " candidate"] = np.arange(1, 8)
# BIC(M) for each M, (candidate)
bic: Float[ArrayLike, " candidate"] = np.zeros(len(n_components))
for index, size in enumerate(n_components):
# fit an M-component mixture by EM
mixture = GaussianMixture(size, random_state=0).fit(samples)
# BIC(M) = (3M − 1) log N − 2 ∑ₙ log p_x(xₙ)
bic[index] = mixture.bic(samples)
# the M with the smallest BIC
best: int = int(n_components[np.argmin(bic)])
print("BIC by M:", {int(m): round(float(b)) for m, b in zip(n_components, bic)})
print(f"BIC is smallest at M = {best}")BIC by M: {1: 8191, 2: 6597, 3: 6627, 4: 6642, 5: 6667, 6: 6685, 7: 6708}
BIC is smallest at M = 2
fig, axes = plt.subplots(1, 2, figsize=(12, 4.5))
axes[0].hist(samples[:, 0], bins=60, density=True, color=DATA_COLOR, alpha=0.3)
for (label, _), color in zip(bandwidths, ["C1", "C2", "C3"]):
axes[0].plot(grid, kdes[label](grid), lw=1.8, color=color, label=label)
axes[0].set(title="KDE bandwidth", xlabel="$x$", ylabel="density")
axes[0].legend(fontsize=8)
axes[1].plot(n_components, bic, "-o", color="C4", ms=5)
axes[1].plot(best, bic.min(), "k*", ms=16, label=f"smallest at $M = {best}$")
axes[1].set(title="number of components", xlabel="$M$", ylabel="BIC")
axes[1].legend(fontsize=8)
for ax in axes:
style_ax(ax)
fig.tight_layout()
plt.show()
Figure 3:Left: KDEs of the same sample at three bandwidths; the smallest is spiky and the largest erases the valley between the modes. Right: BIC against the number of mixture components, smallest at the true number of modes.
The bandwidth sweep shows the two failures, and the printed lines show the bias of section 1 in numbers: the standard deviation of the Gaussianized sample falls from 0.993 to 0.765 as grows. A small bandwidth gives an output close to unit variance but a rough CDF, a large one a smooth CDF and a narrow output. BIC (3) is smallest at , the true number of modes; more components buy too little likelihood to pay for their parameters.
4. The log-determinant of a mixture CDF¶
A flow needs the per-coordinate log-determinant of its marginal map, which (5) gives as the log-density of the data minus the standard-normal log-density at . For the mixture the density is (2), a smooth function of , so the log-determinant is smooth too. The histogram CDF of notebook 00 had a piecewise-constant density instead. MixtureGaussianCDF.transform_and_log_det returns this log-determinant, and we check it against the derivative that autodiff computes through the forward map.
# user
# T'(x) = dz/dx, by forward-mode autodiff through the EM-loaded layer
def layer_derivative(point: Float[ArrayLike, " state"]) -> Float[ArrayLike, ""]:
"""The derivative of the layer's forward map at one event ``point``."""
# today (gauss_flows)
# dz/dx, a 1 × 1 Jacobian, (latent, state)
jacobian: Float[ArrayLike, "latent state"] = jax.jacfwd(layer_em.transform)(point)
return jacobian.reshape(())# Shapes: test = 600 points in x for the log-determinant, 500 for the density
# x on [−5, 5], as one-coordinate events, (test, state)
check_points: TestState = jnp.linspace(-5, 5, 600)[:, None]
# today (gauss_flows)
# log |T'(x)| from the layer, (test)
log_det_check: PerTestPoint
_, log_det_check = jax.vmap(layer_em.transform_and_log_det)(check_points)
# user
# T'(x) at every test point, by autodiff, (test)
dz_dx: PerTestPoint = jax.vmap(layer_derivative)(check_points)
# log |dz/dx|, (test)
log_abs_derivative: PerTestPoint = jnp.log(jnp.abs(dz_dx))
# max |log |T'(x)| − log |dz/dx||
logdet_gap: float = float(jnp.max(jnp.abs(log_det_check - log_abs_derivative)))
# log p_x(x) from scikit-learn at the 500 test points, (test)
sklearn_log_density: PerTestPoint = em_mixture.score_samples(grid[:, None])
# p_x(x) from scikit-learn, (test)
sklearn_density: PerTestPoint = np.exp(sklearn_log_density)
# max |p_layer − p_scikit-learn|
density_gap: float = np.max(np.abs(layer_density - sklearn_density))
print(f"log-determinant against autodiff: max abs difference = {logdet_gap:.1e}")
print(
f"density of the layer against scikit-learn: max abs difference = {density_gap:.1e}"
)log-determinant against autodiff: max abs difference = 9.4e-15
density of the layer against scikit-learn: max abs difference = 2.2e-16
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.plot(grid, np.asarray(layer_log_det), color="C4", lw=2)
ax.set(
title="log-determinant of the mixture CDF", xlabel="$x$", ylabel=r"$\log |T'(x)|$"
)
style_ax(ax)
fig.tight_layout()
plt.show()
Figure 4:The log-determinant of the EM-loaded mixture layer. It dips in the low-density valley between the modes and rises into the tails, where the standard-normal density at shrinks faster than the data density.
The log-determinant of the layer matches autodiff to machine precision, and the density it implies matches scikit-learn’s. The low-density valley between the modes is the dip in the middle, and the curve rises into the tails, because there the standard-normal density at falls faster than the mixture density at . This smooth, exact term is what a flow sums in log_prob.
Recap¶
| Estimator | CDF | Knob | How to choose it |
|---|---|---|---|
| KDE (1) | (2) with | bandwidth | Scott, Silverman, cross-validation |
| Gaussian mixture (2) | (2) | components | BIC (3), held-out likelihood |
| Tool | Role |
|---|---|
rbig.KDEGaussianizer | nonparametric smooth marginal |
rbig.GMMGaussianizer | parametric marginal, fitted by EM |
MixtureGaussianCDF | parametric marginal bijection with a log-determinant, the flow layer |
Next. Mixtures are smooth and compact, but their inverse needs a root find. Notebook 02 builds marginals from monotone splines, including the rational-quadratic spline whose inverse is closed form.
- Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis. Chapman.
- Schwarz, G. (1978). Estimating the Dimension of a Model. The Annals of Statistics, 6(2), 461–464. 10.1214/aos/1176344136