For a given data distribution (Xt)t∈N∼i.i.d.Q, we investigate the hypothesis testing problem: H0:Q=P0 vs. H1:Q=P1, for two different model probability distributions P0 and P1. In contrast to the standard setting, where analytic densities p0 and p1 are given, here, we consider the density-free setting, where we only have access to simulations (Zt0)t∈N∼i.i.d.P0 and (Zt1)t∈N∼i.i.d.P1. For this simulation-based hypothesis testing setting, we construct an E-test martingale, resulting in a sequential test with anytime-valid type-I error guarantees, approximate growth optimality, geometrically decaying type-II error bounds, and asymptotic power one. Most ingredients used in our constructions are variants of well known concepts. The value of this paper lies in the compact presentation of an effective, anytime-valid solution for the density-free simulation-based sequential hypothesis testing case.
1 Introduction
Experimental particle physics generally focuses on distinguishing between competing hypotheses about the underlying processes responsible for the observed data. Often this is done in the form of testing an alternate hypothesis H1 versus the so called Standard Model (SM) of particle physics, which acts as the null hypothesis H0. At the Large Hadron Collider (LHC), this is done both for searches for new phenomena and in precision measurements of the Standard Model. The observed events are the result of a complex sequence of stochastic processes, particle interactions with the detector, and the reconstruction of measurable quantities. Statistical hypothesis testing then provides the framework through which theoretical predictions are tested based on actual experimental observations x=(xn)n∈[N] that originated from the underlying true physical distribution Q.
In particle physics, the alternative hypothesis H1 usually consists only of a single model P1 that arises as an extended version of the Standard Model P0. In such a setting, where one only has a simple null hypothesis H0:Q=P0 and a simple alternative H1:Q=P1, the standard way of testing H0 versus H1 is through the likelihood ratio:
Λ(x):=p0(x)p1(x),(1)
where p1 and p0 are the corresponding probability densities of H1 and H0, respectively. The reason for this lies in the Neyman-Pearson lemma, which states that, for the simple-vs-simple setting, a test based on a threshold applied to the likelihood ratio Λ(x) is the most powerful test at each fixed significance level α∈(0,1], see [NP33, FC98].
For example, in the LHC experiments such as ATLAS [ATL08] and CMS [CMS08], in the search for the Higgs boson, which was discovered in 2012, see [ATL12, CMS12], a likelihood ratio was used between the null-hypothesis H0 of “no Higgs boson present” and the alternate hypothesis H1 of the “existence of a Higgs boson” in the data. In collider analyses, related likelihood-ratio and profile-likelihood constructions form the basis of widely used procedures for hypothesis testing, parameter estimation, and the treatment of nuisance parameters, see [CCGV11, CER11].
However, in realistic LHC analyses, the probability densities p0 and p0 entering the likelihood ratio Λ are rarely available in analytic or closed form. The mapping from the underlying theory parameters to the reconstructed detector-level data involves multiple stages of particle production and detector response, making direct evaluation of the high-dimensional likelihood ratio computationally difficult or intractable, see [BC20]. Monte Carlo simulation therefore plays a central role in modern collider physics. Event generators model the underlying particle interactions and subsequent evolution of the event, while detailed detector simulations model the propagation of particles through the experimental apparatus and its response. The resulting simulated events provide samples from the distributions predicted by a given physical hypothesis and allow theoretical models to be compared with data at the level at which measurements are actually performed. In consequence, simulations are used not only for estimating signal and background distributions but also for modelling detector efficiencies and acceptance, validating analysis procedures, and evaluating systematic uncertainties. The connection between likelihood-ratio optimality and simulation is particularly relevant when the likelihood itself cannot be evaluated explicitly. If independent samples can be generated under competing hypotheses, the problem of distinguishing them can instead be formulated directly in terms of the simulated distributions.
With more modern methods, such as deep learning, a classifier can be trained to distinguish samples drawn from P0 and P1, under appropriate conditions and with sufficient capacity and training data, to learn an approximation Λ^ of the likelihood ratio Λ, which then can be used as a surrogate in the testing procedure and which allows to calculate p-values as a measure of significance.
However, the classical hypothesis testing approach based on p-values has further drawbacks, especially when the sample size needed for a targeted effect size is a priori unknown. The test is generally only valid for a chosen sample size fixed in advance: no “peeking”, no optional stopping or optional continuation is allowed. In addition, one can not easily aggregate evidence against the null hypothesis H0 from different experiments, or conduct multiple hypothesis tests at once, etc. As a remedy, the anytime-valid sequential testing procedure testing by betting was recently developed, see [SSVV11, VW21, GdHK20, WRB20, HZ21, RGVS23, RW25]. Also in this framework, the standard approaches require, in the simple-vs-simple setting, the likelihood ratio Λ, which we do not have in the density-free, simulation-based context.
In this paper, we want to address both points at once: 1.) the density-free/simulation-based hypothesis testing setting (without analytic densities p1, p0), and: 2.) building an anytime-valid sequential hypothesis testing procedure. Our construction will result in a sequential test, which comes with anytime-valid type-I error guarantees, approximate growth optimality, geometrically decaying type-II error bounds and asymptotic power one. We also show that the test statistics will implicitly approximate the likelihood ratio Λ.
2 Anytime-valid hypothesis testing with conditional e-variables
In this section, we start by giving an overview over the main results from the standard literature of anytime-valid hypothesis testing, see, for instance, [SSVV11, VW21, GdHK20, WRB20, HZ21, RGVS23, RW25], etc.
In the following, let Ω be a measurable space with σ-algebra B, which we consider the underlying sample space, on which all occurring random variables live. We will endow (Ω,B) with several different probability distributions: Q, the true distribution, P0 the standard model distribution, and P1 the alternative model distribution. Based on a (finite or infinite) sequence of data points (Xt)t∈N∼Q we want to test the hypothesis if the true distribution Q rather coincides with the standard model distribution P0 or with the alternative model distribution P1:
H0:Q=P0,vs.H1:Q=P1.(2)
The safe hypothesis testing framework is based on the following concepts:
Definition 2.1 (E-variables). A non-negative measurable map E:Ω→[0,∞] is called an E-variable for H0 if:
EP0[E]≤1.(3)
Note that the Markov inequality shows that every E-variable E for H0 induces a p-variable π:=min(1,1/E) for H0:
P0(π≤α)=P0(E≥α1)≤!α,∀α∈(0,1].(4)
In this sense, E-variables can be considered more restrictive, so called post-hoc, (inverses of) p-variables, see [Kon23, Grü24, RW25, CLRG26], and, they directly produce a decision rule for every confidence level α∈(0,1]: “Reject H0 if E≥α1”. The inequality above shows that the type-I error is then bounded by α. We remain to investigate the type-II error, the power, resp., for H1. However, in contrast to the classical concept of power β:=P1(π≤c) of a test, which depends on the chosen threshold c, in the safe hypothesis testing framework, one introduces the E-power instead, which quantifies on logarithmic scale how much evidence one can expect to gather against H0 under the alternative model P1.
Definition 2.2 (E-power). Let E:Ω→[0,∞] be an E-variable for H0. Then its E-power for H1 is given by:
EP1[logE].(5)
In the simple-vs-simple hypothesis test situation, which we are considering in this paper, we can even point out the most E-powerful E-variable:
Lemma 2.3 (Neyman-Pearson lemma for the optimal E-power). Under the assumption of absolute continuity: P1≪P0, the P0-essentially unique E-variable for H0 with maximal E-power for H1 is given by the likelihood-ratio, i.e. the Radon-Nikodym derivative:
E∗(x):=dP0dP1(x),(6)
which has the E-power:
EP1[logE∗]=!KL(P1∥P0),(7)
the Kullback-Leibler divergence between P1 and P0.
Since, in this paper, we are in the situation, where the ratio dP0dP1 is not given to us in an analytic form or as an algorithmic function, we cannot directly use it in practice as our E-variable. In the next section we thus aim to construct other E-variables for H0 with an E-power close to the maximal one of KL(P1∥P0) and which are only based on simulations from P0 and P1.
Before we go there, first note, that the concepts of E-variable E and its E-value E(x), in the presented form, are only restricted to either one realization x∼Q or an array of data points of fixed given length x=(x1,…,xt) with xi∼Q. To turn this into a flexible framework where the number of data points xt∼Q can grow over time t→∞ and where we can build on information from the past, we have to introduce the following concept:
Definition 2.4 (Conditional E-variables and conditional E-power). Let F⊆B be a sub- σ-algebra of B1 on Ω. A non-negative measurable map E:Ω→[0,∞] is called a conditional E-variable for H0 conditional on F if:
EP0[E∣F]≤1P0−a.s.(8)
Its conditional E-power for H1 conditional on F is defined by:
EP1[logE∣F].(9)
Note that a conditional E-variable for H0 conditional to F is also a (unconditional) E-variable for H0. More generally, we can consider a sequence of (Et)t∈N0 conditional E-variables for H0, each constructed by using past information. Formally, we introduce:
1A sub- σ-algebra F⊆B is typically of the form F=σ(Z1,…,Zt) for some random variables Z1,…,Zt:Ω→Z. So, F then encodes the information of the outcomes of Z1,…,Zt.
Notations 2.5. Let (Et)t∈N0 be a sequence of conditional E-variables for H0, Et:Ω→[0,∞], E0:=1, adapted to the filtration F=(Ft)t∈N0 of sub-σ-algebras Ft⊆B:
F0⊆F1⊆F2⊆⋯⊆Ft⊆⋯⊆B,(10)
each conditional on its own past, that is, for every t∈N1 the map Et:Ω→[0,∞] is Ft-measurable and:
EP0[Et∣Ft−1]≤1P0−a.s.(11)
We further construct non-negative variables Wt:Ω→[0,∞] as follows for t∈N1 by multiplication:
Wt:=Et⋅Wt−1=Et⋅Et−1⋯E1,W0:=1.(12)
With these notations we have the following:
Lemma 2.6. With the Notations 2.5, each Wt for t≥0 is an (unconditional) E-variable for H0 and the sequence (Wt)t∈N0 is a non-negative supermartingale adapted to the filtration F=(Ft)t∈N0 w.r.t. P0. More concretely, for t∈N1 we have:
EP0[Wt∣Ft−1]≤Wt−1P0−a.s.,EP0[W0]=1.(13)
The above sequence (Wt)t∈N0 now allows us to define a sequential decision rule with α∈(0,1] as follows:
“Reject H0 if there ever appears any t∈N0 with Wt>α1.”
Remarkably, this sequential decision rule has the following anytime-valid type-I error guarantee, provided by Ville's inequality for non-negative supermartingales, see [Vil39] or Theorem A.1:
Theorem 2.7 (Anytime-valid type-I error bounds). With the Notations 2.5, we have the following upper bound on the anytime-valid type-I error for the above sequential test for every α∈(0,1]:
Under boundedness conditions on the logarithms of the Et's and sufficiently big conditional E-power, we also get an asymptotic type-II error control with help of the Azuma–Hoeffding inequality for bounded, filtration adapted sequences of random variables, see [Azu67, For26b] or Theorem A.2:
Theorem 2.8 (Geometrically decaying type-II error bounds for log-bounded conditional E-variables). With the Notations 2.5, assume that for every t∈N1 there are constants at,bt,ct∈R such that:
In particular, if the bounds are the same (at=a,bt=b,ct=c) for all t∈N1 with positive (conditional) E-power lower bound c>0 for H1 then the type-II error bound simplifies and converges to zero with asymptotically geometric rate:
As a consequence, we then have asymptotic power one:
P1(t∈N0supWt>α1)=P1(t∈N0supWt=∞)=1.(18)
2For s∈R we put s+:=max(0,s) and s+2:=(s+)2.
Remark 2.9 (Clipping log-unbounded E-variables). If E is an E-variable for H0, but for which logE might not be bounded, then for every γ∈(0,1] we can introduce its γ-clipped version:
Eγ(x):=γ+(1−γ)⋅min(E(x),γ−1)≤1+E(x),(19)
which is again an E-variable for H0 and for which we then have the bounds:
−logγ1≤logEγ(x)≤logγ1,(20)
together with the pointwise convergence:
γ→0limEγ(x)=E(x),(21)
which is monotone non-decreasing if E(x)≥1 and monotone non-increasing if E(x)≤1 for γ→0. This then implies the following convergences of the integrals for arbitrary measures P:
γ→0lim∫EγdP=∫EdP,γ→0lim∫logEγdP=∫logEdP.(22)
The latter limit holds, whenever the integral on the right is well-defined (possibly ±∞, but excluding the ∞−∞ case). The convergence of the integrals can be shown with help of the monotone convergence theorem, applied on the sets {E≤1} and {E>1} separately.
This allows us to take an E-variable E for H0 with positive E-power EP1[logE]>0 for H1 (but with possible unbounded logE), and clip it with some small γ>0. If γ>0 is sufficiently small then also Eγ will have positive E-power EP1[logEγ]>0 for H1 and, in addition, the geometrically decaying type-II error bounds of Theorem 2.8 will hold with the bounds a:=−logγ1, b:=logγ1 and c:=EP1[logEγ]>0.
Remark 2.10 (Rejection time). With the Notations 2.5, we introduce the rejection time of the test supermartingale (Wt)t∈N w.r.t. α∈(0,1]:
τα:=inf{t∈N0Wt>α1}.(23)
To get an intuition about the average rejection time, assume, for simplicity, that (xt)t∈N∼P1 is i.i.d. and that we use the same E-variable at each time: Et=E(xt) for t∈N. Via Wald's equation, under integrability conditions 3, see [Wal44, Dur19], we then get the following close approximation for the average rejection time:
which can be interpreted as the average number of samples needed to obtain a rejection. The above formula shows that, if we want to minimize the average rejection time, we need to maximize the E-power of E, which by Lemma 2.3 is uniquely maximized by the likelihood ratio: E∗=dP0dP1, for which we then get the minimal average rejection time:
EP1[τα∗]≳KL(P1∥P0)logα1.(25)
3 Construction of e-variables in the density-free, simulation-based setting
In this section, we now want to construct E-powerful E-variables E for a sequential i.i.d. hypothesis testing problem:
H0:Q=P0,vs.H1:Q=P1,(26)
3The minimal assumptions for the validity of Wald’s equation are: EP1[(logE)−]<∞ and EP1[logE]>0.
where we do not have access to the densities of P0 or P1, or even just the likelihood ratio dP0dP1. Instead, we aim to construct E-variables that are constructed only from i.i.d. samples (zt0)t∈N∼P0 and (zt1)t∈N∼P1, but are close to the optimal E-variable: E∗:=dP0dP1.
To construct E-variables, consider an arbitrary function: h:Ω→[0,∞] with 0<EP0[h]<∞. Then a simple normalization turns h into a valid E-variable for H0:
h~(z):=EP0[h]h(z),EP0[h~]=1.(27)
The problem is that we usually cannot analytically solve the integral: EP0[h]=∫hdP0. If we instead approximate this integral with i.i.d. samples from z10,…,zK0∼P0, we get:
A commonly known trick in statistics and machine learning is to turn such a quantity into a classification probability (or variants thereof), see [Qin98, BBS09, SNK +08, SKS +09, NWJ10, KSS10, GH10, SSK12, GPAM +14, CPL15, CPLB16, LC18, BCLP18, OLV18, HFLM +19, POvdO +19, HBL20, DMP20, CKNH20, WRB20, KRSW21, FDF +20, FTF21, FRF23, FFTV24, MCF +21, MWF22, MFWF23, DHR +22, DMF +23, PBNF24, PFRS24, LMAF26, DER26], where it is known that a maximizer of the underlying classification task is proportional to the (log) density ratio dP0dP1. More concretely, we simply add the nominator h(z) to (the average of) the denominator above and introduce the quantity:
If H0:Q=P0 is true, then z1∼P0 together with z10,…,zK0∼P0 i.i.d. of the same distribution P0. This joint i.i.d. assumption then implies the same distributions for each of the ratios:
Multiplying by (K+1) then shows that E(K,h) is a valid E-variable for H0. Formally, note, that we implicitly endowed all probability distributions with the K-fold independent product of P0 in the expectation value. So, we actually investigated the equivalent hypothesis testing problem:
We now want to investigate, which choice of h actually does optimize E-power for H1. For this we have the following theoretical result:
Proposition 3.2 (Optimal E-power for fixed K≥1, see Proof B.1). Let P0, P1 be two probability distributions on Ω with P1≪P0 and K≥1 be a fixed natural number. Then consider all measurable functions h:Ω→[0,∞) for which 0<h(Z1)+∑k=1Kh(Zk0)<∞P1-almost-surely, and, the following E-power objective:
JK(h):=EP1[logE(K,h)].(38)
Then each maximizer h∗ of JK is P0-almost-surely of the form:
h∗(z)=c⋅dP0dP1(z),(39)
for some constant c∈R>0. Conversely, those functions maximize JK (for all K≥1 simultaneously). The optimal E-variable of our given type is thus given by:
which (for each fixed z1) converges P0⊗N1-almost-surely to the overall most E-powerful E-variable E∗(z1)=dP0dP1(z1) for H0 vs. H1, see Lemma 2.3, for K→∞. Furthermore, for the E-power of E(K,∗) we have the following Jensen inequality:
We now focus on a way to learn to approximate such optimal E-variables with simulations from P1 and P0.
Notations 3.3. To approximate the most E-powerful E-variable for H0 vs. H1, we make use of a flexible, optimizable parameterized function class gθ:Ω→R, for example, deep neural networks of some architecture, with parameters θ∈Θ. We then put hθ(z):=exp(gθ(z)) to use inside E(K,h) and get the parameterized E-variables for H0:
We will optimize the E-power of E(K,θ) by using an empirical estimate of the E-power objective JK from above, using i.i.d. samples from P0 and P1. For this first sample sufficiently many:
We then maximize this objective to receive the following estimator:
θ^K,N:∈argmaxθ∈ΘJK,N(θ),(46)
or, more generally, a sequence of near-maximizing estimators (θ^K,N)N∈N1 that might come with some optimization gap (ξ^K,N)N∈N1, e.g. a gradient optimizer stuck in a local, non-global, maximum, etc., satisfying:
We can use M-estimation theory under standard Wald-type conditions, see [Wal49, vdV98], to get the following results on the asymptotic approximately optimal E-power of the E-variable E(K,θ^K,N) for H0 vs. H1 for the limit N→∞.
Theorem 3.4 (Approximate growth optimality, see Proof B.2). Let the setting be like in Notations 3.3. Assume P1≪P0 and let gθ:Ω→R be a family of B-measurable functions, θ∈Θ, with the following properties:
Compactness: Θ is a compact metric space.
Continuity: for every z∈Ω the map θ↦gθ(z) is continuous.
Non-degeneracy: there exists a θ∈Θ with JK(θ)>−∞.
Then, for fixed K≥1, we have the following uniform strong law of large numbers for the objective, that is the P1-almost-sure convergence:
θ∈Θsup∣JK,N(θ)−JK(θ)∣⟶N→∞0P1-a.s.(50)
Furthermore, for every near-maximizing sequence (θ^K,N)N∈N1 of (JK,N)N∈N1 with optimization gaps (ξK,N)N∈N1 we have the P1-almost-sure convergences 4:
4Note that the expectation value EP1 integrates over the variables (z1,z10,…,zK0) of E(K,θ^K,N), but leaves the randomness from the fitting procedure in θ^K,N intact. The “ P1-a.s.” statement is then about the randomness in θ^K,N.
Now consider the maximizers gc∗:Ω→R∪{−∞} of JK from Proposition 3.2 (in log space) for c∈R:
gc∗(z):=g∗(z)+c,g∗(z):=logdP0dP1(z).(52)
We now assume, in addition to the above, that we have the following properties:
Approximating class: there exist θ∈Θ and ϵ,c∈R with 0≤ϵ<∞ such that:
z∈Ωsup∣gθ(z)−gc∗(z)∣≤ϵ.(53)
Finite χ2-divergence: we have: P1≪P0 with χ2(P1∥P0)<∞.
Then we have approximate growth optimality (AGRO) expressed as the following P1-almost-sure inequalities:
maximal E-powerKL(P1∥P0)≥asymptotic learned E-powerN→∞liminfEP1[logE(K,θ^K,N)](54)≥maximal E-powerKL(P1∥P0)penalty for finite K−log(1+K+1χ2(P1∥P0))approximation gap−21ϵ2optimization gap−ξK.(55)
In particular, if KL(P1∥P0)>21ϵ2+supK∈N1ξK, then we can find K,N≥1 such that we achieve positive E-power EP1[logE(K,θ^K,N)]>0 for H1 with high probability.
After training, we have thus found the E-variable E(K,θ^K,N) for H0 with optimized E-power for H1 or at least with positive E-power EP1[logE(K,θ^K,N)]>0 for H1 with high probability.
For newly sampled points at each time step t≥1:
xt∼Q,(zt,k0)k∈[K]∼i.i.d.P0,(56)
we can thus finally define the (conditional) E-variable at time t≥1:
Et:=E(K,θ^K,N)(xt,zt,10,…,zt,K0),(57)
and recursively the e-test martingale for t≥1:
Wt:=Et⋅Wt−1,W0:=1.(58)
We thus reject H0 in favor of H1 whenever Wt crosses the threshold α1 and we can stop. Recall, that in real physical experiments, the standard is to use the so called 5σ-rule with α1≈3.5⋅106, that is: logα1≈15.
Remark 3.5 (Deep neural networks, see [GBC16, Bis23, Mur22]). For deep neural networks gθ the map:
(θ,z)↦gθ(z),(59)
is continuous and one usually even has a Lipschitz type inequality, based on the used architecture:
∣gθ(z)∣≤C(θ)⋅(1+∥z∥),(60)
with a constant C(θ) that is continuous in θ. Furthermore, the class of deep neural networks is a universal approximator. So, on compact Ω, we can adjust the architecture and the parameterization such that:
gθ≈gc∗,(61)
for some θ from some sufficiently big, but compact Θ. So, the remaining envelope properties from Theorem 3.4 reduce for deep neural networks to simple moment conditions:
EP1[∥Z1∥]<∞,EP0[∥Z0∥]<∞.(62)
So, for deep neural networks, in practice, we can argue that Theorem 3.4 should hold on compact Ω. For non-compact, but σ-compact, Ω one can exhaust the space Ω with compacta and apply Theorem 3.4 individually on each compact subspace. We do not provide further technical details for this generalization here.
Remark 3.6 (Removing the ambiguity of a constant). In practice, we can remove the ambiguity of the constant c∈R in the optimal function in Proposition 3.2 and Theorem 3.4 by introducing the following regularizer:
With the above methods, we can remove the additive constant c and achieve that: gθ^K,N≈logdP0dP1. Note that the constant, anyways, does not affect the E-variable E(K,θ) of our form Equation (43), and only helps to interpret gθ^K,N as a log-likelihood ratio.
Remark 3.7 (Clipping - again). In order to prevent a learned E-variable E(K,θ^K,N), which might by chance become close to zero (log-unbounded from below), to quickly destroy the wealth process Wt, we could introduce a regularizing clipping parameter λ∈[0,1], as described in Remark 2.9:
This would, as mentioned in Remark 2.9, restore the explicit type-II error bounds from Theorem 2.8. However, there are different ways to choose λ, as we will indicate in the following.
a.) A typical, simple and effective choice for λ would be to just set λ1:=21.
b.) Based on the observation, that we already have the deterministic upper bound:
logE(K,θ)≤log(K+1),(68)
a symmetric lower bound could be achieved by the choice λK:=K+1K. Then we would just get:
Since λ might, in this fitting procedure, still become too overconfident ( λ^K,N≈1), we could afterwards scale it down by a fixed hyperparameter ρ∈[0,1), e.g. again ρ1=21, ρ2=32, ρ3=43, ρ4=54 or ρK=K+1K, and put:
λ~K,N:=ρ⋅λ^K,N,(72)
and use the E-variable
E(K,ρ,N):=E(K,θ^K,N,λ~K,N),(73)
which then always produces the deterministic bounds:
log(1−ρ)≤logE(K,ρ,N)≤log(K+1).(74)
d.) There are further options, like providing a whole schedule (λt)t∈N0 over time, or even learning such a schedule (but only on past data). All these choices would not violate the conditional E-variable conditions and all guarantees from Theorem 2.7 and Theorem 2.8 would still hold with the corresponding numbers.
Remark 3.8 (The choice of the number K). There are two considerations for the choice of the number K≥1 that restrict the power of E(K,θ).
a.) The first obstruction is the deterministic upper bound:
E(K,θ)≤K+1,(75)
which restricts the E-power to:
EP1[logE(K,θ)]≤log(K+1).(76)
If we even want to have a chance to be approximately close to the upper limit of KL(P1∥P0) then at least the upper bound should be close to or even exceed it:
log(K+1)≳KL(P1∥P0),(77)
leading to the following condition for the choice of K:
As before, also this quantity could be checked and adjusted during training.
Remark 3.9 (Alternative training objective). Another popular and rather stable training objective in machine learning for learning density ratios comes from another variational form of the KL-divergence, see [NWJ10, BBR +18, POvdO +19]:
The estimator is known to have less bias, but higher variance. After training, one can use gθ^N1,N0 in our E-variable from Equation (43) with some chosen K≥1.
The above concepts and constructions can also be combined with the following.
Remark 3.10 (Finite time horizon and inverse temperature). Recall that in Section 3 we used the construction from Equation (30) to approximate the E-variable from Equation (27):
where we then optimized h in Theorem 3.4 to receive: h=exp(gθ^K,N) with gθ^K,N≈logdP0dP1, which is approximately growth optimal in the long run and minimizes average rejection time, see Remark 2.10. In contrast, following [For26a], we now want to consider the case where the time horizon T∈N for the real experiments (xt)t∈[T]∼i.i.d.Q is a priori known and finite. For this we want to fix h from above, but we now modify it with an inverse temperature regularization parameter β∈R>0:
Note that only the rhs depends on β, so minimizing that type-II error reduces to minimizing the rhs w.r.t. β, which we only need for the case when we have not rejected H1 yet, that is, if Wt−1≤α1. We thus arrive at the exact objective:
(90) where we interpret ℓt−1 as the residual target evidence for rejecting H1 per remaining time step until time T. The optimization problem can then numerically be solved with Newton iteration:
where each expectation value is replaced by the empirical counterparts based on the same one batch of i.i.d. samples (zm0)m∈[M]∼i.i.d.P0 and with h=exp(gθ^K,N). After convergence, i→∞, practically after 3 - 5 rounds of iterations, one has found an approximate βt−1:=β(∞), which one can use, at time t∈[T], for the conditional E-variable:
At the next time step t+1, this can be repeated, leading to an adaptive predictive sequence (βt)t∈[T] of inverse temperatures. This, of course, can be combined with the clipping regularization from Remark 3.7. Note that, even with these β values in place, each of which is only dependent on their own past, the anytime type-I error guarantees from Theorem 2.7 still hold.
4 An alternative testing scenario
Consider the scenario, where we want to test:
H0:Q=P0,vs.H1:Q=P0,(94)
For this we pre-train E(K,θ) as before with help of some alternative P1=P0 first, if possible. However, to adjust to the real data distribution coming from Q, which we suspect to deviate from P0, we will then train E(K,θ) on all past observations xn∼Q with n=1,…,t−1, explicitly excluding xt (and future xn) for training at time t, and sufficiently many simulations from P0 as before (and/or stored simulations from the past). More concretely, at each time t≥1, we optimize the empirical objective with data from times until t−1:
This will still be a valid conditional E-variable for H0 and the anytime type-I error guarantees will still hold. Note that the trained E-variable E(K,θ) will then rather learn to approximate dP0dQ than dP0dP1, which, in this testing scenario, is more optimal, if H1 is true.
5 Discussion
For the simulation-based hypothesis testing setting, H0:Q=P0 vs. H1:Q=P1, where we do not have densities and can only sample from P0 and P1, we constructed a sequential test based on an E-test martingale, which comes with anytime-valid type-I error guarantees, approximate growth optimality, geometrically decaying type-II error bounds, and asymptotic power one.
Future work could address further generalizations for the anytime-valid simulation-based hypothesis testing setting, where we have, instead of simple, composite hypothesis classes H0,H1⊆P(Ω), leading to the statistical test H0:Q∈H0 vs. H1:Q∈H1, and/or the setting of (filtration-adapted) dependent data streams (Xt)t∈N1∼Q, instead of i.i.d. data. Furthermore, a more realistic approximate growth optimality theorem could be proven for more realistic norms, non-compact Ω and Θ, and (universally approximating) function classes of more practical relevance.
References
[ATL08] ATLAS Collaboration. The ATLAS Experiment at the CERN Large Hadron Collider. JINST, 3:S08003, 2008. Also published by CERN Geneva in 2010.
[ATL12] ATLAS Collaboration. Observation of a new particle in the search for the standard model higgs boson with the atlas detector at the lhc. Physics Letters B, 716:1–29, 2012.
[Azu67] Kazuoki Azuma. Weighted sums of certain dependent random variables. Tohoku Mathematical Journal, 19(3):357–367, 1967.
[BBR +18] Mohamed Ishmael Belghazi, Aristide Baratin, Sai Rajeshwar, et al. Mutual Information Neural Estimation. In International Conference on Machine Learning, pages 531–540. PMLR, 2018.
[BBS09] Steffen Bickel, Michael Brückner, and Tobias Scheffer. Discriminative Learning under Covariate Shift. Journal of Machine Learning Research, 10:2137–2155, 2009.
[BC20] Johann Brehmer and Kyle Cranmer. Simulation-based inference methods for particle physics, 2020.
[BCLP18] Johann Brehmer, Kyle Cranmer, Gilles Louppe, and Juan Pavez. Likelihood-Free Inference with Neural Networks. Physical Review D, 98(5):052004, 2018.
[Bis23] Christopher M. Bishop. Deep Learning: Foundations and Concepts. Springer, 2023.
[CCGV11] Glen Cowan, Kyle Cranmer, Eilam Gross, and Ofer Vitells. Asymptotic formulae for likelihood-based tests of new physics. The European Physical Journal C, 71(2), February 2011.
[CER11] CERN. Proceedings of the PHYSTAT 2011 Workshop on Statistical Issues Related to Discovery Claims in Search Experiments and Unfolding, Geneva, 2011. CERN.
[CKNH20] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A Simple Framework for Contrastive Learning of Visual Representations. In International Conference on Machine Learning, pages 1597–1607. PMLR, 2020.
[CLRG26] Ben Chugg, Tyron Lardy, Aaditya Ramdas, and Peter Grünwald. On Admissibility in Post-hoc Hypothesis Testing. International Journal of Approximate Reasoning, 191:109634:1–109634:33, 2026.
[CMS08] CMS Collaboration. The CMS experiment at the CERN LHC. JINST, 3:S08004, 2008. Also published by CERN Geneva in 2010.
[CMS12] CMS Collaboration. Observation of a new boson at a mass of 125 GeV with the cms experiment at the lhc. Physics Letters B, 716:30–61, 2012.
[CPL15] Kyle Cranmer, Juan Pavez, and Gilles Louppe. Approximating Likelihood Ratios with Classifiers. arXiv preprint arXiv:1506.02169, 2015.
[CPLB16] Kyle Cranmer, Juan Pavez, Gilles Louppe, and William K. Brooks. Experiments Using Machine Learning to Approximate Likelihood Ratios for Mixture Models. In Journal of Physics: Conference Series, volume 762, page 012034. IOP Publishing, 2016.
[DER26] Alexander Dombowsky, Barbara E. Engelhardt, and Aaditya Ramdas. Besag-Clifford E-Values for Unnormalized Testing. arXiv preprint arXiv:2603.15845, 2026.
[DHR +22] Arnaud Delaunoy, Joeri Hermans, François Rozet, Antoine Wehenkel, and Gilles Louppe. Towards Reliable Simulation-Based Inference with Balanced Neural Ratio Estimation. In Advances in Neural Information Processing Systems, volume 35, 2022.
[DMF +23] Arnaud Delaunoy, Benjamin Kurt Miller, Patrick Forré, Christoph Weniger, and Gilles Louppe. Balancing Simulation-based Inference for Conservative Posteriors. In Proceedings of the 5th Symposium on Advances in Approximate Bayesian Inference (AABI), Honolulu, Hawaii, USA, July 2023.
[DMP20] Conor Durkan, Iain Murray, and George Papamakarios. Contrastive Learning for Neural Posterior Estimation. In International Conference on Learning Representations, 2020.
[Dur19] Richard Durrett. Probability: Theory and Examples. Cambridge University Press, 5 edition, 2019.
[FC98] Gary J. Feldman and Robert D. Cousins. A Unified approach to the classical statistical analysis of small signals. Phys. Rev. D, 57:3873–3889, 1998.
[FDF +20] Marco Federici, Anjan Dutta, Patrick Forré, Nate Kushman, and Zeynep Akata. Learning Robust Representations via Multi-View Information Bottleneck. In International Conference on Learning Representations, 2020.
[FFTV24] Marco Federici, Patrick Forré, Ryota Tomioka, and Bastiaan S. Veeling. Latent Representation and Simulation of Markov Processes via Time-Lagged Information Bottleneck. In International Conference on Learning Representations, 2024.
[For26a] Patrick Forré. The Type-II Error of Test Supermartingales: e-Power versus the Chernoff-Stein Exponent. arXiv preprint arXiv:2609.27765, 2026.
[For26b] Patrick Forré. Type-II Error Bounds of Test Supermartingales from Lower-Tail Hypothesis. arXiv preprint arXiv:2609.27766, 2026.
[FRF23] Marco Federici, David Ruhe, and Patrick Forré. On the Effectiveness of Hybrid Mutual Information Estimation. arXiv preprint arXiv:2306.00608, 2023.
[FTF21] Marco Federici, Ryota Tomioka, and Patrick Forré. An Information-theoretic Approach to Distribution Shifts. In Advances in Neural Information Processing Systems, 2021.
[GBC16] Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016.
[GdHK20] Peter Grünwald, Rianne de Heide, and Wouter M. Koolen. Safe Testing. Journal of the Royal Statistical Society: Series B, 82(3):543–564, 2020.
[GH10] Michael U. Gutmann and Aapo Hyvärinen. Noise-Contrastive Estimation: A New Estimation Principle for Unnormalized Statistical Models. In Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, pages 297–304. PMLR, 2010.
[GPAM +14] Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative Adversarial Nets. In Advances in Neural Information Processing Systems, volume 27, pages 2672–2680. Curran Associates, Inc., 2014.
[Grü24] Peter Grünwald. Beyond Neyman–Pearson: E-values Enable Hypothesis Testing with a Data-Driven Alpha. Proceedings of the National Academy of Sciences, 121(39):e2302098121, 2024.
[HBL20] Joeri Hermans, Volodimir Begy, and Gilles Louppe. Likelihood-free MCMC with Amortized Approximate Ratio Estimation. In International Conference on Machine Learning, pages 4239–4248. PMLR, 2020.
[HFLM +19] R. Devon Hjelm, Alex Fedorov, Samuel Lavoie-Marchildon, Karan Grewal, Philip Bachman, Adam Trischler, and Yoshua Bengio. Learning Deep Representations by Mutual Information Estimation and Maximization. In International Conference on Learning Representations, 2019.
[HZ21] Alexander Henzi and Johanna F. Ziegel. Valid Post-Selection Inference with E-Values. Electronic Journal of Statistics, 2021.
[Kon23] Nick W. Koning. Post-hoc α Hypothesis Testing and the Post-hoc p-value. arXiv preprint arXiv:2312.08040, 2023.
[KRSW21] Ilmun Kim, Aaditya Ramdas, Aarti Singh, and Larry Wasserman. Classification Accuracy as a Proxy for Two-Sample Testing. The Annals of Statistics, 49(1):411–434, 2021.
[KSS10] Takafumi Kanamori, Taiji Suzuki, and Masashi Sugiyama. Theoretical Analysis of Density Ratio Estimation. IEICE Transactions on Fundamentals, 93(4):787–798, 2010.
[LC18] Alix Lhéritier and Frédéric Cazals. A sequential non-parametric multivariate two-sample test. IEEE Transactions on Information Theory, 64(5):3361–3370, 2018.
[LMAF26] Maximilian Lipp, Benjamin Kurt Miller, Lyubov Amitonova, and Patrick Forré. Generalizing Coverage Plots for Simulation-based Inference. Transactions on Machine Learning Research, 2026.
[MCF +21] Benjamin Kurt Miller, Alex Cole, Patrick Forré, Gilles Louppe, and Christoph Weniger. Truncated Marginal Neural Ratio Estimation. In Advances in Neural Information Processing Systems, volume 34, pages 17707–17726, 2021.
[MFWF23] Benjamin Kurt Miller, Marco Federici, Christoph Weniger, and Patrick Forré. Simulation-based Inference with the Generalized Kullback-Leibler Divergence. In ICML 2023 Workshop on Synergy of Scientific and Machine Learning Modeling (SynS & ML), 2023.
[Mur22] Kevin P. Murphy. Probabilistic Machine Learning: An Introduction. MIT Press, 2022.
[MWF22] Benjamin Kurt Miller, Christoph Weniger, and Patrick Forré. Contrastive Neural Ratio Estimation (for Simulation-based Inference). In Advances in Neural Information Processing Systems, volume 35, pages 4643–4658, 2022.
[NP33] Jerzy Neyman and Egon Sharpe Pearson. IX. on the problem of the most efficient tests of statistical hypotheses. Philosophical Transactions of the Royal Society of London, Series A: Containing Papers of a Mathematical or Physical Character, 231(694-706):289–337, 02 1933.
[NWJ10] XuanLong Nguyen, Martin J. Wainwright, and Michael I. Jordan. Estimating Divergence Functionals and the Likelihood Ratio by Convex Risk Minimization. IEEE Transactions on Information Theory, 56(11):5847–5861, 2010.
[OLV18] Aäron van den Oord, Yazhe Li, and Oriol Vinyals. Representation Learning with Contrastive Predictive Coding. In arXiv preprint arXiv:1807.03748, 2018.
[PBNF24] Teodora Pandeva, Tim Bakker, Christian A. Naesseth, and Patrick Forré. E-Valuating Classifier Two-Sample Tests. Transactions on Machine Learning Research, 2024.
[PFRS24] Teodora Pandeva, Patrick Forré, Aaditya Ramdas, and Shubhanshu Shekhar. Deep Anytime-Valid Hypothesis Testing. In Proceedings of the 27th International Conference on Artificial Intelligence and Statistics, volume 238 of Proceedings of Machine Learning Research, pages 622–630. PMLR, 2024.
[POvdO +19] Ben Poole, Sherjil Ozair, Aaron van den Oord, Alexander A. Alemi, and George Tucker. On Variational Bounds of Mutual Information. International Conference on Machine Learning, pages 5171–5180, 2019.
[Qin98] Jing Qin. Inferences for Case-Control and Semiparametric Two-Sample Density Ratio Models. Biometrika, 85(3):619–630, 1998.
[RGVS23] Aaditya Ramdas, Peter Grünwald, Vladimir Vovk, and Glenn Shafer. Game-Theoretic Statistics and Safe Anytime-Valid Inference. Statistical Science, 38(4):576–601, 2023.
[RW25] Aaditya Ramdas and Ruodu Wang. Hypothesis Testing with E-Values. Foundations and Trends in Statistics, 1(1–2):1–390, 2025.
[SKS +09] Masashi Sugiyama, Takafumi Kanamori, Taiji Suzuki, Shohei Hido, Jun Sese, Ichiro Takeuchi, and Liwei Wang. A Density-ratio Framework for Statistical Data Processing. IPSJ Transactions on Computer Vision and Applications, 1:183–208, 2009.
[SNK +08] Masashi Sugiyama, Shinichi Nakajima, Hisashi Kashima, Paul von Bünau, and Motoaki Kawanabe. Direct Importance Estimation with Model Selection and Its Application to Covariate Shift Adaptation. In Advances in Neural Information Processing Systems, 2008.
[SSK12] Masashi Sugiyama, Taiji Suzuki, and Takafumi Kanamori. Density Ratio Estimation in Machine Learning. Cambridge University Press, 2012.
[SSVV11] Glenn Shafer, Alexander Shen, Nikolai Vereshchagin, and Vladimir Vovk. Testing by Betting: A Strategy for Statistical and Scientific Communication. Journal of the Royal Statistical Society: Series A, 174(1):193–227, 2011.
[vdV98] Aad W. van der Vaart. Asymptotic Statistics, volume 3 of Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press, Cambridge, 1998.
[Vil39] Jean Ville. Étude Critique de la Notion de Collectif. Bull. Amer. Math. Soc, 45(11):824, 1939.
[VW21] Vladimir Vovk and Ruodu Wang. E-values: Calibration, Combination, and Applications. The Annals of Statistics, 49(3):1736–1754, 2021.
[Wal44] Abraham Wald. On Cumulative Sums of Random Variables. The Annals of Mathematical Statistics, 15(3):283–296, September 1944.
[Wal49] Abraham Wald. Note on the Consistency of the Maximum Likelihood Estimate. The Annals of Mathematical Statistics, 20(4):595–601, 1949.
[WRB20] Larry Wasserman, Aaditya Ramdas, and Sivaraman Balakrishnan. Universal Inference. Proceedings of the National Academy of Sciences, 117(29):16880–16890, 2020.
Appendix
A Theorems
Theorem A.1 (Ville's inequality, see [Vil39]). Let (Wt)t∈N0 be a non-negative supermartingale, Wt:(Ω,B,P0)→[0,∞],t∈N0, adapted to the filtration F=(Ft)t∈N0, Ft⊆B and w.r.t. probability measure P0. Then for every α∈(0,1] we have the inequality:
P0(∃t∈N0.Wt>α1)≤α⋅EP0[W0].(97)
Theorem A.2 (Azuma–Hoeffding inequality, see [Azu67]). Let (Lt)t∈N0 be sequence of random variables Lt:(Ω,B,P1)→R,t∈N0,L0:=0, adapted to the filtration F=(Ft)t∈N0, Ft⊆B and w.r.t. probability measure P1. Further assume that for every t∈N1 there are constants at,bt,ct∈R such that:
If, in particular, bt−at≤d>0 and ct≥c for all t∈N1 then we get:
P1(n=1∑tLn≤ℓ)≤exp(−2t⋅d2(c−t1ℓ)+2).(100)
B Proofs
Proof B.1 (Proposition 3.2). In the following we abbreviate X:=ΩK+1 and x=(z1,z10,…,zK0)∈X. We abbreviate: Y:={0,1,…,K} and the uniform distribution on Y:
P(Y=k):=K+11.(101)
For k∈Y we then abbreviate the probability distribution on X with random variable X=(X0,…,XK):
Since KL is a proper divergence, the rhs is minimized if and only if it equals zero if and only if:
P(Y∣X)=Q(K,h)(Y∣X)P(X)−a.s.(109)
Since we assumed P1≪P0, we also have P(X∣Y=k)≪P0⊗(K+1) and P(X)≪P0⊗(K+1). So we can express the lhs via Bayes's theorem in terms of densities p(x∣k) and p(x):
which implies that for some c>0, P0-almost-all z∈Ω:
h(z)=c⋅dP0dP1(z).(114)
Note that Equation (114) also directly implies Equation (111). This then shows that such an h maximizes the E-power EP1[logE(K,h)]. This shows the equivalence.
Proof B.2 (Theorem 3.4). 1.) In the following we abbreviate X:=ΩK+1 and x=(z1,z10,…,zK0)∈X. First note that we have for every x∈X the uniform bound:
where the latter holds by assumption 4 about the integrable envelopes. Together we get the finite integrable envelope bound:
EP1[θ∈Θsup∣ℓθ(X)∣]<∞.(123)
2.) Also note that by assumption 2, ℓθ(x) is continuous in θ for every fixed x∈X. By the integrability condition from Equation (123) we can use the dominated convergence theorem to show that also:
JK(θ)=EP1[ℓθ(X)](124)
is continuous in θ∈Θ. Since Ω is compact by assumption 1 we even get that JK is uniformly continuous.
3.) We now want to prove the uniform law of large numbers:
Note that Dη(x) in monotone non-decreasing in η for each fixed x∈X with:
η→0limDη(x)=0,(129)
due to the uniform continuity of ℓθ(x) in θ, combining the assumptions of continuity 2 and compactness 1. Further note that we have the bound:
0≤Dη(x)≤2⋅θ∈Θsup∣ℓθ(x)∣,
(130) where the upper bound is integrable by Equation (123). The dominated convergence theorem thus implies:
η→0limEP1[Dη(X)]=0.(131)
So, we can choose η>0 small enough and with η1>η>0 such that:
EP1[Dη(X)]<ϵ/4.(132)
By the strong law of large numbers we have the P1-almost-sure convergence:
N1n=1∑NDη(Xn)⟶N→∞EP1[Dη(X)]<ϵ/4.(133)
So, for P1-almost-all realizations ω∈Ω there exists an N0(ω)∈N such that for all N≥N0(ω) we have:
N1n=1∑NDη(Xn(ω))<ϵ/2.(134)
c.) By assumption 1 the space Ω is a compact metric space with some metric d. So, there are finitely many θ1,…,θM∈Ω with:
Ω⊆m∈[M]⋃B(θm,η),(135)
where η>0 was fixed in the previous points and B(θm,η) is the (closed) ball of radius η around θm. So, for every θ∈Ω we can pick an index j(θ)∈[M] such that:
d(θ,θj(θ))≤η,(136)
which then implies:
∣JK(θ)−JK(θj(θ))∣<ϵ/4.(137)
d.) Now consider θ∈Ω and m=j(θ)∈[M]. Then we have: