---
title: Per-Event Likelihood-Ratio Estimator
url: https://www.emergentmind.com/topics/per-event-likelihood-ratio-estimator
type: topic
---

# Per-Event Likelihood-Ratio Estimator

A per-event likelihood-ratio estimator is an estimator of the likelihood ratio associated with a single observation, feature, or time step. In its simplest form, for two simple hypotheses \(H_0\) and \(H_1\) with densities \(p_0(x)\) and \(p_1(x)\), it targets \(r(x)=p_1(x)/p_0(x)\) and often also its log form \(\ell(x)=\log r(x)\). The same idea appears in several closely related settings: discrete event ranking with empirical counts, neural classifier-based ratio learning, amortized simulation-based inference through likelihood-to-evidence ratios, online non-parametric density-ratio estimation, and sequential decision-making through per-round likelihood-ratio contributions [2305.10500] [1903.04057] [2311.04402].

## 1. Formal object and statistical role

For two simple hypotheses, the per-event likelihood ratio is
\[
r(x)=\frac{p_1(x)}{p_0(x)}, \qquad \ell(x)=\log r(x).
\]
This quantity is fundamental because, by the Neyman–Pearson lemma, the uniformly most powerful test for \(H_0\) versus \(H_1\) uses the statistic \(T=\sum_i \ell(x_i)\) for independent events. The same additive structure makes per-event log-likelihood ratios natural components of profile likelihoods, confidence intervals, and composite scores assembled from multiple features [2305.10500].

The definition generalizes beyond fixed hypotheses. In simulation-based inference with intractable likelihoods, one often defines the likelihood-to-evidence ratio
\[
r(x,\theta)=\frac{p(x\mid \theta)}{p(x)},
\]
so that the per-event likelihood ratio between two parameter values satisfies
\[
L(x;\theta,\theta')=\frac{p(x\mid \theta)}{p(x\mid \theta')}=\frac{r(x,\theta)}{r(x,\theta')}.
\]
This formulation is central when the simulator can generate \(x\sim p(x\mid \theta)\) but \(p(x\mid \theta)\) cannot be evaluated analytically [1903.04057].

In sequential decision-making, an “event” may be a single round \(t\) with context or action \(x_t\) and outcome \(y_t\). The per-event contribution is then
\[
l_t(\theta)=\frac{p_\theta(y_t\mid x_t)}{p_{\hat\theta_t}(y_t\mid x_t)},
\]
or, in the weighted formulation,
\[
l_t^{(w)}(\theta)=\frac{p_\theta(y_t\mid x_t)^{w_t}}{p_{\hat\theta_t}(y_t\mid x_t)^{w_t}}.
\]
Cumulative products of these per-event quantities generate anytime-valid confidence sequences through likelihood-ratio processes [2311.04402].

The term “per-event” therefore does not refer to a single implementation pattern. It refers to a granularity: one estimates a ratio contribution locally, then combines those local contributions across events by multiplication of ratios or addition of log-ratios. This common structure links hypothesis testing, reweighting, ranking, MCMC acceptance ratios, and sequential confidence construction.

## 2. Count-based estimators and rare-event conservatism

In discrete settings with observed counts, the most direct estimator replaces class-conditional probabilities by empirical frequencies. If \(n_c(e)\) is the count of event \(e\) in class \(c\) and \(N_c=\sum_e n_c(e)\), then
\[
\hat p(e\mid c)=\frac{n_c(e)}{N_c},
\qquad
\widehat{\mathrm{LR}}(e)=\frac{\hat p(e\mid c=1)}{\hat p(e\mid c=0)}.
\]
In the named-entity context-prediction task of “Conservative Likelihood Ratio Estimator for Infrequent Data Slightly above a Frequency Threshold,” the event is a word bigram immediately to the left of a named entity, the numerator context is “left-of-NE,” and the denominator context is the unconditional corpus distribution. The resulting maximum-likelihood estimator is
\[
r_{\mathrm{MLE}}(x)=\frac{f_{\rm nu}(x)/n_{\rm nu}}{f_{\rm de}(x)/n_{\rm de}},
\]
with log form
\[
\hat\ell(x)=\log f_{\rm nu}(x)-\log n_{\rm nu}-\log f_{\rm de}(x)+\log n_{\rm de}.
\]
The paper emphasizes that low counts make this ratio unstable and heavy-tailed, so rare events tend to be over-ranked [2211.00545].

A simple baseline imposes a numerator frequency threshold \(\theta_{\rm th}\):
\[
r_{\rm th}(x)=
\begin{cases}
r_{\rm MLE}(x) & \text{if } f_{\rm nu}(x)>\theta_{\rm th},\\
0 & \text{otherwise.}
\end{cases}
\]
In that ranking task, zero means “no contribution” rather than a neutral \(LR=1\). This pruning improves efficiency and removes some extreme rare-event estimates, but it leaves discontinuous behavior and still overestimates just above the threshold [2211.00545].

The conservative alternative proposed in the same work derives a closed-form \(\ell_1\)-regularized least-squares importance-fitting estimator on discrete one-hot bases:
\[
r_{\rm L1}(x)=\left(\frac{f_{\rm de}(x)}{n_{\rm de}}\right)^{-1}\frac{\max\big(f_{\rm nu}(x)-\theta_{\rm L1},0\big)}{n_{\rm nu}}.
\]
For \(f_{\rm nu}(x)>\theta_{\rm L1}\),
\[
r_{\rm L1}(x)=r_{\rm MLE}(x)\left(1-\frac{\theta_{\rm L1}}{f_{\rm nu}(x)}\right),
\]
and
\[
\ell_{\rm L1}(x)=\hat\ell_{\rm naive}(x)+\log\left(1-\frac{\theta_{\rm L1}}{f_{\rm nu}(x)}\right).
\]
The correction is largest near the threshold and vanishes as \(f_{\rm nu}(x)\) grows. The estimator is nondecreasing in numerator count, nonincreasing in denominator count, and converges to the MLE as counts become large [2211.00545].

The same paper reports a concrete large-sparse NLP experiment on the WSJ 1987 corpus with 12,000 sampled articles, split into 10,000 train, 1,000 validation, and 1,000 evaluation articles. Validation over \(\theta\in\{1,\dots,9\}\) selected \(\theta_{\rm L1}=2\). In rank–recall evaluation, \(\ell_2\)-regularized estimation was best overall, thresholding improved over the naive baseline, and the \(\ell_1\) conservative estimator slightly outperformed simple thresholding while retaining essentially the same efficiency. Measured averages over 10 runs showed substantial memory and time reductions for thresholding and \(\ell_1\) relative to the baseline and \(\ell_2\) estimators [2211.00545].

Rare-event conservatism also appears in forensic genetics. For a rare haplotype match, the likelihood ratio for event \(E\) is
\[
\mathrm{LR}(E)=\frac{P(E\mid H_p)}{P(E\mid H_d)},
\]
with \(P(E\mid H_p)\approx 1\) and, in a panmictic model without structure, \(P(E\mid H_d)=p\), so \(\mathrm{LR}(E)=1/p\). “Impact of model choice on LR assessment in case of rare haplotype match” reviews plug-in estimators, conservative upper confidence bounds such as the rule of three, a discrete Laplace model, and the nonparametric generalized-Good method. Its central methodological point is that different data reductions and population models define different legitimate likelihood ratios, so it is more sensible to speak of “an LR” rather than “the LR,” and to quantify estimation error explicitly [1502.04083].

## 3. Classifier-based neural estimators

A broad modern approach estimates per-event likelihood ratios through probabilistic classifiers. If a classifier is trained to distinguish samples from \(p_0(x)\) and \(p_1(x)\) with class priors \(\pi_0\) and \(\pi_1\), the Bayes-optimal score is
\[
s^*(x)=\frac{\pi_1 p_1(x)}{\pi_0 p_0(x)+\pi_1 p_1(x)}.
\]
From this,
\[
r(x)=\frac{p_1(x)}{p_0(x)}=\frac{\pi_0}{\pi_1}\frac{s^*(x)}{1-s^*(x)},
\qquad
\ell(x)=\logit(s^*(x))-\log(\pi_1/\pi_0).
\]
With equal priors, \(r(x)=s^*(x)/(1-s^*(x))\) and \(\ell(x)=\logit(s^*(x))\). “Learning Likelihood Ratios with Neural Network Classifiers” stresses that any strictly monotonic function of \(r(x)\) preserves ranking and optimal decision boundaries, but recovering the numerical likelihood ratio requires calibrated outputs and correct prior adjustment [2305.10500].

That paper develops a general loss-functional view. For a learnable function \(f(x)=\phi(z(x))\) and rescaling functions \(A,B\),
\[
L[f]=-\int dx \,[p_0(x)A(f(x))+p_1(x)B(f(x))],
\]
and the extremum satisfies
\[
r(x)=\frac{p_1(x)}{p_0(x)}=-\frac{A'(f(x))}{B'(f(x))}.
\]
This produces several concrete loss families. BCE and MSE yield the odds mapping \(r(x)=f/(1-f)\); MLC and SQR target \(r(x)=f(x)\) directly. The paper studies BCE, MSE, MLC, SQR, and generalized \(p\)-MSE and \(r\)-SQR families, together with output parameterizations on \((0,1)\) or \((0,\infty)\) such as sigmoid, Gaussian CDF, arctan-to-\((0,1)\), ReLU, \(z^2\), and \(\exp(z)\) [2305.10500].

The empirical findings are highly specific. For BCE and MSE, sigmoid is best or close in most cases. For MLC and SQR, \(\exp(z)\) is dramatically better than ReLU or \(z^2\). In univariate Gaussian experiments, BCE and MSE outperformed MLC and SQR under naive parameterizations, while with optimized implementations the standard losses became similar and the generalized families often achieved the smallest MAE. In multivariate Gaussian cases, MLC with \(\exp(z)\) was best among the four standard losses in the more complex problems, and \(r^*\)-SQR often reduced MAE by \(30\)–\(50\%\) relative to MLC+\(\exp(z)\), except in the Hyperbola case where gains were limited. In the high-energy physics jet study, BCE and MSE again preferred sigmoid, MLC and SQR preferred \(\exp(z)\), and gains from generalized families were minor because the MAE landscape was comparatively flat [2305.10500].

The implementation details are also part of the method. The paper uses Keras/TensorFlow, Adam, three hidden layers of widths \(64\)–\(128\)–\(64\), ReLU activations, dropout \(10\%\) after each hidden layer, early stopping with patience \(10\), up to \(100\) epochs, batch size \(10\%\) of the training set, and ensembles of \(100\) independent trainings per configuration. It recommends BCE or MSE with a sigmoid output when the ratio is recovered via odds, and MLC with \(\exp(z)\) when directly regressing the likelihood ratio. Calibration through isotonic regression or Platt scaling is identified as particularly important when BCE or MSE outputs are converted to ratios [2305.10500].

## 4. Amortized estimators for likelihood-free inference

When the likelihood \(p(x\mid \theta)\) is intractable but simulation is available, the per-event object often estimated is not directly \(p(x\mid \theta)/p(x\mid \theta')\), but the likelihood-to-evidence ratio
\[
r(x,\theta)=\frac{p(x\mid \theta)}{p(x)},
\]
where \(p(x)=\int p(x\mid \theta)p(\theta)\,d\theta\). The key identity
\[
L(x;\theta,\theta')=\frac{p(x\mid \theta)}{p(x\mid \theta')}=\frac{r(x,\theta)}{r(x,\theta')}
\]
allows a single amortized estimator to support many pairwise likelihood-ratio computations [1903.04057].

“Likelihood-free MCMC with Amortized Approximate Ratio Estimators” learns \(r(x,\theta)\) by binary classification between dependent pairs \((x,\theta)\sim p(x,\theta)=p(\theta)p(x\mid \theta)\) and independent pairs \((x,\theta)\sim p(x)p(\theta)\). The Bayes-optimal classifier score is
\[
s^*(x,\theta)=\frac{p(x,\theta)}{p(x,\theta)+p(x)p(\theta)}
=\frac{p(x\mid \theta)}{p(x\mid \theta)+p(x)},
\]
and therefore
\[
r(x,\theta)=\frac{s^*(x,\theta)}{1-s^*(x,\theta)}.
\]
If the network outputs logits \(h(x,\theta)\), then \(\log r(x,\theta)=h(x,\theta)\) and \(r(x,\theta)=\exp(h(x,\theta))\). The training objective is binary cross-entropy over mixed batches of joint and product-of-marginals samples, typically implemented by constructing negative examples through shuffling or the “two batches trick” [1903.04057].

The principal advantage is amortization. One network is trained once over the prior support of \(\theta\) and the observation space of \(x\), then reused for posterior scanning, per-event likelihood-ratio evaluation, and MCMC acceptance probabilities. For a fixed observed event \(x_{\rm obs}\), the Metropolis–Hastings acceptance rule becomes
\[
\alpha(\theta\to \theta')
=
\min\!\left(
1,
\frac{p(\theta')\,\hat r(x_{\rm obs},\theta')\,q(\theta\mid \theta')}
{p(\theta)\,\hat r(x_{\rm obs},\theta)\,q(\theta'\mid \theta)}
\right).
\]
The paper recommends log-domain computation, direct use of logits as \(\log \hat r\), and proposal tuning toward acceptance rates around \(0.2\)–\(0.5\) [1903.04057].

The same estimator supports event-level hypothesis testing and dataset-level aggregation. For a single event,
\[
\hat L(x;\theta,\theta')=\exp[h(x,\theta)-h(x,\theta')],
\]
and for multiple i.i.d. observations \(X=\{x_i\}\),
\[
\Lambda(X;\theta,\theta')=\sum_i [h(x_i,\theta)-h(x_i,\theta')].
\]
The paper further describes diagnostics and robustness procedures: a ROC/AUC diagnostic based on the identity \(p(x\mid \theta)=p(x)r(x,\theta)\), simulation-based calibration, posterior predictive checks, effective sample size, \(R\)-hat, trace plots, autocorrelation, and ensembling with averaged logits for stability [1903.04057].

This formulation is closely related to, but distinct from, classifier-based two-sample likelihood-ratio estimation. Here the classifier is conditioned on \(\theta\) and trained against the product of marginals rather than against a fixed alternative class. The paper argues that this avoids the support-mismatch issues that arise with fixed-reference classifiers, provided the simulator covers the prior support adequately [1903.04057].

## 5. Online and sequential formulations

In sequential decision-making, per-event likelihood-ratio estimation is used not only to score observations but also to build time-uniform uncertainty sets. “Likelihood Ratio Confidence Sets for Sequential Decision Making” considers a sequence of contexts or actions \(x_t\) and outcomes \(y_t\), with likelihood family \(p_\theta(y_t\mid x_t)\) and estimator sequence \(\{\hat\theta_t\}\) chosen before observing \(y_t\). The per-event contribution is
\[
l_t(\theta)=\frac{p_\theta(y_t\mid x_t)}{p_{\hat\theta_t}(y_t\mid x_t)},
\]
or, with adaptive weights \(w_t\in(0,1]\),
\[
l_t^{(w)}(\theta)=\frac{p_\theta(y_t\mid x_t)^{w_t}}{p_{\hat\theta_t}(y_t\mid x_t)^{w_t}}.
\]
The cumulative product
\[
\Lambda_T(\theta)=\prod_{t=1}^T l_t^{(w)}(\theta)
\]
defines the confidence set
\[
C_T(\alpha)=\{\theta\in\Theta:\Lambda_T(\theta)\le 1/\alpha\}.
\]
Under measurability conditions on \(\{\hat\theta_t\}\) and \(\{w_t\}\), the reciprocal process is a nonnegative supermartingale, and Ville’s inequality yields anytime-valid coverage \(P(\exists t:\theta^\star\notin C_t(\alpha))\le \alpha\) [2311.04402].

The size of these sets depends on the estimator sequence. The paper therefore links per-event LR estimation to online convex optimization, especially Follow-the-Regularized-Leader:
\[
\hat\theta_t\in \arg\min_{\theta\in\Theta}
\sum_{s=1}^{t-1} -\log p_\theta(y_s\mid x_s)+\psi_t(\theta).
\]
For GLMs with bounded covariates and strongly convex, smooth log-partition function \(A\), nonasymptotic regret bounds imply corresponding controls on likelihood-ratio set size through Bregman divergences. An adaptive reweighting scheme is introduced to counteract large early bias, with
\[
w_t=\frac{1/L}{1/L+\mathrm{bias}_{x_t}^2(\hat\theta_t)},
\]
and a computable upper bound
\[
\mathrm{bias}_{x}^2(\hat\theta_t)\le 2\lambda^2\|x\|_{(V_t^{\mu;\lambda})^{-1}}^2.
\]
The intended effect is to downweight early, poorly learned directions while allowing \(w_t\to 1\) as estimation bias decreases [2311.04402].

A different online perspective appears in “Online non-parametric likelihood-ratio estimation by Pearson-divergence functional minimization.” There the observed stream consists of i.i.d. pairs \((x_t\sim p, x_t'\sim q)\), and the target is the relative density ratio
\[
r^\alpha(x)=\frac{q(x)}{(1-\alpha)p(x)+\alpha q(x)}, \qquad 0\le \alpha<1.
\]
For \(\alpha=0\), this is \(q(x)/p(x)\); to obtain \(p(x)/q(x)\), one swaps \(p\) and \(q\) or inverts the estimate when positivity permits. The method works in an RKHS and performs stochastic functional gradient descent on the Pearson-divergence objective using per-step loss
\[
\ell_t^{\rm PE}(f)=(1-\alpha)\frac{1}{2}f(x_t)^2+\alpha\frac{1}{2}f(x_t')^2-f(x_t')+\frac{\lambda_t}{2}\|f\|_H^2.
\]
The functional update is
\[
f_t(\cdot)
=
(1-\eta_t\lambda_t)f_{t-1}(\cdot)
-\eta_t\Big[(1-\alpha)f_{t-1}(x_t)K(x_t,\cdot)+(\alpha f_{t-1}(x_t')-1)K(x_t',\cdot)\Big],
\]
with schedules
\[
\eta_t=\frac{a}{(t_0+t)^{2/(2\beta+1)}},
\qquad
\lambda_t=\frac{1/a}{(t_0+t)^{1/(2\beta+1)}}.
\]
The dictionary grows by adding \(x_t\) and \(x_t'\) at every step, yielding \(O(t)\) per-iteration cost, \(O(t^2)\) cumulative kernel evaluations up to time \(t\), and \(O(t)\) memory. The paper provides high-probability convergence guarantees in both \(L^2(P^\alpha)\) and RKHS norm under bounded-kernel and smoothness assumptions [2311.01900].

These two online lines address different problems. The sequential-decision framework presumes a specified parametric likelihood and uses per-round LR contributions for coverage and control; the OLRE framework estimates density ratios non-parametrically from streaming samples. Their commonality lies in a genuinely per-event update: each new observation modifies the ratio estimator or ratio process through a single local contribution rather than batch recomputation.

## 6. High-dimensional spectral methods, applications, and caveats

High-dimensional per-event likelihood-ratio estimation is difficult when direct density estimation in the ambient space is poor. “High-Dimensional Density Ratio Estimation with Extensions to Approximate Likelihood Computation” addresses this by expanding the ratio in eigenfunctions of a kernel integral operator associated with the denominator distribution \(Q\). If \(w(x)=p(x)/q(x)\), the expansion is
\[
\beta(x)=\sum_{j=1}^{\infty}\beta_j\psi_j(x),
\qquad
\beta_j=E_F[\psi_j(X)],
\]
where \(\{\psi_j\}\) are orthonormal in \(L^2(X,G)\) for \(G\) with density \(q\). Truncating at \(J\) terms gives
\[
\widehat{\beta}(x)=\left(\sum_{j=1}^J \widehat{\beta}_j \widehat{\psi}_j(x)\right)_+,
\]
with \(\widehat{\psi}_j\) obtained by Nyström extension and \(\widehat{\beta}_j\) estimated by empirical averages over samples from \(P\). The underlying squared-loss objective is LSIF-like, and the method exploits approximate orthogonality so that coefficients reduce to expectations of basis functions under the numerator distribution [1404.7063].

This basis construction adapts to the geometry of the denominator data and is intended to remain effective when observations lie near lower-dimensional manifolds embedded in high ambient dimension. The paper also extends the idea from density ratios to approximate likelihood computation. Defining
\[
L(x;\theta)=\frac{f(x\mid \theta)}{g(x)},
\]
with \(g(x)\) often chosen as the marginal under a prior, it uses a tensor-product expansion over basis functions in \(x\) and \(\theta\):
\[
\widehat{L}(x;\theta)
=
\sum_{j=1}^J \sum_{i=1}^I \widehat{\gamma}_{ij}\widehat{\psi}_j(x)\widehat{\phi}_i(\theta).
\]
This produces per-event approximate likelihoods usable in downstream Bayesian or maximum-likelihood inference without explicit dimension reduction [1404.7063].

The application range of per-event likelihood-ratio estimators is correspondingly broad. In NLP, they can rank bigrams as predictors of named-entity left contexts [2211.00545]. In scientific inference, they provide optimal or near-optimal test statistics, event reweighting, and confidence-interval ingredients [2305.10500]. In likelihood-free physics-style workflows, they support MCMC, importance sampling, SMC, nested sampling, Hamiltonian Monte Carlo through \(\nabla_\theta \log \hat r(x,\theta)\), and nuisance-parameter marginalization [1903.04057]. In sequential learning, they generate anytime-valid confidence sequences for generalized linear bandits, survival analysis, additive-noise models, and RKHS bandits [2311.04402]. In forensics, they quantify evidential weight for rare haplotype matches, but the estimated LR depends strongly on the chosen population model and data reduction [1502.04083].

Several caveats recur across these literatures. First, ranking quality and numeric calibration are distinct: any monotone surrogate preserves rankings, but using a score as a numerical LR requires correct calibration and, in classifier-based methods, correct treatment of training priors [2305.10500]. Second, support overlap matters. If the numerator has support outside the denominator, the true ratio may be infinite or undefined; both simulation-based and non-parametric papers explicitly warn about this [1903.04057] [2311.01900]. Third, rare events are structurally difficult: naive empirical ratios often overestimate them, thresholding can be too discontinuous, and model misspecification may dominate the error budget [2211.00545] [1502.04083]. Fourth, different modeling choices may define different legitimate likelihood ratios rather than different estimates of a single uniquely meaningful quantity; the forensic literature makes this point explicitly, and it has a plausible implication for other domains whenever evidence reduction or denominator choice is non-unique [1502.04083].

A common practical pattern nevertheless emerges. One estimates a local ratio or log-ratio for each event, aggregates across events additively or multiplicatively, prunes or regularizes low-information regions, calibrates when numerical ratios are needed, and validates the estimator with task-appropriate diagnostics such as MAE, ROC/AUC-based checks, rank–recall, simulation-based calibration, posterior predictive checks, or time-uniform coverage. Within that pattern, the per-event likelihood-ratio estimator is less a single algorithm than a unifying statistical primitive that supports inference, decision-making, and evidence quantification across discrete, parametric, neural, amortized, online, and high-dimensional settings.

Source: https://www.emergentmind.com/topics/per-event-likelihood-ratio-estimator