- Home
- Library
- Computational Quantum Field Theory
- From Generated Events to an Inferred Coupling
- Learning Likelihood Ratios and Posteriors
Learning Likelihood Ratios and Posteriors
A classifier can learn to distinguish events generated at two couplings. Its output can then estimate a likelihood ratio—but classification accuracy alone does not establish calibrated parameter inference. Small per-event errors can accumulate across an observation, and a flexible model can fail badly outside its training range.
We will train a small polynomial classifier on the preceding angular simulator, compare it with the exact likelihood, and test repeated-data coverage. The example retains failures: the larger classifier is less accurate than a restricted alternative in several tests, and its extrapolated confidence sets miss the truth in every retained test observation. Pointwise calibration and a deliberate efficiency mismatch show what statistical calibration can and cannot repair.
Preparation: The exact count-and-angle likelihood, logistic regression and elementary probability. The example trains a polynomial classifier, not a neural network.
Why a classifier contains a density ratio
Let denote the detected angular density at coupling , with the efficiency fixed to its nominal value. Choose a reference and make a labeled training population:
Bayes' rule gives the population probability of class 1,
Binary cross entropy is minimized pointwise by . With equal class priors its optimal logit is the log density ratio. A finite trained model need not reach this population optimum. In particular, ranking events well does not establish that the numerical output is a calibrated class probability.
Cranmer, Pavez and Louppe prove the related invariance of a density ratio under a reduction monotone in that ratio, and separate learning the score from calibrating its distribution in §§2.2–2.3. Their Eq. (2.10) uses the opposite class convention from Eq. (2), so the odds must be inverted when translating labels. Cranmer, Pavez and Louppe
To learn many couplings at once, draw from the same distribution for both classes and feed to the classifier. Equal parameter distributions are consequential: otherwise the class odds also contain their ratio. The reference events still carry a sampled input , even though their angle is drawn at . Parameterized classification is described in that source's §3.2 and Algorithm 1.
Freeze a simulator, training range and model
The exact angular density is
The known count mean is , with , and nominal . Set . Train on uniform in , using exactly balanced classes and independent simulation streams. The fixed inference domain is wider, , so its outer parts are explicitly an extrapolation test.
Let be Legendre polynomials, , and define
This has 54 learned coefficients and enforces . The probabilities in Eq. (3) are used to generate events, not as target ratio labels. A limited eight-coefficient alternative uses , . Both are trained by minimizing
The implementation evaluates the logarithm stably and supplies an analytic gradient to L-BFGS. There are 131072 training events, 32768 independent validation events and 65536 independent classifier-test events per fit. Three independent training seeds are retained for the 54-coefficient model; the limited model uses the first training sample. Architecture, penalty and these sample sizes were fixed before the inference tests.
All four fits stop successfully by the optimizer's stopping rules, but their actual gradient infinity norms, approximately –, miss the requested gradient target. The diagnostics retain both facts. Directional finite differences check the gradient, and the positive ridge permits a strong-convexity objective-gap diagnostic from its norm. This small numerical optimization uncertainty is separate from approximation and finite-training error; a success flag cannot remove either.
On held-out classifier samples the raw log-ratio root-mean-square errors are – for the larger models and for the limited model. The latter is not an observed underfitting failure. Additional coefficients have not improved this fixed-budget experiment.
A normalized working shape still needs validation
Exponentiating a fitted logit gives positive odds, but usually not a normalized density ratio. Define
In this bounded example the reference density is known, so quadrature can perform this normalization without using exact target ratios as training labels. This is an explicit advantage of the benchmark, not a generic black-box normalization method. With only a reference simulator, the integral would itself require estimation and an uncertainty assessment.
Across the fixed 141-point inference scan, doubling the normalizer quadrature from 128 to 256 nodes changes by at most . The raw normalization defects within the training range reach about – for the larger models and for the limited one. Outside training they can become enormous: the maximum absolute defect across the wider inference scan reaches . The exact exponential normalization remains numerically tractable using log-sum-exp, but cannot repair an incorrect angular shape.
This is why normalization, probability calibration and interval calibration are different checks. The first fixes an integral; the second tests the classifier's numerical probability output; the third concerns a repeated-data decision procedure. Weighted-distribution and reference checks for approximate ratios are discussed in Cranmer, Pavez and Louppe, §3.5. Cranmer, Pavez and Louppe
Keep the count term when learning only the shape
For observed angles , the working log likelihood relative to the reference observation is
The rate is retained exactly; only the shape ratio is learned. Dropping the first two terms would perform conditional-on-count inference and answer a different question. The exact baseline uses the same observations and the concave score in derived in the preceding article.
For the learned model, search a fixed 561-point parameter grid, refine every grid-local maximum, and compare the endpoints. Extra maxima are retained rather than silently selecting the one closest to the generating coupling. A 1121-point check on the first 20 test observations in each condition changes estimates by at most and likelihood-ratio statistics by .
A posterior can be formed from the same ratio,
Its interpretation still depends on a stated prior measure and the working model. Learning a ratio does not learn a prior, and a credible interval is not automatically a confidence interval. The companion retains complete likelihood-ratio sets and a uniform- posterior for the displayed observation, rather than identifying an optimizer curvature with either object. A direct posterior-learning method would also inherit the distribution of parameters used to train it; the distinction between likelihood, ratio and posterior surrogates is discussed by Cranmer, Brehmer and Louppe, §3.2. Cranmer et al.
Repeated observations expose the extrapolation failure
For each held-out truth , generate 1000 test observations, with fresh Poisson counts and detected angles. All methods use the same observations for paired comparisons. The first three truths lie in training; does not. Each training fit stays frozen.
Define the two-sided statistic
We first test the nominal rule , whose 95% interpretation is asymptotic for a correct regular likelihood. The table gives actual inclusion fractions, with bias defined as the test mean of .
| True | Exact: 95% inclusion | 54 coefficients, seed 0: inclusion | 8 coefficients: inclusion | 54 coefficients, seed 0: bias |
|---|---|---|---|---|
| 0.5 | 0.952 | 0.899 | 0.937 | -0.00280 |
| 0.8 | 0.946 | 0.945 | 0.948 | +0.00091 |
| 1.1 | 0.947 | 0.888 | 0.949 | -0.00875 |
| 1.4 | 0.959 | 0.000 | 0.956 | -0.17117 |
For a fraction from 1000 independent tests, its conditional binomial standard error is ; near 0.95 this is about 0.007. At a measured fraction of zero this plug-in standard error is zero, but it does not prove that the population probability is exactly zero. The retained count is the precise statement: none of the 1000 extrapolation tests included truth for any of the three larger fits.
The other two 54-coefficient training seeds have extrapolation biases and , also with zero nominal inclusion. Within training, at their inclusion fractions are 0.909 and 0.906. The high-degree fits frequently introduce extra stationary points. The independent training runs share test observations and are reported separately, not pooled as independent repetitions.
The limited model performs substantially better in this experiment, including at the selected extrapolation point. That observation does not establish reliable extrapolation for a general low-degree model. It shows why model capacity and a good training loss cannot replace held-out inference tests.
Top: normalized shape ratios relative to , showing the larger classifier's extrapolation failure. Bottom left: nominal 95% inclusion fractions; the vertical line marks the upper training boundary. Bottom right: the independent efficiency-shift experiment. Error bars describe finite test repetitions conditional on each frozen fit, not uncertainty in the simulator or training procedure. The larger-model curves use training seed 0; the other retained seeds show the same extrapolation failure.
What pointwise simulation calibration actually guarantees
A chosen statistic can be calibrated without assuming that it is an exact likelihood ratio. At each of the four declared truths, generate a separate set of calibration observations. Let their statistics at that truth be sorted as . For desired inclusion , use
provided . With continuous independent statistics and a frozen fitted model, exchangeability gives inclusion probability averaged over both the random calibration sample and a new test observation. It does not guarantee that one realized calibration threshold has that conditional coverage. Ties handled by the non-strict inclusion rule can make coverage conservative.
Using the independent test observations, calibrated 95% inclusion for the seed-0 larger model is 0.947, 0.961, 0.950 and 0.937 at the four truths. This restores a useful pointwise test even when the estimator at remains badly biased. Calibrating a threshold does not correct the point estimate or recover information lost by a poor statistic.
Finite calibration fluctuations also occur for the exact likelihood: at its calibrated 68.27% inclusion in this retained test set is 0.637. The rank statement is a repeated-calibration statement, while the displayed binomial uncertainty concerns test data conditional on the particular threshold. The study calibrates four parameter points; it does not construct or validate a continuous confidence belt between them. The use of simulator-based calibration and its limitations are discussed in Cranmer, Brehmer and Louppe, §3.3. Cranmer et al.
Correct calibration cannot fix the wrong simulator
Finally generate 1000 independent observations at with true efficiency slope . Analyze them with the nominal model , retaining its nominal calibration thresholds. All efficiencies remain valid probabilities.
| Analysis under the shifted observations | Bias in | Nominal 95% inclusion |
|---|---|---|
| Exact likelihood, wrong efficiency | -0.06420 | 0.777 |
| 54 coefficients, seed 0, wrong efficiency | -0.06441 | 0.777 |
| 8 coefficients, wrong efficiency | -0.06364 | 0.756 |
| Exact likelihood, true efficiency | -0.00195 | 0.947 |
Applying the nominal pointwise calibration raises the first two inclusion fractions only to 0.790 and 0.810. The calibration data and shifted observations are not identically distributed, so the exchangeability argument no longer applies. The truth-aware exact control isolates this model error from the classifier approximation. Recalibrating on a correct shifted simulator would change the model being supplied; it is not an ability of the nominal network or classifier to discover its own missing physics.
The source's §3.3 explicitly separates finite-estimator diagnostics from model misspecification. In practice an adequately supported nuisance model or a corrected simulator is needed. Our previous article's efficiency calibration supplies one transparent example; this shifted test deliberately fixes the wrong value instead. Cranmer et al.
The retained companions are learned_ratio.py, ratio_study.py, the actual fitted coefficients in ratio-models.json, and selected diagnostics and per-replica summaries in ratio-results.json. Training, validation, classifier tests, interval calibration and final observations use separate random streams. The inference is one-dimensional and analytically checkable; it is not a demonstration of detector-scale learning or a production speed advantage.
Summary
Classifier odds can estimate a density ratio, but finite learning, normalization, interval calibration and simulator correctness are separate questions. The actual trained example fails some nominal coverage tests and extrapolation, while pointwise simulation calibration supplies a more limited guarantee. Efficiency mismatch biases both exact and learned inference.
Exercises
- Derive Eq. (2) for unequal class priors. Suppose a classifier output is a strictly increasing function of the true log ratio, but its numerical probability scale is wrong. Which testing property survives, and why can plugging its odds into a likelihood still fail?
Solution
The class-posterior odds equal the prior odds times the density ratio:
which rearranges to Eq. (2). Omitting the class-prior correction rescales the inferred event ratio. When training-class proportions also depend on , the missing factor can change the parameter likelihood rather than merely adding a data-only constant.
A strictly monotone score preserves event ordering for a simple-hypothesis test. Its threshold can therefore implement the same likelihood-ratio ordering after calibration. It does not fix the numerical likelihood ratio: replacing the log ratio by , for example, keeps ordering but replaces the odds ratio by its square. Products of such per-event numbers produce the wrong likelihood curvature and generally the wrong inference. One must calibrate class probabilities or the induced score distributions, or independently calibrate the chosen test statistic. The last option validates a test under its simulator without proving that the guessed density ratio was correct.
- Prove the rank statement below Eq. (10). Explain its conditioning, what ties do, and why using nominal calibration with the shifted efficiency experiment breaks the argument.
Solution
Condition on a trained model and a fixed generating parameter. Under the stated model, the calibration statistics and the new test statistic are independent and identically distributed. If their distribution is continuous, every rank of the test statistic among the values has probability . The test statistic is at most the th calibration order statistic exactly when its combined rank is at most . Hence
The probability includes variation of the calibration values. After observing one threshold, its conditional inclusion probability is the unknown cumulative distribution evaluated at that threshold, and need not equal . With ties, random tie-breaking recovers uniform ranks; retaining all ties through gives at least the randomized inclusion probability, hence possible conservatism.
Under an efficiency shift, nominal calibration statistics and shifted test statistics come from different distributions. They are no longer exchangeable, so the uniform-rank proof fails. More nominal calibration observations only estimate the wrong distribution more precisely. They cannot repair the discrepancy between nominal and actual observation laws.
References
- Cranmer, Kyle, Johann Brehmer and Gilles Louppe. “The frontier of simulation-based inference,” arXiv:1911.01429v3. Sections 3.2–3.3 distinguish likelihood, ratio and posterior surrogates, and discuss repeated-simulation calibration and simulator misspecification.
- Cranmer, Kyle, Juan Pavez and Gilles Louppe. “Approximating Likelihood Ratios with Calibrated Discriminative Classifiers,” arXiv:1506.02169v2. Sections 2.2–2.3, Theorem 1 and Eq. (2.10), derive the classifier connection; §§3.1–3.3 and Algorithm 1 develop parameterized inference; §3.5 gives ratio diagnostics.
Scrollable formula. Use Left and Right arrow keys to reveal hidden content.
Scrollable table. Use Left and Right arrow keys to reveal hidden columns.
Scrollable figure. Use Left and Right arrow keys to reveal hidden content.