SlowGuess/NeurIPS_2023_OCR huggingface dataset:
and hence, the betting fractions interpolate between the regimes of not betting and betting using a likelihood ratio. From this standpoint, 2STs of Lheritier and Cazals [2018, 2019], Pandeva et al. [2022] set  $\lambda_{t} = 1, \forall t$ , and use only the second term for updating the wealth despite the fact that the true likelihood ratio is unknown. An argument about the consistency of such test hence requires imposing strong assumptions about a sequence of predictors  $(g_{t})_{t \geq 1}$  [Lheritier and Cazals, 2018, 2019]. Our test differs in a critical way: we use a sequence of betting fractions,  $(\lambda_{t})_{t \geq 1}$ , which adapts to the quality of the underlying predictors, yielding a consistent test under much weaker assumptions.
${}^{3}$  Standard CLT does not apply directly when the conditioning set grows; see [Kim and Ramdas, 2020].
Example 1. Consider  $P = \mathcal{N}(0,1)$  and  $Q = \mathcal{N}(\delta,1)$  for 20 values of  $\delta$ , equally spaced in  $[0,0.5]$ . For a given  $\delta$ , the Bayes-optimal predictor is
$$
g ^ {\text {B a y e s}} (z) = \frac {\varphi (z ; 0 , 1) - \varphi (z ; \delta , 1)}{\varphi (z ; 0 , 1) + \varphi (z ; \delta , 1)} \in [ - 1, 1 ], \tag {21}
$$
where  $\varphi (z;\mu ,\sigma^2)$  denotes the density of  $\mathcal{N}(\mu ,\sigma^2)$  evaluated at  $z$ . In Figure 1a, we compare tests that use (a) the Bayes-optimal predictor, (b) a predictor constructed with the plug-in estimates of the means and variances. While in the former case betting using a likelihood ratio  $(\lambda_{t} = 1,\forall t)$  is indeed optimal, our test with an adaptive sequence  $(\lambda_{t})_{t\geq 1}$  is superior when a predictor is learned. The difference becomes even more drastic in Figure 1b where a (regularized)  $k$  NN predictor is used.
(a) Parametric model.
(b) Nonparametric model  $(k$ -NN).
Figure 1: Comparison between our 2ST with adaptive betting fractions and the likelihood ratio test for Example 1. While the likelihood ratio test is better if the Bayes-optimal predictor is used, our test is superior if a predictor is learned. The results are aggregated over 500 runs for each value of  $\delta$ .
Sequential Classification-based 2ST (Seq-C-2ST). Let  $\mathcal{A}_{\mathrm{c}}:(\cup_{t\geq 1}(\mathcal{Z}\times \{-1, + 1\})^{t})\times \mathcal{G}\to \mathcal{G}$  denote a learning algorithm which maps a training dataset of any size and previously used classifier, to an updated predictor. For example,  $\mathcal{A}_{\mathrm{c}}$  may apply a single gradient descent step using the most recent observation to update a model. We start with  $\mathcal{D}_0 = \emptyset$  and  $g_{1}\in \mathcal{G}:g_{1}(z) = 0$  , for any  $z\in \mathcal{Z}$  At round  $t$  , we use one of the payoffs:
$$
f _ {t} ^ {\mathrm {m}} \left(Z _ {t}, W _ {t}\right) = W _ {t} \cdot \operatorname {s i g n} \left[ g _ {t} \left(Z _ {t}\right) \right] \in \{- 1, 1 \}, \tag {22a}
$$
$$
f _ {t} ^ {\mathrm {s}} \left(Z _ {t}, W _ {t}\right) = W _ {t} \cdot g _ {t} \left(Z _ {t}\right) \in [ - 1, 1 ]. \tag {22b}
$$
After  $(Z_{t},W_{t})$  is used for betting, we update a training dataset:  $\mathcal{D}_t = \mathcal{D}_{t - 1}\cup \{(Z_t,W_t)\}$ , and an existing predictor:  $g_{t + 1} = \mathcal{A}_{\mathrm{c}}(\mathcal{D}_t,g_t)$ . We summarize our sequential classification-based 2ST (SeqC-2ST) in Algorithm 2. We note that using pre-trained models (e.g., for image data) as initialization may definitely improve the performance during the early stages of testing in practice.
Algorithm 2 Sequential classification-based 2ST (Seq-C-2ST)
Input: level  $\alpha \in (0,1)$ , data stream  $((Z_{t},W_{t}))_{t\geq 1}$ ,  $g_{1}(z)\equiv 0$ ,  $\mathcal{A}_{\mathrm{c}}$ ,  $\mathcal{D}_0 = \emptyset$ ,  $\lambda_1^{\mathrm{ONS}} = 0$ .  
for  $t = 1,2,\ldots$  do  
Evaluate the payoff  $f_{t}^{\mathrm{s}}(Z_{t},W_{t})$  as in (22a);  
Using  $\lambda_t^{\mathrm{ONS}}$ , update the wealth process  $\kappa_t^{\mathrm{s}}$  as per (5);  
if  $\kappa_t^{\mathrm{s}}\geq 1 / \alpha$  then  
Reject  $H_{0}$  and stop;  
else  
Update the training dataset:  $\mathcal{D}_t\coloneqq \mathcal{D}_{t - 1}\cup \{(Z_t,W_t)\}$ ;  
Update predictor:  $g_{t + 1} = \mathcal{A}_c(\mathcal{D}_t,g_t)$ ;  
Compute  $\lambda_{t + 1}^{\mathrm{ONS}}$  (Algorithm 1) using  $f_{t}^{\mathrm{s}}(Z_{t},W_{t})$ ;
While we do not need any assumptions to confirm the type I error control, we place some mild assumptions on the learning algorithm  $\mathcal{A}_{\mathrm{c}}$  to argue about the consistency.
Assumption 1 ( $R_{\mathrm{m}}$ -learnability). Suppose that  $H_{1}$  in (1b) is true. An algorithm  $\mathcal{A}_{\mathrm{c}}$  is such that the resulting sequence  $(g_t)_{t \geq 1}$  satisfies:  $\lim \sup_{t \to \infty} \frac{1}{t} \sum_{i=1}^{t} \mathbb{1}\{W_i \cdot \operatorname{sign}[g_i(Z_i)] < 0\} < 1/2$ .
Assumption 2 ( $R_{\mathrm{s}}$ -learnability). Suppose that  $H_{1}$  in (1b) is true. An algorithm  $\mathcal{A}_{\mathrm{c}}$  is such that the resulting sequence  $(g_{t})_{t\geq 1}$  satisfies:  $\lim \sup_{t\to \infty}\frac{1}{t}\sum_{i = 1}^{t}(g_i(Z_i) - W_i)^2 < 1$ .
In words, the above assumptions state that a sequence of predictors  $(g_{t})_{t\geq 1}$  is better than a chance predictor on average. We conclude with the following result, whose proof is deferred to Appendix D.3.
Theorem 2. The following claims hold for Seq-C-2ST (Algorithm 2):
1. If  $H_0$  in (1a) is true, the test ever stops with probability at most  $\alpha$ :  $\mathbb{P}_{H_0}(\tau < \infty) \leq \alpha$ .
2. Suppose that  $H_{1}$  in (1b) is true. Then:
(a) Under Assumption 1, the test with the payoff (22a) is consistent:  $\mathbb{P}_{H_1}(\tau < \infty) = 1$ .
(b) Under Assumption 2, the test with the payoff (22b) is consistent:  $\mathbb{P}_{H_1}(\tau < \infty) = 1$ .
Remark 4. Suppose that we perform two-sample testing for  $d$ -dimensional data. At time  $T$ , the total accumulated computation for the kernelized test of Shekhar and Ramdas [2023] is  $O(dT^2)$ . For our test, the answer depends on the chosen classifier and learning algorithm. Using logistic regression in combination with gradient descent for updating model parameters results in cheap updates and payoff evaluation (both are  $O(d)$  at each round, and hence the total accumulated computation at time  $T$  is  $O(dT)$ ). For  $k$ -NN classifier, no parameters have to be updated, yet evaluating payoffs becomes more expensive with a growing sample size, resulting in the total accumulated computation of  $O(kdT^2)$  at time  $T$ . For more complex models like neural nets, runtime depends on the chosen architecture: the total accumulated computation at time  $T$  is  $O((cB + F)T)$ , where  $F$  and  $B$  are the costs of forward-propagation and back-propagation steps respectively and  $c$  is the number of back-propagation steps applied after processing the next point (the exact cost depends on the architecture).
Sequential Classification-based Independence Test (Seq-C-IT). Under the setting of Definition 2, a single point from  $P_{XY}$  is revealed at each round. Following [Podkopaev et al., 2023], we bet on two points from  $P_{XY}$  (labeled as  $+1$ ) and utilize external randomization to produce instances from  $P_{X} \times P_{Y}$  (labeled as  $-1$ ). Let  $\mathcal{A}_{c}^{\mathrm{IT}}: (\cup_{t \geq 1} ((\mathcal{X} \times \mathcal{Y}) \times \{-1, +1\})^{t}) \times \mathcal{G} \to \mathcal{G}$  denote a learning algorithm which maps a training dataset of any size and previously used classifier, to an updated predictor. We start with  $\mathcal{D}_0 = \emptyset$  and  $g_1: g_1(x,y) = 0, \forall (x,y) \in \mathcal{X} \times \mathcal{Y}$ . We use derandomized versions of the payoffs (22), e.g., instead of (22b), we use
$$
\begin{array}{l} f _ {t} ^ {\mathrm {s}} \left(\left(X _ {2 t - 1}, Y _ {2 t - 1}\right), \left(X _ {2 t}, Y _ {2 t}\right)\right) = \frac {1}{4} \left(g _ {t} \left(X _ {2 t - 1}, Y _ {2 t - 1}\right) + g _ {t} \left(X _ {2 t}, Y _ {2 t}\right)\right) \\ - \frac {1}{4} \left(g _ {t} \left(X _ {2 t - 1}, Y _ {2 t}\right) + g _ {t} \left(X _ {2 t}, Y _ {2 t - 1}\right)\right). \tag {23} \\ \end{array}
$$
After  $(X_{2t - 1},Y_{2t - 1})$ ,  $(X_{2t},Y_{2t})$  have been used for betting, we update a training dataset:
$$
\mathcal {D} _ {t} = \mathcal {D} _ {t - 1} \cup \left\{\left(\left(X _ {2 t - 1}, Y _ {2 t - 1}\right), + 1\right), \left(\left(X _ {2 t}, Y _ {2 t}\right), + 1\right), \left(\left(X _ {2 t - 1}, Y _ {2 t}\right), - 1\right), \left(\left(X _ {2 t}, Y _ {2 t - 1}\right), - 1\right) \right\},
$$
and an existing predictor:  $g_{t + 1} = \mathcal{A}_{\mathrm{c}}^{\mathrm{IT}}(\mathcal{D}_{t},g_{t})$ . Seq-C-IT inherits the time-uniform type I error control and the consistency guarantees of Theorem 2, and we omit details for brevity.
Synthetic Experiments. In our evaluation, we first consider synthetic datasets where the complexity of the independence testing setup is characterized by a single univariate parameter. We set the monitoring horizon to  $T = 5000$  points from  $P_{XY}$ , and for each parameter value, we aggregate the results over 200 runs. In particular, we use the following synthetic settings:
1. Spherical model. Let  $(U_{t})_{t\geq 1}$  be a sequence of random vectors on a unit sphere in  $\mathbb{R}^d$ :  $U_{t}\stackrel {\mathrm{iid}}{\sim}\operatorname {Unif}(\mathbb{S}^{d})$ , and let  $u_{(i)}$  denote the  $i$ -th coordinate of  $u$ . For  $t\geq 1$ , we take
$$
\left(X _ {t}, Y _ {t}\right) = \left(\left(U _ {t}\right) _ {(1)}, \left(U _ {t}\right) _ {(2)}\right).
$$
We consider  $d \in \{3, \dots, 10\}$ , where larger  $d$  defines a harder setup.
2. Hard-to-detect-dependence (HTDD) model. We sample  $((X_{t},Y_{t}))_{t\geq 1}$  from
$$
p (x, y) = \frac {1}{4 \pi^ {2}} \left(1 + \sin (w x) \sin (w y)\right) \cdot \mathbb {1} \left\{\left(x, y\right) \in [ - \pi , \pi ] ^ {2} \right\}. \tag {24}
$$
We consider  $w \in \{0, \dots, 6\}$ , where  $H_0$  is true (random variables are independent) if and only if  $w = 0$ . For  $w > 0$ , Corr  $(X,Y) \approx 1 / w^2$ , and the setup is harder for larger  $w$ .
For the comparison, we use two predictive models to construct Seq-C-ITs:
1. Let  $\mathcal{N}_t(z) \coloneqq \mathcal{N}(z, \mathcal{D}_{t-1}, k_t)$  define the set of  $k_t$  closest points in  $\mathcal{D}_{t-1}$  to a query point  $z \coloneqq (x, y)$ . We consider a regularized  $k$ -NN predictor:  $\hat{g}_t(z) = \frac{1}{k_t + 1} \sum_{(Z,W) \in \mathcal{N}_t(z)} W$ . We select the number of neighbors using the square-root rule:  $k_t = \sqrt{|\mathcal{D}_{t-1}|} = \sqrt{4(t - 1)}$ .
2. We use a multilayer perceptron (MLP) with three hidden layers and 128, 64 and 32 neurons respectively and the parameters learned using an incremental training scheme.
We use the HSIC-based sequential kernelized independence test (SKIT) [Podkopaev et al., 2023] as a reference test and defer details, such as MLP training scheme and SKIT hyperparameters, to Appendix E.1. In Figure 2, we observe that SKIT outperforms Seq-C-ITs under the spherical model (with no localized dependence structure), whereas, under the structured HTDD model, Seq-C-ITs, is superior. Further, inspecting Figure 2b at  $w = 0$  confirms that all tests control the type I error. We refer the reader to Appendix E.2 for additional experiments on synthetic data with localized dependence where Seq-C-ITs are superior. In Appendix E.2, we also provide the results for the average stopping times of our tests: we empirically confirm that our tests are adaptive to the complexity of a problem at hand: they stop earlier on easy tasks and later on harder ones.
(a) Spherical model.
(b) HTDD model.
Figure 2: Power of different sequential independence tests on synthetic data from Section 3. Under the spherical model (no localized dependence), SKIT is better than Seq-C-ITs. Under the (structured) HTDD model, SKIT is inferior to sequential predictive independence tests.
Real Data Experiments. First, we compare sequential classification-based and kernelized 2STs using Karolinska Directed Emotional Faces dataset (KDEF) [Lundqvist et al., 1998] which contains images of actors and actresses expressing different emotions: afraid (AF), angry (AN), disgusted (DI), happy (HA), neutral (HE), sad (SA), and surprised (SU). Following earlier works [Lopez-Paz and Oquab, 2017, Jitkrittum et al., 2016], we focus on straight profile only and assign HA, NE, SU emotions to the positive class (instances from  $P$ ), and AF, AN, DI emotions to the negative class (instances from  $Q$ ); see Figure 3a. We remove corrupted images and obtain a dataset containing 802 images with six different emotions. The original images  $(562 \times 762$  pixels) are cropped to exclude the background, resized to  $64 \times 64$  pixels and converted to grayscale.
For Seq-C-2ST, we use a small CNN as an underlying model and defer details about the architecture and training to Appendix E.1. As a reference kernel-based 2ST, we use the sequential MMD test of Shekhar and Ramdas [2023] and adapt it to the setting where at each round either an observation from  $P$  or that from  $Q$  is revealed; see Appendix E.1 for details. We omit the comparison to Lheritier and Cazals [2019] since their test has been shown to be inferior to the one developed by Shekhar and Ramdas [2023]. In Figure 3b, we illustrate that while both tests achieve perfect power after processing sufficiently many observations, our Seq-C-2ST requires fewer observations to do so.
Figure 3: (a) Examples of instances from  $P$  (top row) and  $Q$  (bottom row) for KDEF dataset. (b) Rejection rates for our test (Seq-C-2ST) and the sequential kernelized 2ST. While both tests achieve perfect power with enough data, our test is superior to the kernelized approach, requiring fewer observations to do so. The results are averaged over 200 random orderings of the data.
Next, we compare two independence tests using MNIST image dataset [LeCun et al., 1998]. To simulate the null setting, we sample pairs of random images from the entire dataset, and to simulate the alternative, we sample pairs of random images depicting the same digit (Figure 4a). For Seq-C-IT, we use MLP with the same architecture as for simulations on synthetic data. For SKIT, we use the median heuristic with 20 points from  $P_{XY}$  to compute kernel hyperparameters. In Figure 4b, we show that while both tests control the type I error under  $H_0$ , SKIT is inferior to Seq-C-IT under  $H_1$ , requiring twice as much data to achieve perfect power.
Figure 4: (a) Instances from the  $P_{XY}$  (top row) and  $P_{X} \times P_{Y}$  (bottom row) for MNIST dataset. (b) While both independence tests control the type I error under  $H_{0}$ , Seq-C-IT outperforms SKIT under  $H_{1}$ , rejecting the null much sooner. The results are aggregated over 200 runs.
While kernel methods are state-of-the-art for nonparametric two-sample and independence testing, their performance often deteriorates on complex data, e.g., high-dimensional data with localized dependence. In such settings, prediction-based tests are often much more effective. In this work, we developed sequential predictive two-sample and independence tests following the principle of testing by betting. Our tests control the type I error despite continuously monitoring the data and are consistent under weak and tractable assumptions. Further, our tests provably adapt to the complexity of a problem at hand: they stop earlier on easy tasks and later on harder ones. An additional advantage of our tests is that an analyst may modify the design choices, e.g., model architecture, on-the-fly. Through experiments on synthetic and real data, we confirm that our tests are competitive to kernel-based ones overall and outperform those under structured settings.
We refer the reader to the Appendix for additional results that were not included in the main paper:
1. In Appendix A, we complement classification-based ITs with a regression-based approach. Regression-based ITs represent an alternative to the classification-based approach in settings where a data stream  $((X_{t},Y_{t}))_{t\geq 1}$  may be processed directly as feature-response pairs.
2. In Section 2, we considered the case of balanced classes, meaning that at each round, an instance from either  $P$  or  $Q$  is observed with equal chance. In Appendix B, we extend the methodology to a more general case of two-sample testing with unknown class proportions.
3. Batch two-sample and independence tests rely on either a cutoff computed using the asymptotic null distribution of a chosen test statistic (when it is tractable) or a permutation p-value, and if the distribution drifts, both approaches fail to provide the type I error control. In contrast, Seq-C-2ST and Seq-C-IT remain valid beyond the i.i.d. setting by construction (analogous to tests developed by Shekhar and Ramdas [2023], Podkopaev et al. [2023]), and we refer the reader to Appendix C for more details.
Acknowledgements. The authors thank Ian Waudby-Smith and Tudor Manole for fruitful discussions. AR acknowledges support from NSF grants IIS-2229881 and DMS-2310718.
Thomas B. Berrett and Richard J. Samworth. Nonparametric independence testing via mutual information. Biometrika, 2019.
Xiuyuan Cheng and Alexander Cloninger. Classification logit two-sample testing by neural networks for differentiating near manifold densities. IEEE Transactions on Information Theory, 2022.
Ashok Cutkosky and Francesco Orabona. Black-box reductions for parameter-free online learning in banach spaces. In Conference on Learning Theory, 2018.
Donald A. Darling and Herbert E. Robbins. Some nonparametric sequential tests with power one. Proceedings of the National Academy of Sciences, 1968.
Jerome H. Friedman. On multivariate goodness-of-fit and two-sample testing. Technical report, Stanford University, 2004.
Arthur Gretton, Olivier Bousquet, Alex Smola, and Bernhard Schölkopf. Measuring statistical dependence with Hilbert-Schmidt norms. In Algorithmic Learning Theory, 2005.
Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Scholkopf, and Alexander Smola. A kernel two-sample test. Journal of Machine Learning Research, 2012.
Peter Grünwald, Alexander Henzi, and Tyron Lardy. Anytime-valid tests of conditional independence under model-X. Journal of the American Statistical Association, 2023.
Elad Hazan, Amit Agarwal, and Satyen Kale. Logarithmic regret algorithms for online convex optimization. Machine Learning, 2007.
Simon Hediger, Loris Michel, and Jeffrey Naf. On the use of random forest for two-sample testing. Computational Statistics & Data Analysis, 2022.
Wittawat Jitkrittum, Zoltán Szabó, Kacper P Chwialkowski, and Arthur Gretton. Interpretable distribution features with maximum testing power. In Advances in Neural Information Processing Systems, 2016.
Ilmun Kim and Aaditya Ramdas. Dimension-agnostic inference using cross U-statistics. Bernoulli, 2020.
Ilmun Kim, Ann B. Lee, and Jing Lei. Global and local two-sample tests via regression. *Electronic Journal of Statistics*, 2019.
Ilmun Kim, Aaditya Ramdas, Aarti Singh, and Larry Wasserman. Classification accuracy as a proxy for two-sample testing. The Annals of Statistics, 2021.
Jonas M. Kübler, Vincent Stimper, Simon Buchholz, Krikamol Muandet, and Bernhard Schölkopf. AutoML two-sample test. In Advances in Neural Information Processing Systems, 2022.
Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 1998.
Alix Lheritier and Frédéric Casals. A sequential non-parametric multivariate two-sample test. IEEE Transactions on Information Theory, 2018.
Alix Lheritier and Frédéric Cazals. Low-complexity nonparametric bayesian online prediction with universal guarantees. In Advances in Neural Information Processing Systems, 2019.
Feng Liu, Wenkai Xu, Jie Lu, Guangquan Zhang, Arthur Gretton, and Danica J. Sutherland. Learning deep kernels for non-parametric two-sample tests. In International Conference on Machine Learning, 2020.
David Lopez-Paz and Maxime Aquab. Revisiting classifier two-sample tests. In International Conference on Learning Representations, 2017.
Daniel Lundqvist, Anders Flykt, and Arne Ohman. The Karolinska Directed Emotional Faces - KDEF. Technical report, Karolinska Institutet, 1998.
Teodora Pandeva, Tim Bakker, Christian A Naesseth, and Patrick Forre. E-valuating classifier two-sample tests. arXiv preprint: 2210.13027, 2022.
Aleksandr Podkopaev, Patrick Blöbaum, Shiva Prasad Kasiviswanathan, and Aaditya Ramdas. Sequential kernelized independence testing. In International Conference on Machine Learning, 2023.
Aaditya Ramdas and Tudor Manole. Randomized and exchangeable improvements of Markov's, Chebyshev's and Chernoff's inequalities. arXiv preprint: 2304.02611, 2023.
Aaditya Ramdas, Sashank Jakkam Reddi, Barnabas Poczos, Aarti Singh, and Larry Wasserman. On the decreasing power of kernel and distance based nonparametric hypothesis tests in high dimensions. AAAI Conference on Artificial Intelligence, 2015.
Aaditya Ramdas, Johannes Ruf, Martin Larsson, and Wouter Koolen. Admissible anytime-valid sequential inference must rely on nonnegative martingales. arXiv preprint: 2009.03167, 2020.
Shalev Shaer, Gal Maman, and Yaniv Romano. Model-free sequential testing for conditional independence via testing by betting. In Conference on Artificial Intelligence and Statistics, 2023.
Glenn Shafer. Testing by betting: a strategy for statistical and scientific communication. Journal of the Royal Statistical Society: Series A (Statistics in Society), 2021.
Glenn Shafer and Vladimir Vovk. Game-Theoretic Foundations for Probability and Finance. Wiley Series in Probability and Statistics. Wiley, 2019.
Shubhanshu Shekhar and Aaditya Ramdas. Nonparametric two-sample testing by betting. IEEE Transactions on Information Theory, 2023.
Danica J. Sutherland, Hsiao-Yu Tung, Heiko Strathmann, Soumyajit De, Aaditya Ramdas, Alex Smola, and Arthur Gretton. Generative models and model criticism via optimized maximum mean discrepancy. In International Conference on Learning Representations, 2017.
Jean Ville. Étude critique de la notion de collectif. Thèses de l'entre-deux-guerres. Gauthier-Villars, 1939.
Larry Wasserman, Aaditya Ramdas, and Sivaraman Balakrishnan. Universal inference. Proceedings of the National Academy of Sciences, 2020.
A Regression-based Independence Testing
Regression-based independence tests represent an alternative to classification-based approaches in settings where a data stream  $((X_{t},Y_{t}))_{t\geq 1}$  may be processed directly as feature-response pairs. Suppose that one selects a functional class  $\mathcal{G}:\mathcal{X}\to \mathcal{V}$  for performing such prediction task, and let  $\ell$  denote a loss function that evaluates the quality of predictions. For example, if  $(Y_{t})_{t\geq 1}$  is a sequence of univariate random variables, one can use the squared loss:  $\ell (g(x),y) = (g(x) - y)^2$ , or the absolute loss:  $\ell (g(x),y) = |g(x) - y|$ .
Such tests rely on the following idea: if the alternative  $H_{1}$  in (2b) is true and a sequence of sequentially updated predictors  $(g_{t})_{t\geq 1}$  has nontrivial predictive power, then the losses on random instances drawn from the joint distribution  $P_{XY}$  are expected to be less on average than the losses on random instances from  $P_{X}\times P_{Y}$ . For the  $t$ -th pair of points from  $P_{XY}$ , we can label the losses of  $g_{t}$  on all possible  $(X,Y)$ -pairs as
$$
L _ {2 t - 1} = \ell \left(g _ {t} \left(X _ {2 t - 1}\right), Y _ {2 t - 1}\right), \quad L _ {2 t} = \ell \left(g _ {t} \left(X _ {2 t}\right), Y _ {2 t}\right),
$$
$$
L _ {2 t - 1} ^ {\prime} = \ell \left(g _ {t} \left(X _ {2 t - 1}\right), Y _ {2 t}\right), \quad L _ {2 t} ^ {\prime} = \ell \left(g _ {t} \left(X _ {2 t}\right), Y _ {2 t - 1}\right). \tag {25}
$$