<figure><img src="image_1.png" /></figure>

HAL
open science

# Testing Identity of Distributions under Kolmogorov Distance in Polylogarithmic Space

Christian Janos Lebeda, Jakub Tětek

► To cite this version:

Christian Janos Lebeda, Jakub Tětek. Testing Identity of Distributions under Kolmogorov Distance in Polylogarithmic Space. SIAM Symposium on Simplicity in Algorithms (SOSA25), Jan 2025, New orleans, USA, United States. 10.1137/1.9781611978315.4 . hal-04895297

HAL Id: hal-04895297

https://inria.hal.science/hal-04895297v1

Submitted on 17 Jan 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Testing Identity of Distributions under Kolmogorov Distance in Polylogarithmic Space

Christian Janos Lebeda*

christian-janos.lebeda@inria.fr

Inria, University of Montpellier

Jakub Tětek†

j.tetek@gmail.com

INSAIT, Sofia University “St. Kliment Ohridski”

## Abstract

Suppose we have a sample from a distribution $D$ and we want to test whether $D = D^*$ for a fixed distribution $D^*$. Specifically, we want to reject with constant probability, if the distance of $D$ from $D^*$ is $\ge \varepsilon$ in a given metric. In the case of continuous distributions, this has been studied thoroughly in the statistics literature. Namely, for the well-studied Kolmogorov metric a test is known that uses the optimal $O(1/\varepsilon^2)$ samples.

However, this test naively uses also space $O(1/\varepsilon^2)$, and previous work improved this to $O(1/\varepsilon)$. In this paper, we show that much less space suffices – we give an algorithm that uses space $O(\log^4 \varepsilon^{-1})$ in the streaming setting while also using an asymptotically optimal number of samples. This is in contrast with the standard total variation distance on discrete distributions for which such space reduction is known to be impossible. Finally, we state 9 related open problems that we hope will spark interest in this and related problems.

## 1 Introduction

Testing hypotheses about continuous distributions is a fundamental topic in statistics, with applications in a wide range of fields of science. However, in theoretical computer science – and the area of distribution testing specifically – the focus has been mostly on discrete distributions. As such, there are many algorithmic questions regarding testing continuous distributions, which remain unexplored.

One of the most fundamental problems in distribution testing is the so-called *identity testing*. In this problem, we get a sample from a distribution $D$ and we want to know whether $D = D^*$ for a fixed distribution $D^*$. Namely, we want with probability $1 - \delta$ to accept if $D = D^*$ and reject if $D$ has distance $\ge \varepsilon$ from $D^*$ in some given metric. This question has been studied extensively in statistics. Indeed, the famed Kolmogorov-Smirnov test (see Section 2) solves exactly this problem under the metric that is today called the Kolmogorov (K) distance, which is defined as the $L_\infty$ distance of the cumulative distribution functions. This test is known to be asymptotically optimal, using $\Theta(\frac{\log 1/\delta}{\varepsilon^2})$ samples (see Section 4 for details).

However, the Kolmogorov-Smirnov test has relatively high space complexity. If we assume that we receive the samples one by one and we can only loop over the data once, it naively needs space $\Theta(\log(1/\delta)/\varepsilon^2)$ for storing all samples. This has been improved in previous work to space $\Theta(1/\varepsilon)$ using two different approaches by [9, 18]. We discuss their techniques further along with other related work in Section 4. In this paper, we show that one can do much better. Namely, we show that one only needs polylogarithmic space for identity testing under Kolmogorov distance, while still achieving asymptotically optimal sample complexity. Specifically, we give a simple algorithm such that the following holds:

**Theorem 3.1, restated.** There exists an algorithm that (i) has sample complexity $O(\log(1/\delta)/\varepsilon^2)$, (ii) has space complexity $O(\log^4 1/\varepsilon)$, and (iii) it is correct for testing identity for any two distributions$^1 D, D^*$ w.r.t. the Kolmogorov distance with probability at least $1 - \delta$ (with probability $1 - \delta$ it accepts if $D = D^*$ and rejects if $d_K(D, D^*) \ge \varepsilon$).

<footnote>*This work was carried out while this author was at the IT University of Copenhagen.</footnote>

<footnote>†This author was supported by the VILLUM Foundation grants 54451 and 16582. This research was partially funded from the Ministry of Education and Science of Bulgaria (support for INSAIT, part of the Bulgarian National Roadmap for Research Infrastructure). Part of this work was carried out while this author was at BARC, University of Copenhagen.</footnote>

<footnote n="1">¹It turns out we may assume the distributions are continuous without loss of generality. We do this throughout this paper, but our results also hold for non-continuous distributions. See the discussion in Section 2.</footnote>
Our result is in contrast with identity testing under the standard total variation distance on discrete distributions. There, one cannot asymptotically decrease the space complexity by more than a logarithmic factor without asymptotically increasing the sample complexity [11]. On the one hand, without space constraints, sample complexity $\Theta(\sqrt{n}/\varepsilon^2)$ is optimal [23] for $n$ being the support size of $D^*$. On the other hand, any algorithm that uses $s$ bits has to use $\Omega(\frac{n}{s\varepsilon^2})$ samples [11]. For details on this and other related work, see Section 4. For even more background, we refer the reader to the recent survey on statistical inference under space constraints [7].

It should be noted that the space complexity of our algorithm can be further decreased at the cost of increasing the sample complexity. In fact, when explaining below the intuition behind our algorithm, we describe a simpler approach that leads to a lower space complexity but suboptimal sample complexity. This way, one can obtain an algorithm with constant space complexity and sample complexity $O(\frac{\text{poly log}(1/\varepsilon)}{\varepsilon^2})$.

We hope that our approach will inspire further research into related topics. To this end, we state nine open problems in Section 5.

## 1.1 Our techniques

We now sketch our approach. We describe here a less technical version that adds a polylogarithmic factor to the sample complexity. In the actual proof, we take care to ensure we do not asymptotically increase the sample complexity.

The high-level idea is that depending on $D^*$, we divide the real line into (non-disjoint) buckets bases on dyadic intervals. We then prove that if $d_K(D, D^*) \ge \varepsilon$, then there has to be at least one of these buckets which has significantly different probabilities under the two distributions. We then estimate the probability of each bucket under the distribution $D$ and check whether it significantly differs from the probability under $D^*$, in which case we reject. If there is no such bucket, we accept.

The difficulty with this approach is that there will be more buckets than the amount of space we can use. Specifically, there are $\Theta(1/\varepsilon)$ buckets and we want an algorithm that uses only polylogarithmic space. This means that we cannot estimate the buckets' probabilities all at once using the same sample. Instead, we do it sequentially (first estimating the probability of some buckets, then of other buckets, and so on). The crux then lies in how to do this without increasing the sample complexity, since with this approach, we have to use fresh samples for estimating different buckets.

We get around this issue using the following idea: The lower probability a bucket has, the more such buckets there will be, but the fewer samples we need to estimate its probability to within a fixed additive error. We now describe this idea in more detail.

Suppose $d_K(D, D^*) \ge 10\varepsilon$. We divide the real line into buckets each having probability $2^{-j}$ under $D^*$ for $j = 1, \dots, \lfloor \lg 1/\varepsilon \rfloor$ as follows. For each $j$, we let $B_{1,j}$ be a bucket starting with $-\infty$ that has probability $2^{-j}$, then $B_{2,j}$ is an interval with probability $2^{-j}$ whose left endpoint is the right endpoint of $B_{1,j}$, and so on. We claim that there has to be a bucket $B_{i,j}$ such that $|P[D \in B_{i,j}] - P[D^* \in B_{i,j}]| \ge \frac{\varepsilon}{\lg 1/\varepsilon}$.

To this end, we consider a point $y$ such that $|P[D \le y] - P[D^* \le y]| \ge 10\varepsilon$ (note that such $y$ exists by the assumption that the K distance is $\ge 10\varepsilon$). We then argue that we can approximately write the interval $(-\infty, y]$ as a disjoint union of at most $\lfloor \lg 1/\varepsilon \rfloor$ of the buckets $B_{i,j}$. We look at the binary expansion of the value of $P[D^* \le y]$ and we consider the first $\lfloor \lg 1/\varepsilon \rfloor$ bits in order. If the $j$-th bit is set to 1, we add a bucket that has probability $2^{-j}$ in $D^*$ to the union, choosing the bucket whose left endpoint is equal to the right endpoint of the bucket added last. This way, we obtain a set of buckets with size $\le \lfloor \lg 1/\varepsilon \rfloor$ that approximately covers the interval $(-\infty, y]$. The remaining difference between the intervals is contained in a single bucket that has probability $\le \varepsilon$ under $D^*$.

Suppose for the sake of contradiction that the probability of each of the buckets under $D$ and $D^*$ differs by less than $\frac{\varepsilon}{\lg 1/\varepsilon}$. We then argue that by the triangle inequality, the probability of the interval $(-\infty, y]$ under the two distributions differ by less than $10\varepsilon$. This is a contradiction with our definition of $y$. This means that there has to exist $i, j$ such that $|P[D \in B_{i,j}] - P[D^* \in B_{i,j}]| \ge \frac{\varepsilon}{\lg 1/\varepsilon}$.

However, there are too many buckets for us to estimate all of their probabilities at once (in fact, there are $\Theta(1/\varepsilon)$ different buckets, which we cannot afford to store at once due to space constraints). However, we claim that our job is easier for lower-probability buckets. We need to estimate the probabilities to within additive error $\frac{\varepsilon}{\lg 1/\varepsilon}$. By a standard calculation of variance and using the Chebyshev inequality, if the bucket's probability is $p$, we need $O(p \cdot \log^2 \varepsilon^{-1}/\varepsilon^2)$ samples (for constant failure probability, which we can amplify). This is very convenient for us: there are $2^j$ buckets on level $j$ each with probability $2^{-j}$. This means that we can afford to estimate their
frequencies one by one using fresh samples each time for a total number of samples

$$2^j \cdot O(2^{-j} \cdot \log^2 \frac{\epsilon^{-1}}{\epsilon^{-2}}) = O\left(\frac{\log^2 \epsilon^{-1}}{\epsilon^2}\right).$$

We do this at once separately on each of the $O(\lg \epsilon^{-1})$ levels, for a logarithmic space complexity and sample complexity $O(\frac{\log^2 \epsilon^{-1}}{\epsilon^2})$ for constant failure probability. A more careful analysis can be used to shave off the logarithmic factors from the sample complexity at a polylogarithmic cost to the space complexity, thus obtaining at once polylogarithmic space complexity and asymptotically optimal sample complexity.

## 2 Preliminaries

**Notation and setup of the paper.** We write $D$ for the unknown distribution from which we draw i.i.d. samples, and we write $D^*$ for the fixed known distribution. The support for both $D$ and $D^*$ can be any totally ordered set $U$. For a distribution $D$, $D(S)$ denotes the probability of $S$ for $S$ being a measurable set. We abuse notation and write $P[D \le x]$ to denote $P_{X \sim D}[X \le x]$ for a value $x$. We denote the inverse of the CDF of $D^*$ as $q$, defined as $q_x = \sup\{y | P[D^* \le y] \le x\}$, where $q_0 = -\infty$ and $q_1 = \infty$ are special cases. We use $[k]$ for $k \in \mathbb{N}$ to denote $\{1, \dots, k\}$. We use $\mathbb{I}[\cdot]$ for a given condition to be the random event where the condition is satisfied. Finally, we write $\lg x$ for the base-2 logarithm of any $x \in \mathbb{R}^+$.

**Kolmogorov distance and Kolmogorov-Smirnov test.** Let us have two distributions $D_1, D_2$ over the same ordered set $U$. We define the Kolmogorov distance $d_K(D_1, D_2)$ as $\sup_{x \in U} |P_{X_1 \sim D_1}[X_1 \le x] - P_{X_2 \sim D_2}[X_2 \le x]|$. In other words, the Kolmogorov distance of two distributions is defined as the $L_\infty$ distance on their CDFs. The Kolmogorov-Smirnov statistic is the distance between the empirical CDF of a sample and the reference CDF. Given a sorted sample $(X_1, X_2, \dots, X_n)$ of $n$ data points drawn from $D$ the standard Kolmogorov-Smirnov test computes the KS statistic as $\max_i(\max(i/n - q_{X_i}, q_{X_i} - (i-1)/n))$. The null hypothesis where $D = D^*$ is rejected if the KS statistic is sufficiently high based on $n$ and accepted failure probability.

**Continuous vs. non-continuous distributions.** Throughout this paper, we assume that all distributions are continuous, that is, that any singleton event has probability zero. We claim that this is without loss of generality – if a distribution $D$ on the universe $U$ is not continuous, we may replace it with a distribution $D' = D \otimes \text{Uniform}([0, 1])$ on $U \times [0, 1]$, with lexicographic order. If we have sampling access to $D$, we may easily simulate samples from $D'$ and at the same time, the $K$ distance does not decrease (in fact, it stays the same) by performing this transformation.

**Chernoff bounds.** We use Chernoff bounds in the proofs for the correctness guarantees of our algorithm. Specifically, we rely on Chernoff bounds to bound the value of a binomial distribution. Here we list the specific bounds that are prerequisites for following the proofs. The forms of the bounds differ slightly from typical textbook presentations. We perform some simple calculations here to simplify the presentation of the proofs in Section 3.

**Fact 2.1.** Let $X$ be a random variable distributed as $\text{Bin}(n, p)$ and let $\mu = E[X] = np$. Then it holds that

$$ (2.1) \qquad P[X/n > p + \Delta] \le e^{-\Delta^2 n/(2p+\Delta)}. $$

Furthermore, for any $\Delta < \mu$ it holds that

$$ (2.2) \qquad P[X/n < p - \Delta] \le e^{-\Delta^2 n/(2p)}, $$

and

$$ (2.3) \qquad P[|X - \mu| > \Delta] \le 2e^{-\Delta^2/(3\mu)}. $$

*Proof.* Throughout this proof we let $\delta = \Delta/p$. We find the first bound by

$$ \begin{aligned} P[X/n > p + \Delta] &= P[X > \mu + n\Delta] = P[X > (1+\delta)\mu] \le \exp(-\delta^2\mu/(2+\delta)) \\ &= \exp(-(\Delta/p)^2np/(2+\Delta/p)) = \exp(-\Delta^2n/(2p+\Delta)), \end{aligned} $$

where the inequality is a common simpler variant of the standard Chernoff bound (see https://www.lkozma.net/inequalities_cheat_sheet/ineq.pdf).
The second bound follows from

$$P[X/n < p - \Delta] = P[X < \mu - n\Delta] = P[X < (1 - \delta)\mu] \le e^{-\delta^2\mu/2} = e^{-\Delta^2n/(2p)},$$

where the inequality is a standard Chernoff-Hoeffding bound [12, Theorem 1.1].

Finally, for the third bound we have that

$$P[|X - \mu| > \Delta] \le P[X < \mu - \Delta] + P[X > \mu + \Delta] = P[X < (1 - \Delta/\mu)\mu] + P[X > (1 + \Delta/\mu)\mu] \le 2e^{-\Delta^2/(3\mu)},$$

where the first inequality is a union bound and the second inequality follows from standard Chernoff-Hoeffding bounds [12, Theorem 1.1]. □

**Models of computation.** We consider the KS test in the one-pass streaming model. In this model, we receive the samples from $D$ one by one and access each sample only once. Alternatively, we could consider a model where the algorithm has oracle access to samples from $D$, and our goal is to satisfy a certain sampling budget and space constraint. The algorithm is equivalent in both models, but we present our work under the first model as it is more common in the computer science literature. We give our space complexity in the $w$-bit word RAM model as defined by [15] for $w$ large enough so that a single word can represent a sample from the distribution or a counter of size $O(1/\epsilon^2 + \log \delta^{-1})$. Each counter stored by our algorithm fits in a single word since all counts are at most this large. We do not consider the space requirements for representing $q$ or $D^*$. Our algorithm requires access to $q_{i2-j}$ for each $i \in [2^j]$ where $j = [\lg 1/\epsilon] + 2$. We assume that these $\Theta(1/\epsilon)$ entries of $q$ are either stored efficiently or can be computed when necessary from a compact representation of $D^*$.

## 3 Our algorithm

In this section, we present our algorithm and prove our main theorem, Theorem 3.1. Throughout the proof, we work with failure probability $\delta = 1/10$. This can be amplified by standard probability amplification to general $\delta$ as we discuss in the proof of Theorem 3.1.

Recall that we have two distributions $D, D^*$, we may sample from $D$ and we know $D^*$. We define a bucket as $B_{i,j} = (q_{i-1}2^{-j}, q_{i-1}2^{-j}]$, where we have $q_x = \sup\{y \mid P[D^* \le y] \le x\}$ with special cases $q_0 = -\infty$ and $q_1 = \infty$.

**Our algorithm.** We describe a subroutine for a fixed value of $j$. We then execute this subroutine for all $j \in [[\lg 1/\epsilon] + 2]$ in parallel (that is, we feed any sample as an input to all these subroutines).

For a given value $j$, we consider the first $\Theta(\log^3 1/\epsilon)$ buckets $B_{i,j}$ and we have a counter for each (we take fewer buckets if fewer remain). We then take $t = c \cdot \min(\frac{1}{\epsilon^2}, \frac{(\lg 1/\epsilon+3)^3}{2^j \epsilon^2})$ samples where $c$ is a sufficiently high constant. Based on them, we estimate the probability under $D$ of each $B_{i,j}$ that we are storing. If the estimated probability differs from the probability under $D^*$ (that is, $2^{-j}$) by more than $\Delta = \max(\frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon+3})/20$, we reject. We then take the next $\Theta(\log^3 1/\epsilon)$ buckets and repeat, until we have gone through all $2^j$ buckets $B_{.,j}$.

If none of the subroutines rejected, we accept.

Use probability amplification to amplify success probability to $1 - \delta$: execute this algorithm sequentially $\Theta(\log 1/\delta)$ times and return the majority answer.

**Intuition behind parameter choice.** A curious reader might ask why we choose the values of $t$ and $\Delta$ the way we do. The intuition behind our algorithm that we described above corresponds to choosing $t = \Theta(\frac{(\lg 1/\epsilon)^3}{2^j \epsilon^2})$ and $\Delta = \Theta(\epsilon/\log(1/\epsilon))$. Namely, we want to check whether the probability of a bucket is within $\Theta(\epsilon/\log(1/\epsilon))$ of $2^{-j}$ and we want to be correct with probability $1 - \Theta(\epsilon)$ so as to be able to union-bound over the $O(1/\epsilon)$ intervals. The number of samples this requires is equal to this choice of $t$, by Chernoff's inequality. The issue comes from the fact that for small values of $j$, the value of $t$ is greater than the total number of samples we have available, which is $\Theta(1/\epsilon^2)$.

A naive solution is to simply enforce that $t$ is never more than $1/\epsilon^2$. This is precisely what we choose to do. However, our estimates would then not be accurate enough. To this end, we relax the requirement for our
estimates for smaller values of $j$. First, we have to settle for a higher failure probability. This is not a large issue – we union bound the failure probability over different values of $j$, meaning that as long as the failure probability decreases sufficiently fast in $j$, the probabilities still add up to a constant.

Second, we also have to settle for lower accuracy – for example, for $j = 1$, we have $2^{-j} = 1/2$, in which case $1/\epsilon^2$ samples only gives us accuracy to within additive $\Theta(\epsilon)$, instead of the desired $\Theta(\epsilon/\log(1/\epsilon))$. In Lemma 3.1, we will thus prove a stronger claim which allows us to have lower accuracy for smaller values of $j$. Namely, for small values of $j$, we test whether the probability differs from $2^{-j}$ by $\epsilon/j^2$. There is no reason why use specifically $j^2$ – we could use any polynomial in $j$ or even an exponential with a sufficiently small base.

**Analyzing our algorithm.** Before we are ready to prove correctness of our algorithm, we prove the following lemma, which states that if indeed $d_K(D, D^*) \ge \epsilon$, then there has to be a bucket $B_{i,j}$ whose probability differs significantly under the two distributions.

**LEMMA 3.1.** Let us have two continuous distributions $D, D^*$ over a totally ordered set $U$. Suppose that $d_K(D, D^*) \ge \epsilon$. Then there exists $j \in [[\lg 1/\epsilon] + 2]$ and $i \in [2^j]$ such that $|D^*(B_{i,j}) - D(B_{i,j})| \ge 2\Delta = \max\left(\frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon + 3}\right)/10$.

*Proof.* Let $x \in [0, 1]$ be such that $|P[D \le q_x] - P[D^* \le q_x]| \ge \epsilon$. Note that such $x$ exists by the assumption $d_K(D, D^*) \ge \epsilon$. Our goal will be to approximately write the set $(-\infty, q_x]$ as a disjoint union of some of the buckets $B_{i,j}$. We then use this to show that if no such bucket exists, then it has to be the case that $|P[D \le q_x] - P[D^* \le q_x]| < \epsilon$, which would be a contradiction.

Let $b_1b_2\cdots$ be the binary expansion of $x$. We now define $x_{\ell} = b_1\cdots b_\ell$ and we let $\tilde{x} = x_{\lfloor \lg 1/\epsilon \rfloor + 2}$. Note that $x - \epsilon/4 \le \tilde{x} \le x$. This means that $|P[D^* \le \tilde{q}_x] - P[D^* \le q_x]| = x - \tilde{x} \le \epsilon/4$.

We use the binary encoding of $\tilde{x}$ to write the set $(-\infty, \tilde{q}_x]$ as a disjoint union of some of the buckets $B_{i,j}$. Namely, we define a set of indices $I$ such that $(-\infty, \tilde{q}_x] = \bigcup_{(i,j) \in I} B_{i,j}$ and such that this union is disjoint. We construct this set inductively. Namely, we define $I_0, \cdots, I_{\lfloor \lg 1/\epsilon \rfloor + 2}$ where for any $k$, $I_k$ satisfies that $(-\infty, q_{x:k}] = \bigcup_{(i,j) \in I_k} B_{i,j}$. First, we set $I_0 = \emptyset$. Suppose now that we have the set $I_k$; we inductively construct $I_{k+1}$. If $b_{k+1} = 0$ then $x_{k+1} = x_k$ and we may thus set $I_{k+1} = I_k$. If, on the other hand $b_{k+1} = 1$, then it holds

$$(-\infty, q_{x_{k+1}}] \setminus (-\infty, q_{x_k}] = (q_{x_k}, q_{x_{k+1}}] = B_{x_k 2^{k+1}+1, k+1},$$

meaning that we may set $I_{k+1} = I_k \cup \{(x_k 2^{k+1} + 1, k + 1)\}$. Finally, we define $I = I_{\lfloor \lg 1/\epsilon \rfloor + 2}$.

Assume now for the sake of contradiction that $|D^*(B_{i,j}) - D(B_{i,j})| < 2\Delta = \max(\frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon + 3})/10$ for all $B_{i,j}$ where $(i, j) \in I$. We bound

$$ \begin{aligned} |P[D \le q_x] - P[D^* \le q_x]| &= \left| \sum_{i,j \in I} D(B_{i,j}) + P[D \in (q_{\tilde{x}}, q_x]] - \sum_{i,j \in I} D^*(B_{i,j}) - P[D^* \in (q_{\tilde{x}}, q_x)] \right| \\ &\le \sum_{i,j \in I} |D(B_{i,j}) - D^*(B_{i,j})| + |P[D \in (q_{\tilde{x}}, q_x)] - P[D^* \in (q_{\tilde{x}}, q_x)]| \\ &< \sum_{j=1}^{\lfloor \lg 1/\epsilon \rfloor + 2} \max \left( \frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon + 3} \right) / 10 + |P[D \in (q_{\tilde{x}}, q_x)] - P[D^* \in (q_{\tilde{x}}, q_x)]| \\ &< \epsilon/2 + |P[D \in (q_{\tilde{x}}, q_x)] - P[D^* \in (q_{\tilde{x}}, q_x)]|, \end{aligned} $$

where we have used the calculation

$$\sum_{j=1}^{\lfloor \lg 1/\epsilon \rfloor + 2} \max \left( \frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon + 3} \right) < \sum_{j=1}^{\lfloor \lg 1/\epsilon \rfloor + 2} \left( \frac{\epsilon}{j^2} + \frac{\epsilon}{\lg 1/\epsilon + 3} \right) < 1.65 \cdot \epsilon + \epsilon < 5 \cdot \epsilon.$$

Therefore, if the left-hand side is $\ge \epsilon$ as we assume, it has to be the case that $|P[D \in (q_{\tilde{x}}, q_x)] - P[D^* \in (q_{\tilde{x}}, q_x)]| > \epsilon/2$. As we have noted, it holds that $P[D^* \in (q_{\tilde{x}}, q_x)] \le \epsilon/4$, meaning that it has to be the case that $P[D \in (q_{\tilde{x}}, q_x)] > \epsilon/2$. But this event is a subset of the event $D \in B_{\tilde{x}2^{j+1},j}$ for $j = \lfloor \lg 1/\epsilon \rfloor + 2$. The probability of outputting a value in this bucket under $D^*$ is $2^{-\lfloor \lg 1/\epsilon \rfloor + 2} \le \epsilon/4$, so the difference of the probability under the two distributions is $> \epsilon/4$, which is $> 2\Delta$. This is a contradiction, concluding the proof. $\square$
Next, we bound the failure probability of our algorithm. We separately consider the cases where $D$ is either equal to or $\epsilon$-distinct from $D^*$. We bound the failure probability for a single execution of our algorithm by $1/10$ in each case. We then use probability amplification to achieve failure probability at most $\delta$.

**LEMMA 3.2.** *Suppose that $d_K(D, D^*) \ge \epsilon$. Then our algorithm, without performing probability amplification, accepts with probability at most $1/10$.*

*Proof.* By Lemma 3.1, there exists a bucket $B_{i,j}$ such that $|D(B_{i,j}) - D^*(B_{i,j})| = |D(B_{i,j}) - 2^{-j}| \ge 2\Delta = \max(\frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon+3})/10$. The algorithm estimates the probability under $D$ of this bucket using $t = c \cdot \min(\frac{1}{\epsilon^2}, \frac{(\lg 1/\epsilon+3)^3}{2^j \epsilon^2})$ samples; let $Z_{i,j}$ be this estimate. The algorithm can only accept if $|Z_{i,j} - 2^j| \le \Delta$. We bound this probability.

We start with the case $D(B_{i,j}) \ge 2^{-j} + 2\Delta$. In this case, we prove that $P[Z_{i,j} < 2^{-j} + \Delta] \le 1/10$. In general, the probability that a binomial distribution $Bin(n, p)$ is below a threshold for a fixed $n$ is a decreasing function of $p$. This means that the probability $P[Z_{i,j} < 2^{-j} + \Delta]$ is decreasing in $D(B_{i,j})$. As such we may assume that $D(B_{i,j}) = 2^{-j} + 2\Delta$. This allows us to use the Chernoff bound (see Equation (2.2)) to bound:

$$P[Z_{i,j} < 2^{-j} + \Delta] \le \exp\left(-\frac{t\Delta^2}{2(2^{-j} + 2\Delta)}\right) \le \exp\left(-\frac{t\Delta^2}{4 \cdot 2^{-j}}\right),$$

where the last inequality uses that $2^{-j} \ge 2^{-\lfloor \lg 1/\epsilon \rfloor - 2} \ge \epsilon/8$ whereas $\Delta \le \epsilon/20$, meaning that $2^{-j} + 2\Delta \le 2 \cdot 2^{-j}$. A similar argument can be used in the case $D(B_{i,j}) \le 2^{-j} - 2\Delta$ to give the exact same upper bound. Similarly to the above, we may assume $D(B_{i,j}) = 2^{-j} - 2\Delta$ because we bound $P[Z_{i,j} > 2^{-j} - \Delta]$ which is increasing in $D(B_{i,j})$. In that case, we have $D(B_{i,j}) \ge \epsilon/8 - 2 \cdot \epsilon/20 = \epsilon/40$. This means that in this case, we have $\Delta/D(B_{i,j}) \le 2$. This allows us to again use the Chernoff bound (Equation (2.1)).

$$P[Z_{i,j} > 2^{-j} - \Delta] \le \exp\left(-\frac{t\Delta^2}{2 \cdot D(B_{i,j}) + \Delta}\right) \le \exp\left(-\frac{t\Delta^2}{4(2^{-j} - 2\Delta)}\right) < \exp\left(-\frac{t\Delta^2}{4 \cdot 2^{-j}}\right).$$

It remains to argue that this is $\le 1/10$. We consider separately the two branches of the min in $t$. First, we consider when $t = c/\epsilon^2$. In this case, we substitute and bound

$$\exp\left(-\frac{t\Delta^2}{4 \cdot 2^{-j}}\right) \le \exp\left(-\frac{c}{\epsilon^2} \cdot \frac{\epsilon^2}{400j^4} \cdot \frac{1}{4 \cdot 2^{-j}}\right) = \exp\left(-\frac{c}{1600j^4 2^{-j}}\right) < 0.1,$$

where the last inequality holds for a large enough value of $c$. Similarly, if $t = c \cdot \frac{(\lg 1/\epsilon+3)^3}{2^j \epsilon^2}$, we may bound

$$\exp\left(-\frac{t\Delta^2}{4 \cdot 2^{-j}}\right) \le \exp\left(-c \cdot \frac{(\lg 1/\epsilon + 3)^3}{2^j \epsilon^2} \cdot \left(\frac{\epsilon}{20(\lg 1/\epsilon + 3)}\right)^2 \cdot \frac{1}{4 \cdot 2^{-j}}\right) \le \exp\left(-\frac{c(\lg 1/\epsilon + 3)}{1600}\right) < 0.1,$$

where the last inequality again holds for $c$ large enough. □

**LEMMA 3.3.** *Suppose that $D = D^*$. Then our algorithm, without performing probability amplification, rejects with probability at most $1/10$.*

*Proof.* The algorithm draws $t = c \cdot \min(1/\epsilon^2, (\lg 1/\epsilon + 3)^3/(2^j \epsilon^2))$ samples to estimate the probability $D(B_{i,j})$, for $c$ being a sufficiently large constant that consider later. Let $X_{i,j}$ denote the random variable counting the number of these $t$ samples in the interval $B_{i,j}$. Our algorithm rejects only if for at least one bucket the event $|X_{i,j} - t/2^j| \ge t\Delta = t \cdot \max(\frac{\epsilon}{j^2}, \frac{\epsilon}{\lg 1/\epsilon+3})/20$ occurs.

We define $I = \{i, j | j \in [\lfloor \lg 1/\epsilon \rfloor + 2] \wedge i \in [2^j]\}$ and we define $I_1$ as the subset of $(i, j) \in I$ where $\frac{1}{\epsilon^2} \le \frac{(\lg 1/\epsilon+3)^3}{2^j \epsilon^2}$ and $I_2$ the remaining elements of $I$. That is, $I_1$ corresponds to the indices where the first branch of the min in $t$ is smaller, whereas the second branch is smaller in $I_2$. Let $Y_{i,j} = \mathbb{I}[|X_{i,j} - t/2^j| \ge t\Delta]$ denote the event where we reject based on bucket $B_{i,j}$. We use a union bound for the probability of any $Y_{i,j}$ occurring.

$$P\left[\bigcup_{i,j \in I} Y_{i,j}\right] \le \sum_{i,j \in I} P[Y_{i,j}] = \sum_{i,j \in I_1} P[Y_{i,j}] + \sum_{i,j \in I_2} P[Y_{i,j}].$$
The random variable $X_{i,j}$ follows a binomial distribution with expected value of $\mu = t/2^j$. Using a standard Chernoff bound we have that $P[|X_{i,j} - t/2^j| \ge \delta] \le 2e^{-\delta^2/(3\mu)}$ (see Equation (2.3)).

We first consider the case where $t = c/\varepsilon^2$, corresponding to the indices in $I_1$. We bound the probability of rejecting due to bucket $B_{i,j}$ as

$$P\left[\left|X_{i,j} - t/2^j\right| \ge t \cdot \max\left(\frac{\varepsilon}{j^2}, \frac{\varepsilon}{\lg 1/\varepsilon + 3}\right)/20\right] \le P\left[\left|X_{i,j} - t/2^j\right| \ge \frac{t \cdot \varepsilon}{20j^2}\right] \\ \le 2 \exp\left(-\left(\frac{t \cdot \varepsilon}{20j^2}\right)^2/(3\mu)\right) = 2 \exp\left(-\left(\frac{c}{20j^2\varepsilon}\right)^2 \cdot \frac{\varepsilon^2 2^j}{3c}\right) \le 2 \exp\left(-\frac{200 \cdot 2^j}{j^4}\right),$$

where the last inequality holds for $c$ large enough.

There are $2^j$ buckets for each value of $j \in [[\lg 1/\varepsilon] + 2]$. It follows from a union bound that the probability of rejecting any of the buckets with $t = c/\varepsilon^2$ samples is upper bounded by

$$\sum_{i,j \in I_1} P[Y_{i,j}] \le \sum_{j=1}^{[[\lg 1/\varepsilon]+2]} 2^j 2 \exp\left(-\frac{200 \cdot 2^j}{j^4}\right) < \sum_{j=1}^{\infty} 2^j 2 \exp\left(-\frac{200 \cdot 2^j}{j^4}\right) < 0.05.$$

Next we consider the case where $t = \frac{c(\lg 1/\varepsilon + 3)^3}{2^j \varepsilon^2}$, corresponding to $I_2$. We bound the probability of rejecting based on bucket $B_{i,j}$ as

$$P\left[\left|X_{i,j} - t/2^j\right| \ge t \cdot \max\left(\frac{\varepsilon}{j^2}, \frac{\varepsilon}{\lg 1/\varepsilon + 3}\right)/20\right] \le P\left[\left|X_{i,j} - t/2^j\right| \ge \frac{t \cdot \varepsilon}{20(\lg 1/\varepsilon + 3)}\right] \\ \le 2e^{-(\frac{t \cdot \varepsilon}{20(\lg 1/\varepsilon + 3)})^2/(3\mu)} = 2e^{-(\frac{c(\lg 1/\varepsilon + 3)^3}{20^2 \cdot 3 \cdot (\lg 1/\varepsilon + 3)^2})^2 t/3} = 2e^{-\frac{c(\lg 1/\varepsilon + 3)^3}{20^2 \cdot 3 \cdot (\lg 1/\varepsilon + 3)^2}} \le 2e^{-2(\lg 1/\varepsilon + 3)} \le \varepsilon/e^6,$

where the inequality second to last holds for $c$ large enough.

The total number of buckets is bounded by $\sum_{j=1}^{[[\lg 1/\varepsilon]+2]} 2^j < 2^{\lg 1/\varepsilon + 4} = 16/\varepsilon$. As such, using a union bound we have that

$$\sum_{i,j \in I_2} P[Y_{i,j}] < 16/\varepsilon \cdot \varepsilon/e^6 < 0.05.$$

□

We are now ready to state the theorem, which summarizes the properties of our algorithm.

**THEOREM 3.1.** There exists an algorithm that (i) has sample complexity $O(\log(1/\delta)/\varepsilon^2)$, (ii) has space complexity $O(\log^4 1/\varepsilon)$, and (iii) it is correct for testing identity for any two distributions $D, D^*$ w.r.t. the Kolmogorov distance with probability at least $1 - \delta$ (with probability $1 - \delta$ it accepts if $D = D^*$ and rejects if $d_K(D, D^*) \ge \varepsilon$).

*Proof.* The space complexity is clearly as claimed: each subroutine uses space $O(\log^3 1/\varepsilon)$ and we execute $[\lg 1/\varepsilon] + 2$ subroutines at once. The probability amplification does not increase space complexity as it only needs one additional counter for storing how many of the executions accepted. Our algorithm, without performing probability amplification, is correct with probability 9/10 by Lemma 3.2 and 3.3. This is amplified to $1 - \delta$.

It remains to argue the sample complexity. We argue that without probability amplification, it is $O(1/\varepsilon^2)$. The claim then follows since probability amplification adds a factor $\log 1/\delta$, implying the sample complexity is as claimed. We are executing the subroutines in parallel, meaning that it suffices to argue that each subroutine uses $O(1/\varepsilon^2)$ samples. The number of buckets for a fixed value of $j$ is $2^j$ and they are processed in batches of size $O(\log^3 1/\varepsilon)$. This means that the complexity of a subroutine is

$$\left\lfloor \frac{2^j}{\log^3 1/\varepsilon} \right\rfloor \cdot c \cdot \min \left( \frac{1}{\varepsilon^2}, \frac{(\lg 1/\varepsilon + 3)^3}{2^j \varepsilon^2} \right) = O\left( \frac{1}{\varepsilon^2} \right),$$

where the equality can be seen by a simple calculation if we consider separately the cases $\frac{2^j}{\log^3 1/\varepsilon} \le 1$ and $\frac{2^j}{\log^3 1/\varepsilon} > 1$. □
## 4 Related work

Apart from the papers referenced below, we refer the interested reader to the recent survey on statistical inference under memory constraints [7].

**Statistics literature.** In the statistical literature, the problem of identity testing has been studied since the 1930s when Kolmogorov and Smirnov developed their test [22, 17]. It is easy to see that this test is optimal up to constant factors: On one hand, the sample complexity of $O(\log(1/\delta)/\varepsilon^2)$ immediately follows from the Dvoretzky-Kiefer-Wolfowitz inequality [13]. On the other hand, it is well-known that one needs $\Omega(\log(1/\delta)/\varepsilon^2)$ samples to distinguish between Bernoulli distributions with parameter $1/2$ and $1/2 + \varepsilon$.<fnref n="2" /> But the Kolmogorov-Smirnov test can be used to distinguish between these two distributions<fnref n="3" />, so the sample complexity of the Kolmogorov-Smirnov test is optimal.

Many generalizations and other tests have been developed in the literature. This includes the Cramér-von Mises test [10, 24] or the Anderson-Darling test [3] which both put more weight on the tails of the distribution or the multivariate version of the Kolmogorov-Smirnov test [16]. We refer the reader wanting to know more about this area to the chapter on goodness of fit in the book [19].

**Applied work on small-memory Kolmogorov-Smirnov test.** It has been studied how to estimate the Kolmogorov-Smirnov statistic in streams in small amount of memory. The estimate can then be used to accept or reject the hypothesis similar to the classical KS test. This approach differs from our technique in that we directly reject or accept the hypothesis without computing an estimate of the KS statistic. We discuss here three different techniques for estimating the KS statistic and argue why each requires $\Omega(1/\varepsilon)$ space.

An estimator with error at most $3\varepsilon$ based on approximate quantiles was presented by [18]. Their technique relies on any sketch data structure that returns a data point from a stream with length $n$ with rank error at most $\varepsilon n$. They extract from this sketch a subset of the stream of size at least $1/(2\varepsilon)$. They use this subset to estimate the KS statistic with error at most $2\varepsilon$. As such they must use space $\Omega(1/\varepsilon)$ even ignoring any auxiliary space required to maintain such a sketch.

The problem has also been studied in the applied literature by [9] in a setting where they want to efficiently estimate the KS statistic at any point in the stream. They store $m$ non-overlapping buckets each with probability $1/m$ under the reference distribution $D^*$. Since they are repeatably estimating the KS statistic they use a greedy heuristic to update the estimate in time $O(\log(m))$ after observing each data point. Their data structure can be easily used to estimate the KS statistic with error $\le 1/m$ in time $O(m)$. As such they need $\Theta(1/\varepsilon)$ buckets to estimate the KS statistic with error $\varepsilon$. We also use $\Theta(1/\varepsilon)$ buckets based on the CDF on $D^*$. However, we only need to store a small subset of these buckets at any point since our technique relies on estimating the probability for individual buckets under $D$ rather than the full CDF.

Lastly, an estimator based on chunking and averaging was presented by [20]. They split the stream into chunks of length $J$. They compute the KS statistic on each chunk and store a running average. They show that the running average approaches the expected value in the limit. The value of $J$ should therefore be chosen sufficiently high to ensure that the expected value of the test is close to the actual Kolmogorov distance. We have that $J = \Omega(1/\varepsilon)$ since changing a single data point in a sample of length $J$ can change the KS statistic by $1/J$.

**Discrete distributions.** We now discuss identity testing for discrete distributions (under the standard total variation distance). This problem has also been studied in statistics, but the tests have suboptimal dependency on the support size, see the review by Balakrishnan and Wasserman [4] for a detailed historical background. The optimal complexity in terms of the support size was given by [5] and this was later improved to also be optimal in terms of $\varepsilon$ by [23]. What is interesting to us is that this problem has also been studied under various constraints such as privacy constraints (see [1] and references within) or communication constraints [11, 2]. However, to us the most interesting is the study of identity testing under space constraints.

The reduction in [14] implies that any result for the special case of uniformity testing also extends to identity testing. Diakonikolas et al. [11] shows an algorithm with space $s$ and sample complexity $O(\frac{n \log n}{s \varepsilon})$ and they show a lower-bound which is near-matching in terms of the dependency on $n$ and $s$. They also show a lower-bound which matches up to a constant factor for $s$ not being too small. The upper-bound was later simplified by Canonne and

<footnote n="2">²Specifically, the total variation distance of $Bin(m, 1/2)$, $Bin(m, 1/2 + \varepsilon)$ is $TV = O(\varepsilon\sqrt{m})$ [21, formula 15], meaning that one has to set $m = \Omega(1/\varepsilon^2)$ to make the distance constant. (Note that the success probability is $\le 1 - TV$.) A more detailed computation shows optimality also in terms of $\delta$.</footnote>

<footnote n="3">³We can add a value drawn from e.g. Uniform([0, 1/2]) to the Bernoulli samples to obtain samples following continuous distributions. The distributions are $\varepsilon$-distinct as the probabilities of outputting a value $\le 1/2$ clearly differ by $\varepsilon$.</footnote>
Lyu [8]. In the setting where the number of samples available is unlimited, Berg, Ordentlich, and Shayevitz [6] study the necessary state of a finite state machine that tests uniformity.

# 5 Open problems

Many interesting problems remain open in bounded-memory algorithms for distribution testing of non-discrete distributions. We now describe some of them.

**Testing identity with sampling access to two distributions.** Suppose that instead of knowing one of the two distributions in question, we only have sampling access to both. This corresponds to the two-sample KS test in the statistics literature. Is it possible to solve this problem in polylogarithmic space as well?

**Improving the number of samples used.** Our result ignored the constant in the sample complexity. Suppose that the KS test uses $S_{KS}$ samples for a given level of $\varepsilon$. Is there an algorithm that uses $(1 + \gamma)S_{KS}$ samples and uses memory $O(\log^c \varepsilon^{-1}/\gamma^c)$ for some constant $c$? If not, is there at least for each $\gamma > 0$ an algorithm with space complexity $O(\log^c \varepsilon^{-1})$.

**Approximating the KS statistic in $o(1/\varepsilon)$ space.** It would be of great practical interest if a streaming algorithm existed for approximating the KS statistic in space $o(1/\varepsilon)$ (space $O(1/\varepsilon)$ can be achieved using buckets as discussed in Section 4). Our algorithm can be modified to give an approximation up to a factor of $O(\log \varepsilon^{-1})$. Can better approximation be achieved in polylogarithmic space?

**Multi-dimensional distributions.** Generalizations of the $K$ distance exist that are defined for multi-dimensional distributions. Are there efficient streaming algorithms for identity testing also in this case?

**Testing relationships between multiple distributions.** Suppose we have sampling access to a distribution on $\mathbb{R}^2$. Give a streaming algorithm for testing whether these two coordinates are independent. Does the second coordinate stochastically dominate the first? Are the coordinates positively associated?

**Tests that are more efficient at the tails.** Design a space-efficient algorithm for identity testing with respect to some distance that allows for distinguishing smaller differences on the tails. In the statistics literature, the Anderson-Darling test [3] or the Cramér-von Mises test [10, 24] solves this problem. Is it possible to get a more space-efficient algorithm that approximately implements either of these two tests?

**Improve the space complexity.** The exponent in our algorithm is higher than one would perhaps hope. Is this inherent to the problem or can this be improved? Lower bounds would be especially interesting. It should be noted that in the lower bound, one will have to somehow use the fact that the algorithm has optimal sample complexity – as we noted in the introduction, it is possible to achieve constant space complexity at the cost of slightly higher sample complexity.

**Extend the results to tolerant distribution testing.** For identity testing, in standard distribution testing, we ought to accept if the distributions are equal and reject if their Kolmogorov distance is $\ge \varepsilon$. In tolerant distribution testing, one ought to accept if the distance is $< \varepsilon_1$ and reject if it is $\ge \varepsilon_2$. Many results are significantly more difficult in this setting than with standard distribution testing. Is this also the case for identity testing w.r.t. the Kolmogorov distance in the streaming setting?

**Distributed setting.** Suppose we are in the following setting, instead of the streaming setting. We have multiple machines with each storing part of the data. We want to test identity or any of the problems from the above open problems. How do we do this while communicating as few bits as possible between the machines?

# Acknowledgments

Lebeda carried out parts of this work at the IT University of Copenhagen. The authors would like to thank Bernhard Haeupler for helping improve the presentation of this paper. We thank Gautam Kamath for helpful comments on terminology. Finally, we thank anonymous reviewers for suggestions and comments that helped improve the paper.

# References

[1] Jayadev Acharya, Clément L Canonne, Cody Freitag, Ziteng Sun, and Himanshu Tyagi. Inference under information constraints iii: Local privacy constraints. *IEEE Journal on Selected Areas in Information Theory*, 2(1):253–267, 2021.

[2] Jayadev Acharya, Clément L Canonne, Yuhan Liu, Ziteng Sun, and Himanshu Tyagi. Interactive inference under information constraints. *IEEE Transactions on Information Theory*, 68(1):502–516, 2021.
[3] Theodore W Anderson and Donald A Darling. A test of goodness of fit. *Journal of the American statistical association*, 49(268):765-769, 1954.

[4] Sivaraman Balakrishnan and Larry Wasserman. Hypothesis testing for high-dimensional multinomials: A selective review. *The Annals of Applied Statistics*, 12(2):727–749, 2018. doi: 10.1214/18-AOAS1155SF. URL https://doi.org/10.1214/18-AOAS1155SF.

[5] Tugkan Batu, Eldar Fischer, Lance Fortnow, Ravi Kumar, Ronitt Rubinfeld, and Patrick White. Testing random variables for independence and identity. In *Proceedings 42nd IEEE Symposium on Foundations of Computer Science*, pages 442–451. IEEE, 2001.

[6] Tomer Berg, Or Ordentlich, and Ofer Shayevitz. On the memory complexity of uniformity testing. In *Conference on Learning Theory*, pages 3506–3523. PMLR, 2022.

[7] Tomer Berg, Or Ordentlich, and Ofer Shayevitz. Statistical inference with limited memory: A survey. *arXiv preprint arXiv:2312.15225*, 2023.

[8] Clément L Canonne and Hongyi Lyu. Uniformity testing in the shuffle model: Simpler, better, faster. In *Symposium on Simplicity in Algorithms (SOSA)*, pages 182–202. SIAM, 2022.

[9] Douglas O Cardoso and Thalis D Galeno. Online evaluation of the kolmogorov-smirnov test on arbitrarily large samples. *Journal of Computational Science*, 67:101959, 2023.

[10] Harald Cramér. On the composition of elementary errors: First paper: Mathematical deductions. *Scandinavian Actuarial Journal*, 1928(1):13–74, 1928.

[11] Ilias Diakonikolas, Themis Gouleakis, Daniel M Kane, and Sankeerth Rao. Communication and memory efficient testing of discrete distributions. In *Conference on Learning Theory*, pages 1070–1106. PMLR, 2019.

[12] Devdatt P. Dubhashi and Alessandro Panconesi. *Concentration of Measure for the Analysis of Randomized Algorithms*. Cambridge University Press, 2009.

[13] Aryeh Dvoretzky, Jack Kiefer, and Jacob Wolfowitz. Asymptotic minimax character of the sample distribution function and of the classical multinomial estimator. *The Annals of Mathematical Statistics*, pages 642–669, 1956.

[14] Oded Goldreich. The uniform distribution is complete with respect to testing identity to a fixed distribution. In *Electronic Colloquium on Computational Complexity (ECCC)*, volume 23, page 1, 2016.

[15] Torben Hagerup. Sorting and searching on the word RAM. In *STACS*, volume 1373 of *Lecture Notes in Computer Science*, pages 366–398. Springer, 1998. doi: 10.1007/BFb0028575.

[16] Ana Justel, Daniel Peña, and Rubén Zamar. A multivariate kolmogorov-smirnov test of goodness of fit. *Statistics & probability letters*, 35(3):251–259, 1997.

[17] Andrey Kolmogorov. Sulla determinazione empirica di una legge didistribuzione. *Giorn Dell'inst Ital Degli Att*, 4:89-91, 1933.

[18] Ashwin Lall. Data streaming algorithms for the kolmogorov-smirnov test. In *2015 IEEE International Conference on Big Data (Big Data)*, pages 95–104, 2015. doi: 10.1109/BigData.2015.7363746.

[19] Erich Leo Lehmann, Joseph P Romano, and George Casella. *Testing statistical hypotheses*, volume 3. Springer, 1986.

[20] Hien Duy Nguyen. A stream-suitable kolmogorov-smirnov-type test for big data analysis, 2017. URL https://arxiv.org/abs/1704.03721.

[21] Bero Roos. Binomial approximation to the poisson binomial distribution: The krawtchouk expansion. *Theory of Probability & Its Applications*, 45(2):258–272, 2001.
[22] Nikolai V Smirnov. On the estimation of the discrepancy between empirical curves of distribution for two independent samples. *Bull. Math. Univ. Moscou*, 2(2):3-14, 1939.

[23] Gregory Valiant and Paul Valiant. An automatic inequality prover and instance optimal identity testing. *SIAM Journal on Computing*, 46(1):429-455, 2017.

[24] Richard Edler von Mises. *Wahrscheinlichkeit, Statistik und Wahrheit*. Verlag von Julius Springer, Wien, 1928.
doi: 10.1007/978-3-662-36230-3. [Probability, Statistics and Truth].