Skip to main content
Sandbox Physics

Neural Posterior Calibration and Model Mismatch

How can you tell whether a neural network's posterior deserves trust? Test it on many simulated datasets whose true values are known. Draw the source from the prior and generate data with the assumed model. The fraction of true values inside the network’s 90 percent regions checks calibration at that level for these simulations. Use residuals to check whether the assumed signal and noise describe the data.

Change the noise or add a signal the model lacks to a synthetic ringdown, and watch when a frozen neural posterior and the exact posterior stop covering the truth.

Interactive modelNeural Posterior Calibration and Model Mismatch
Truth inside the exact 90% region0.8890.889
Truth inside the network 90% region0.9170.917
Importance-sampling efficiency0.990.99
Residual test p-value0.50.5

Cyan: exact grid posteriorAmber: frozen neural posteriorWhite: injected source or nominal value

Neither check flags this record.

Where each posterior puts the source

Solid lines: 90% regions. Dashed: 50%. Dots: network draws. Drag the white marker to move the source.

How often the true source falls inside

Repeated noise at this one source. The pale band shows sampling variation if the coverage at this source is 90%; short dotted marks are a saved 400-record reference when a preset is selected.

Offline calibration over the prior

Offline case: noise inside the training range, no mismatch.

More numbers and the offline rank test
Records in the live count
Optimal signal-to-noise ratio
Jensen–Shannon divergence between the posteriors · nats
Exact posterior mean frequency · Hz
Network posterior mean frequency · Hz
Exact posterior mean damping time · ms
Network posterior mean damping time · ms
Noise level actually in the record
Simulation-based calibration of the network

Rank of the true value among 99 network draws, for 2000 sources from the prior. Filled bars: frequency. Outlined bars: damping time. Grey band: 99% range for uniform ranks.

Training: 30.7 million simulations, 23198 weights, 7 minutes on one CPU. Frozen weights SHA-256 bb213976acf54c96…

Three ways a posterior can fail

BackgroundA damped sinusoid rings in noisy synthetic data. An exact grid calculation and a neural network trained on simulations both estimate its frequency and damping time from each new record.

Why it mattersNeural posteriors are fast enough to analyse a gravitational-wave event in seconds, so their errors have to be found before anyone relies on them.

Focus question
When does a posterior that looks sharp stop telling the truth?
One-sentence intuition
Calibration on simulations tests the network against the model; only a test against the data checks the model itself.

Core mathematical model

Bayes' theorem for the source parameters

p(θ∣d)=p(d∣θ) p(θ)p(d)p(\theta\mid d)=\frac{p(d\mid\theta)\,p(\theta)}{p(d)}

The exact posterior follows from the likelihood of the assumed model and the prior.

Gaussian white-noise likelihood

ln⁡p(d∣θ)=−12σ2∑k[dk−hk(θ)]2+const\ln p(d\mid\theta)=-\frac{1}{2\sigma^2}\sum_{k}\bigl[d_k-h_k(\theta)\bigr]^2+\text{const}

Every sample has independent noise of standard deviation sigma; the grid evaluates this sum for every candidate source.

Coverage of a 90% region

Pr⁡[θ∗∈R0.9(d)]≈0.9\Pr\bigl[\theta^{\ast}\in R_{0.9}(d)\bigr]\approx0.9

Draw a new source from the prior for each record and generate the data using the assumed model. For this ensemble, a calibrated 90% region contains the true source about nine times in ten. The live tally instead repeats noise at one fixed source.

Common difficulties

A perfect likelihood does not fix a wrong model

Typical misconceptionIf the network matches the exact posterior, the answer must be right.

Better mental modelBoth posteriors use the same assumed model. When the record holds a signal the model lacks, they can agree with each other and both miss the true source.

Run the experiment

  1. 01

    Watch the count settle

    Start from Trained conditions and let new records stream for half a minute.

    What to observe: In the saved 400-record run, the grid and network fractions are 0.900 and 0.905. Compare the live fractions with those reference marks. The cyan and amber regions each show the analysis of the current record.
  2. 02

    Leave the training range

    Choose Cleaner than the training data, or drag the noise band edge below 0.15.

    What to observe: The exact posterior stays near 0.9, the network falls far below it, and the importance-sampling efficiency drops toward zero. That low efficiency is the warning sign.
  3. 03

    Hide a signal from both analyses

    Choose A hidden second mode, then A glitch in the record. Read the efficiency and the residual test.

    What to observe: Both posteriors miss the source more often than one time in ten in the saved runs. The saved median efficiency is 0.983 for the second mode and 0.292 for the glitch. The residual test flags every glitch in that saved group and 6.3 percent of the second-mode group. Shifts in fitted frequency and damping time absorb much of the second mode.

Related experiments and articles

What this page links to directly

See every article series on the content map →

Continue exploring

Testing a model of the universe

How do we test a model of the universe against data, and how far can we trust the result?

  1. LabSupernova Distances and the Distance LadderChange the matter fraction and see which expansion history fits the supernovae.
  2. LabDark Energy or Modified GravityChange gravity’s running strength and compare clustering growth with Einstein gravity.
  3. LabFlat Torus Universe and Matched CirclesChange the box edge and watch the matched circles shrink and vanish as the box grows.
  4. LabOne Sky and Cosmic VariancePress Draw another sky a few times and watch the measured power wander around the theory.
  5. LabCosmology, Likelihoods and PriorsWiden the prior half-width and watch whether the data or the prior sets the answer.
  6. You are hereNeural Posterior Calibration and Model MismatchPick Noise louder than assumed and watch whether the 90% regions still catch the truth.

Trusting posteriors learned from simulations · Reading path

From a posterior to calibration and model mismatch

Read the articles on this path that use this Lab, then try the other Labs they suggest.

  1. ArticleHow can you tell whether a neural network's posterior deserves trust?
  2. ArticleWhat a posterior and a 90% credible region promise
  3. ArticleChecking posterior calibration with ranks and coverage
  4. ArticleFinding a wrong simulator with importance weights and residuals
  5. ArticleRecompute the ringdown posterior calibration
  6. ArticleReading the DINGO evidence: P–P plots, divergences and sample efficiency
Something broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy