SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Aleksandr Podkopaev
Walmart Global Tech sasha.podkopaev@walmart.com
Carnegie Mellon University aramdas@cmu.edu
We study the problems of sequential nonparametric two-sample and independence testing. Sequential tests process data online and allow using observed data to decide whether to stop and reject the null hypothesis or to collect more data, while maintaining type I error control. We build upon the principle of (nonparametric) testing by betting, where a gambler places bets on future observations and their wealth measures evidence against the null hypothesis. While recently developed kernel-based betting strategies often work well on simple distributions, selecting a suitable kernel for high-dimensional or structured data, such as images, is often nontrivial. To address this drawback, we design prediction-based betting strategies that rely on the following fact: if a sequentially updated predictor starts to consistently determine (a) which distribution an instance is drawn from, or (b) whether an instance is drawn from the joint distribution or the product of the marginal distributions (the latter produced by external randomization), it provides evidence against the two-sample or independence nulls respectively. We empirically demonstrate the superiority of our tests over kernel-based approaches under structured settings. Our tests can be applied beyond the case of independent and identically distributed data, remaining valid and powerful even when the data distribution drifts over time.
We consider two closely-related problems of nonparametric two-sample and independence testing. In the former, given observations from two distributions  $P$  and  $Q$ , the goal is to test the null hypothesis that the distributions are the same:  $H_0: P = Q$ , against the alternative that they are not:  $H_1: P \neq Q$ . In the latter, given observations from some joint distribution  $P_{XY}$ , the goal is to test the null hypothesis that the random variables are independent:  $H_0: P_{XY} = P_X \times P_Y$ , against the alternative that they are not:  $H_1: P_{XY} \neq P_X \times P_Y$ . Kernel tests, such as kernel-MMD [Gretton et al., 2012] for two-sample and HSIC [Gretton et al., 2005] for independence testing, are amongst the most popular methods for solving these tasks which work well on data from simple distributions. However, their performance is sensitive to the choice of a kernel and respective parameters, like bandwidth, and applying such tests requires additional effort. Further, selecting kernels for structured data, like images, is a nontrivial task. Lastly, kernel tests suffer from decaying power in high dimensions [Ramdas et al., 2015].
Predictive two-sample and independence tests (2STs and ITs respectively) aim to address such limitations of kernelized approaches. The idea of using classifiers for two-sample testing dates back to Friedman [2004] who proposed using the output scores as a dimension reduction method. More recent works focused on the direct evaluation of a learned model for testing. In an initial arXiv 2016 preprint, Kim et al. [2021] proposed and analyzed predictive 2STs based on sample-splitting, namely testing whether the accuracy of a model trained on the first split of data and estimated on the second split is significantly better than chance. The authors established the consistency of asymptotic and exact tests in high-dimensional settings and provided rates for the case of Gaussian
distributions. Inspired by this work, Lopez-Paz and Oquab [2017] soon after demonstrated that empirically predictive 2STs often outperform state-of-the-art 2STs, such as kernel-MMD. Recently, Hediger et al. [2022] proposed a related test that utilizes out-of-bag predictions for bagging-based classifiers, such as random forests. To incorporate measures of model confidence, many authors have also explored using test statistics that are based on the output scores instead of the binary class predictions [Kim et al., 2019, Liu et al., 2020, Cheng and Cloninger, 2022, Kübler et al., 2022].
The focus of the above works is on batch tests which are calibrated to have a fixed false positive rate (say,  $5\%$  ) if the sample size is specified in advance. In contrast, we focus on the setting of sequentially released data. Our tests allow on-the-fly decision-making: an analyst can use observed data to decide whether to stop and reject the null or to collect more data, without inflating the false alarm rate.
Problem Setup. First, we define the problems of sequential two-sample and independence testing.
Definition 1 (Sequential two-sample testing). Suppose that we observe a stream of i.i.d. observations  $((Z_{t},W_{t}))_{t\geq 1}$ , where  $W_{t}\sim \mathrm{Rademacher}(1 / 2)$ , the distribution of  $Z_{t}\mid W_{t} = +1$  is denoted  $P$ , and that of  $Z_{t}\mid W_{t} = -1$  is denoted  $Q$ . The goal is to design a sequential test for
$$
H _ {0}: P = Q, \tag {1a}
$$
$$
H _ {1}: P \neq Q. \tag {1b}
$$
Definition 2 (Sequential independence testing). Suppose that we observe that a stream of observations:  $((X_{t},Y_{t}))_{t\geq 1}$ , where  $(X_{t},Y_{t})\sim P_{XY}$  for  $t\geq 1$ . The goal is to design a sequential test for
$$
H _ {0}: \left(X _ {t}, Y _ {t}\right) \sim P _ {X Y} \text {a n d} P _ {X Y} = P _ {X} \times P _ {Y}, \tag {2a}
$$
$$
H _ {1}: \left(X _ {t}, Y _ {t}\right) \sim P _ {X Y} \text {a n d} P _ {X Y} \neq P _ {X} \times P _ {Y}. \tag {2b}
$$
We operate in the framework of "power-one tests" [Darling and Robbins, 1968] and define a level- $\alpha$  sequential test as a mapping  $\Phi: \cup_{t=1}^{\infty} \mathcal{Z}^t \to \{0,1\}$  that satisfies:  $\mathbb{P}_{H_0}(\exists t \geq 1: \Phi(Z_1, \ldots, Z_t) = 1) \leq \alpha$ . We refer to such notion of type I error control as time-uniform. Here, 0 stands for "do not reject the null yet" and 1 stands for "reject the null and stop". Defining the stopping time as the first time that the test outputs  $1$ :  $\tau := \inf \{t \geq 1: \Phi(Z_1, \ldots, Z_t) = 1\}$ , a sequential test must satisfy
$$
\mathbb {P} _ {H _ {0}} (\tau <   \infty) \leq \alpha . \tag {3}
$$
We aim to design consistent tests which are guaranteed to stop if the alternative happens to be true:
$$
\mathbb {P} _ {H _ {1}} (\tau <   \infty) = 1. \tag {4}
$$
Related Works. Our construction follows the principle of testing by betting [Shafer, 2021]. The most closely related work is that of "nonparametric 2ST by betting" of Shekhar and Ramdas [2023], which later inspired several follow-up works, including sequential (marginal) kernelized independence tests of Podkopaev et al. [2023], and the sequential conditional independence tests under the model-X assumption of Grünwald et al. [2023] and Shaer et al. [2023]. We extend the line of work of Shekhar and Ramdas [2023] and of Podkopaev et al. [2023], studying predictive approaches in detail.
Sequential predictive 2STs were studied by Lhéritier and Cazals [2018, 2019], but in practice, those tests were found to be inferior to the ones developed by Shekhar and Ramdas [2023]. Recently, Pandeva et al. [2022] proposed a predictive 2ST that handles unknown class proportions using ideas from [Wasserman et al., 2020]. In Section 2, we show that our tests are closely related to [Lhéritier and Cazals, 2018, 2019, Pandeva et al., 2022], but are consistent under much milder assumptions.
Sequential Nonparametric Two-Sample and Independence Testing by Betting. Suppose that one observes a sequence of random variables  $(Z_{t})_{t\geq 1}$ , where  $Z_{t}\in \mathcal{Z}$ . The principle of testing by betting [Shafer and Vovk, 2019, Shafer, 2021] can be described as follows. A player starts the game with initial capital  $\mathcal{K}_0 = 1$ . At round  $t$ , she selects a payoff function  $f_{t}:\mathcal{Z}\to [-1,\infty)$  that satisfies  $\mathbb{E}_{Z\sim P_Z}[f_t(Z)\mid \mathcal{F}_{t - 1}] = 0$  for all  $P_Z\in H_0$ , where  $\mathcal{F}_{t - 1} = \sigma (Z_1,\ldots ,Z_{t - 1})$  denotes the sigma-field generated by  $Z_{1},\ldots ,Z_{t - 1}$  with  $\mathcal{F}_0$  being the trivial sigma-field, and bets a fraction of her wealth  $\lambda_t\mathcal{K}_{t - 1}$  for an  $\mathcal{F}_{t - 1}$ -measurable  $\lambda_t\in [0,1]$ . Once  $Z_{t}$  is revealed, her wealth is updated as
$$
\mathcal {K} _ {t} = \mathcal {K} _ {t - 1} + \lambda_ {t} \mathcal {K} _ {t - 1} f _ {t} \left(Z _ {t}\right) = \mathcal {K} _ {t - 1} \left(1 + \lambda_ {t} f _ {t} \left(Z _ {t}\right)\right). \tag {5}
$$
The wealth is used to measure the evidence against  $H_0$ : if a player can make money in such game, the null is rejected. Formally, for testing  $H_0$  at level  $\alpha \in (0,1)$ , we use the stopping rule:
$$
\tau = \inf  \left\{t \geq 1: \mathcal {K} _ {t} \geq 1 / \alpha \right\}. \tag {6}
$$
The validity of the test follows from Ville's inequality [Ville, 1939], a time-uniform generalization of Markov's inequality, since  $(\mathcal{K}_t)_{t\geq 0}$  is a nonnegative martingale starting at 1 under any  $P_Z\in H_0$ . To ensure high power, one has to choose  $(f_t)_{t\geq 1}$  and  $(\lambda_t)_{t\geq 1}$  to guarantee the growth of the wealth if the alternative is true. In the context of two-sample and independence testing, Shekhar and Ramdas [2023] and Podkopaev et al. [2023] recently proposed effective betting strategies based on kernelized measures of statistical distance and dependence respectively which admit a variational representation. In a nutshell, datapoints observed prior to a given round are used to estimate the witness function — one that best highlights the discrepancy between  $P$  and  $Q$  for two-sample (or between  $P_{XY}$  and  $P_X\times P_Y$  for independence) testing — and a bet is formed as an estimator of a chosen measure of distance (or dependence). In contrast, our bets are based on evaluating the performance of a sequentially learned predictor that distinguishes between instances from distributions of interest.
Remark 1. In practical settings, an analyst may not be able to continue collecting data forever and may adaptively stop the experiment before the wealth exceeds  $1 / \alpha$ . In such case, one may use a different threshold for rejecting the null at a stopping time  $\tau$ , namely  $U / \alpha$ , where  $U$  is a (stochastically larger than) uniform random variable on  $[0,1]$  drawn independently from  $(\mathcal{F}_t)_{t\geq 0}$ . This choice strictly improves the power of the test without violating the validity; see [Ramdas and Manole, 2023].
Contributions. In Section 2, we develop sequential predictive two-sample and independence tests. We establish sufficient conditions for consistency of our tests and relate those to evaluation metrics of the underlying models. In Section 3, we conduct an extensive empirical study on synthetic and real data, justifying the superiority of our tests over the kernelized ones on structured data.
2 Classification-based Two-Sample Testing
We begin with the two-sample testing setting outlined in Definition 5. Let  $\mathcal{G}:\mathcal{Z}\to [-1,1]$  denote a class of predictors used to distinguish between instances from  $P$  (labeled as  $+1$ ) and  $Q$  (labeled as  $-1)^{1}$ . We assume that: (a) if  $g\in \mathcal{G}$ , then  $-g\in \mathcal{G}$ , (b) if  $g\in \mathcal{G}$  and  $s\in [0,1]$ , then  $sg\in \mathcal{G}$ , and (c) predictions are based on  $\mathrm{sign}[g(\cdot)]$ , and if  $g(z) = 0$ , then  $z$  is assigned to the positive class. Two natural evaluation metrics of a predictor  $g\in \mathcal{G}$  include the misclassification and the squared risks:
$$
R _ {\mathrm {m}} (g) := \mathbb {P} (W \cdot \operatorname {s i g n} [ g (Z) ] <   0), \quad R _ {\mathrm {s}} (g) := \mathbb {E} \left[ (g (Z) - W) ^ {2} \right], \tag {7}
$$
which give rise to the following measures of distance between  $P$  and  $Q$ , namely
$$
d _ {\mathrm {m}} (P, Q) := \sup  _ {g \in \mathcal {G}} \left(\frac {1}{2} - R _ {\mathrm {m}} (g)\right), \quad d _ {\mathrm {s}} (P, Q) := \sup  _ {g \in \mathcal {G}} \left(1 - R _ {\mathrm {s}} (g)\right). \tag {8}
$$
It is easy to check that  $d_{\mathrm{m}}(P, Q) \in [0, 1/2]$  and  $d_{\mathrm{m}}(P, Q) \in [0, 1]$ . The upper bounds hold due to the non-negativity of the risks and the lower bounds follow by considering  $g: g(z) = 0, \forall z \in \mathcal{Z}$ . Note that the misclassification risk is invariant to rescaling  $(R_{\mathrm{m}}(sg) = R_{\mathrm{m}}(g), \forall s \in (0, 1])$ , whereas the squared risk is not, and rescaling any  $g$  to optimize the squared risk provides better contrast between  $P$  and  $Q$ . In the next result, whose proof is deferred to Appendix D.3, we present an important relationship between the squared risk of a rescaled predictor and its expected margin:  $\mathbb{E}[W \cdot g(Z)]$ .
Proposition 1. Fix an arbitrary predictor  $g \in \mathcal{G}$ . The following claims hold:
1. For the misclassification risk, we have that:
$$
\sup  _ {s \in [ 0, 1 ]} \left(\frac {1}{2} - R _ {\mathrm {m}} (s g)\right) = \left(\frac {1}{2} - R _ {\mathrm {m}} (g)\right) \vee 0 = \left(\frac {1}{2} \cdot \mathbb {E} [ W \cdot \operatorname {s i g n} [ g (Z) ] ]\right) \vee 0. \tag {9}
$$
2. For the squared risk, we have that:
$$
\sup  _ {s \in [ 0, 1 ]} (1 - R _ {\mathrm {s}} (s g)) \geq (\mathbb {E} [ W \cdot g (Z) ] \vee 0) \cdot \left(\frac {\mathbb {E} [ W \cdot g (Z) ]}{\mathbb {E} [ g ^ {2} (Z) ]} \wedge 1\right) \tag {10}
$$
Further,  $d_{\mathrm{s}}(P,Q) > 0$  if and only if there exists  $g \in \mathcal{G}$  such that  $\mathbb{E}\left[W \cdot g(Z)\right] > 0$ .
${}^{1}$  Similar argument can be applied to general scoring-based classifiers:  $g : \mathcal{Z} \rightarrow  \mathbb{R}$  ,e.g.,SVMs,by considering  $\widetilde{\mathcal{G}} = \left\{  {\widetilde{g} : \widetilde{g}\left( z\right)  = \tanh \left( {s \cdot  g\left( z\right) }\right) ,g \in  \mathcal{G},s > 0}\right\}$  ,where the constant  $s > 0$  corrects the scale of the scores.
$2\vee$  and  $\wedge$  denote a maximum and a minimum respectively:  $a\lor b = \max \{a,b\}$ $a\land b = \min \{a,b\}$
Consider an arbitrary predictor  $g \in \mathcal{G}$ . Note that under the null  $H_0$  in (1a), the misclassification risk  $R_{\mathrm{m}}(g)$  does not depend on  $g$ , being equal to 1/2, whereas the squared risk  $R_{\mathrm{s}}(g)$  does. In contrast, the lower bound (10) no longer depends on  $g$  under the null  $H_0$ , being equal to 0.
Oracle Test. It is a known fact that the minimizer of either the misclassification or the squared risk is  $g^{\mathrm{Bayes}}(z) = 2\eta (z) - 1$ , where  $\eta (z) = \mathbb{P}\left(W = +1\mid Z = z\right)$ . Since  $g^{\mathrm{Bayes}}$  may not belong to  $\mathcal{G}$ , we consider  $g_{\star}\in \mathcal{G}$ , which minimizes either the misclassification or the squared risk over predictors in  $\mathcal{G}$ , and omit superscripts for brevity. To design payoff functions, we follow Proposition 1 and consider
$$
f _ {\star} ^ {\mathrm {m}} \left(Z _ {t}, W _ {t}\right) = W _ {t} \cdot \operatorname {s i g n} \left[ g _ {\star} \left(Z _ {t}\right) \right] \in \{- 1, 1 \}, \tag {11a}
$$
$$
f _ {\star} ^ {s} \left(Z _ {t}, W _ {t}\right) = W _ {t} \cdot g _ {\star} \left(Z _ {t}\right) \in [ - 1, 1 ]. \tag {11b}
$$
Let the oracle wealth processes based on misclassification and squared risks  $(\mathcal{K}_t^{\mathrm{m},\star})_{t\geq 0}$  and  $(\mathcal{K}_t^{\mathrm{s},\star})_{t\geq 0}$  be defined by using the payoff functions (11a) and (11b) respectively, along with a predictable sequence of betting fractions  $(\lambda_t)_{t\geq 1}$  selected via online Newton step (ONS) strategy [Hazan et al., 2007] (Algorithm 1), which has been studied in the context of coin-betting by Cutkosky and Orabona [2018]. If a constant betting fraction is used throughout:  $\lambda_t = \lambda ,\forall t$  , then
$$
\mathbb {E} \left[ \frac {1}{t} \log \mathcal {K} _ {t} ^ {i, \star} \right] = \mathbb {E} \left[ \log \left(1 + \lambda f _ {\star} ^ {i} (Z, W)\right) \right], \quad i \in \{\mathrm {m}, \mathrm {s} \}. \tag {12}
$$
To illustrate the tightness of our results, we consider the optimal constant betting fractions which maximize the log-wealth (12) and are constrained to lie in  $[-0.5, 0.5]$ , like ONS bets:
$$
\lambda_ {\star} ^ {i} = \underset {\lambda \in [ - 0. 5, 0. 5 ]} {\arg \max } \mathbb {E} \left[ \log \left(1 + \lambda f _ {\star} ^ {i} (Z, W)\right) \right], \quad i \in \{\mathrm {m}, \mathrm {s} \}. \tag {13}
$$
Algorithm 1 Online Newton step (ONS) strategy for selecting betting fractions
Input: sequence of payoffs  $(f_{t})_{t\geq 1}$ ,  $\lambda_1^{\mathrm{ONS}} = 0$ ,  $a_0 = 1$ .
Observe  $f_{t} \in [-1, 1]$ ;
Set  $z_{t} \coloneqq f_{t} / (1 + \lambda_{t}^{\mathrm{ONS}}f_{t})$
Set  $a_{t} \coloneqq a_{t - 1} + z_{t}^{2}$ ;
Set  $\lambda_{t + 1}^{\mathrm{ONS}}\coloneqq \frac{1}{2}\wedge \left(0\vee \left(\lambda_t^{\mathrm{ONS}} + \frac{2}{2 - \log 3}\cdot \frac{z_t}{a_t}\right)\right);$
Assuming that the 2ST null is false and a predictor with non-trivial prediction risk is used, it is easy to see that the optimal constant betting fraction has to be positive, which is why in Algorithm 1 we truncate  $\lambda_t^{\mathrm{ONS}}$  at 0 instead of  $-1/2$  (the latter option is used in [Cutkosky and Orabona, 2018]). We note that this is allowed and does not affect any theoretical claims of the paper. In early simulations, we also did not observe any major differences between the two truncating options. We conclude with the following result for the oracle tests, whose proof is deferred to Appendix D.3.
Theorem 1. The following claims hold:
1. Suppose that  $H_0$  in (1a) is true. Then the oracle sequential test based on either  $(\mathcal{K}_t^{\mathrm{m},\star})_{t\geq 0}$  or  $(\mathcal{K}_t^{\mathrm{s},\star})_{t\geq 0}$  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) The growth rate of the oracle wealth process  $(\mathcal{K}_t^{\mathrm{m},\star})_{t\geq 0}$  satisfies:
$$
\lim  _ {t \rightarrow \infty} \inf  \left(\frac {1}{t} \log \mathcal {K} _ {t} ^ {\mathrm {m}, \star}\right) \stackrel {\text {a . s .}} {\geq} \left(\frac {1}{2} - R _ {\mathrm {m}} \left(g _ {\star}\right)\right) ^ {2}. \tag {14}
$$
If  $R_{\mathrm{m}}(g_{\star}) < 1/2$ , then the test based on  $(\mathcal{K}_t^{\mathrm{m},\star})_{t\geq 0}$  is consistent:  $\mathbb{P}_{H_1}(\tau < \infty) = 1$ . Further, the optimal growth rate achieved by  $\lambda_{\star}^{\mathrm{m}}$  in (13) satisfies:
$$
\mathbb {E} \left[ \log \left(1 + \lambda_ {\star} ^ {\mathrm {m}} f _ {\star} ^ {\mathrm {m}} (Z, W)\right) \right] \leq \left(\frac {1 6}{3} \cdot \left(\frac {1}{2} - R _ {\mathrm {m}} \left(g _ {\star}\right)\right) ^ {2} \wedge \left(\frac {1}{2} - R _ {\mathrm {m}} \left(g _ {\star}\right)\right)\right). \tag {15}
$$
(b) The growth rate of the oracle wealth process  $(\mathcal{K}_t^{s,\star})_{t\geq 0}$  satisfies:
$$
\lim  _ {t \rightarrow \infty} \inf  \left(\frac {1}{t} \log \mathcal {K} _ {t} ^ {\mathrm {s}, \star}\right) \stackrel {\text {a . s .}} {\geq} \frac {1}{4} \cdot \mathbb {E} [ W \cdot g _ {\star} (Z) ]. \tag {16}
$$
If  $\mathbb{E}\left[W\cdot g_{\star}(Z)\right] > 0$  then the test based on  $(\mathcal{K}_t^{\mathrm{s},\star})_{t\geq 0}$  is consistent:  $\mathbb{P}_{H_1}(\tau < \infty) = 1$ . Further, the optimal growth rate achieved by  $\lambda_{\star}^{\mathrm{s}}$  in (13) satisfies:
$$
\mathbb {E} \left[ \log \left(1 + \lambda_ {\star} ^ {\mathrm {s}} f _ {\star} ^ {\mathrm {s}} (Z, W)\right) \right] \leq \frac {1}{2} \cdot \mathbb {E} \left[ W \cdot g _ {\star} (Z) \right]. \tag {17}
$$
Theorem 1 precisely characterizes the properties of the oracle wealth processes and relates those to interpretable metrics of predictive performance. Further, the proof of Theorem 1 highlights a direct impact of the variance of the payoffs on the wealth growth rate, and hence the power of the resulting sequential tests (as the null is rejected once the wealth exceeds  $1 / \alpha$ ).
The second moment of the payoffs based on the misclassification risk (11a) is equal to one, resulting in a slow growth: the bound (14) is proportional to squared deviation of the misclassification risk from one half. The bound (15) shows that the growth rate with the ONS strategy matches, up to constants, that of the oracle betting fraction. Note that the second term in (15) characterizes the growth rate if  $R_{\mathrm{m}}(g_{\star}) < 5 / 16$  (low Bayes risk). In this regime, the growth rate of our test is at least  $\left(\frac{3}{16}\right)\cdot \left(\frac{1}{2} -R_{\mathrm{m}}(g_{\star})\right)$  which is close to the optimal rate. The second moment of the payoffs based on the squared risk is more insightful. First, we present a result for the case when the oracle predictor  $g_{\star}$  in (11b) is replaced by an arbitrary  $g\in \mathcal{G}$ . The proof is deferred to Appendix D.3.
Corollary 1. Consider an arbitrary  $g \in \mathcal{G}$  with nonnegative expected margin:  $\mathbb{E}\left[W \cdot g(Z)\right] \geq 0$ . Then the growth rate of the corresponding wealth process  $(\mathcal{K}_t^{\mathrm{s}})_{t \geq 0}$  satisfies:
$$
\begin{array}{l} \lim  _ {t \rightarrow \infty} \left(\frac {1}{t} \log \mathcal {K} _ {t} ^ {\mathrm {s}}\right) \geq \frac {1}{4} \left(\sup  _ {s \in [ 0, 1 ]} (1 - R _ {\mathrm {s}} (s g)) \wedge \mathbb {E} [ W \cdot g (Z) ]\right) (18a) \\ \geq \frac {1}{4} \left(\mathbb {E} [ W \cdot g (Z) ]\right) ^ {2}, (18b) \\ \end{array}
$$
and the optimal growth rate achieved by  $\lambda_{\star}^{\mathrm{s}}$  in (13) satisfies:
$$
\mathbb {E} \left[ \log \left(1 + \lambda_ {\star} ^ {\mathrm {s}} f ^ {\mathrm {s}} (Z, W)\right) \right] \leq \left(\frac {4}{3} \cdot \sup  _ {s \in [ 0, 1 ]} \left(1 - R _ {\mathrm {s}} (s g)\right)\right) \wedge \left(\frac {1}{2} \cdot \mathbb {E} \left[ W \cdot g (Z) \right]\right). \tag {19}
$$
Corollary 1 states that for an arbitrary  $g \in \mathcal{G}$ , the growth rate is lower bounded by the minimum of the expected margin and the (optimized) squared risk of such predictor. While the latter term is always smaller for the optimal  $g_{\star}$ , this may not hold for an arbitrary  $g \in \mathcal{G}$ . The lower bound (18b), which follows from Proposition 1, is always worse than that for  $g_{\star}$  (the expected margin is squared). The upper bound (19) shows that the growth rate with the ONS strategy matches, up to constants, that of the optimal constant betting fraction. Before presenting a practical sequential 2ST, we provide two important remarks that further contextualize the current work in the literature.
Remark 2. In practice, we learn a predictor sequentially and have to choose a learning algorithm. Note that (18a) suggests that direct margin maximization may hurt the power of the resulting 2ST: the squared risk is sensitive to miscalibrated and overconfident predictors. Kübler et al. [2022] made a similar conjecture in the context of batch two-sample testing. To optimize the power, the authors suggested minimizing the cross-entropy or the squared loss and related such approach to maximizing the signal-to-noise ratio, a heuristic approach that was proposed earlier by Sutherland et al.  $[2017]^3$ .
Remark 3. Suppose that  $g^{\mathrm{Bayes}} \in \mathcal{G}$  and consider the payoff function based on the squared risk (11b). At round  $t$ , the wealth of a player  $\mathcal{K}_{t-1}$  is multiplied by
$$
\begin{array}{l} 1 + \lambda_ {t} \cdot W _ {t} \cdot g ^ {\text {B a y e s}} (Z _ {t}) = (1 - \lambda_ {t}) \cdot 1 + \lambda_ {t} \cdot \left(1 + W _ {t} \cdot g ^ {\text {B a y e s}} (Z _ {t})\right) \\ = \left(1 - \lambda_ {t}\right) \cdot 1 + \lambda_ {t} \cdot \frac {\left(\eta \left(Z _ {t}\right)\right) ^ {\mathbb {1} \left\{W _ {t} = 1 \right\}} \left(1 - \eta \left(Z _ {t}\right)\right) ^ {\mathbb {1} \left\{W _ {t} = - 1 \right\}}}{\left(\frac {1}{2}\right) ^ {\mathbb {1} \left\{W _ {t} = 1 \right\}} \left(\frac {1}{2}\right) ^ {\mathbb {1} \left\{W _ {t} = - 1 \right\}}}, \tag {20} \\ \end{array}
$$