# On Wasserstein Two-Sample Testing and Related Families of Nonparametric Tests

^{2}

^{3}

^{1}

^{*}

Next Article in Journal

Previous Article in Journal

Previous Article in Special Issue

Previous Article in Special Issue

Department of Mathematics, Brown University, Providence, RI 02912, USA

Laboratory of Statistics, CREST, ENSAE, Université Paris-Saclay, Malakoff 92240, France

Departments of Statistics and Computer Science, University of California, Berkeley, CA 94703, USA

Author to whom correspondence should be addressed.

Received: 28 May 2016 / Accepted: 26 December 2016 / Published: 26 January 2017

(This article belongs to the Special Issue Statistical Significance and the Logic of Hypothesis Testing)

Nonparametric two-sample or homogeneity testing is a decision theoretic problem that involves identifying differences between two random variables without making parametric assumptions about their underlying distributions. The literature is old and rich, with a wide variety of statistics having being designed and analyzed, both for the unidimensional and the multivariate setting. In this short survey, we focus on test statistics that involve the Wasserstein distance. Using an entropic smoothing of the Wasserstein distance, we connect these to very different tests including multivariate methods involving energy statistics and kernel based maximum mean discrepancy and univariate methods like the Kolmogorov–Smirnov test, probability or quantile (PP/QQ) plots and receiver operating characteristic or ordinal dominance (ROC/ODC) curves. Some observations are implicit in the literature, while others seem to have not been noticed thus far. Given nonparametric two-sample testing’s classical and continued importance, we aim to provide useful connections for theorists and practitioners familiar with one subset of methods but not others.

Nonparametric two-sample testing (or homogeneity testing) deals with detecting differences between two d-dimensional distributions, given samples from both, without making any parametric distributional assumptions. The popular tests for $d=1$ are rather different from those for $d>1$, and our interest is in tying together different tests used in both settings. There is massive literature on the two-sample problem, having been formally studied for nearly a century, and there is no way we can cover the breadth of this huge and historic body of work. Our aim is much more restricted—we wish to study this problem through the eyes of the versatile Wasserstein distance. We wish to form connections between several seemingly distinct families of such tests, both intuitively and formally, in the hope of informing both practitioners and theorists who may have familiarity with some sets of tests, but not others. We will also only introduce related work that has a direct relationship with this paper.

There are also a large number of tests for parametric two-sample testing (assuming a form for underlying distributions, like Gaussianity), and others for testing only differences in mean of distributions (like Hotelling’s t-test, Wilcoxon’s signed rank test, Mood’s median test). Our focus will be different from these—in this paper, we will restrict our attention only to nonparametric tests for testing differences in distributions, i.e., differences in any moment of distributions that may not have a known parametric form.

Our paper started as an attempt to understand testing with the Wasserstein distance (also called earth-mover’s distance or transportation distance). The main prior work in this area involved studying the “trimmed” comparison of distributions by [1,2] with applications to biostatistics, specifically population bioequivalence, and later by [3,4]. Apart from two-sample testing, the study of univariate goodness-of-fit testing (or one-sample testing) was undertaken in [5,6,7], and summarized exhaustively in [8]. There are other semiparametric works specific to goodness-of-fit testing for location-scale families that we do not mention here, since they diverge from our interest in fully nonparametric two-sample testing for generic distributions.

In this survey-style paper, we uncover an interesting relationship between the multivariate Wasserstein test and the (Euclidean) Energy distance test, also called the Cramer test, proposed independently by [9,10]. This proceeds through the construction of a smoothed Wasserstein distance, by adding an entropic penalty/regularization—varying the weight of the regularization interpolates between the Wasserstein distance at one extreme and the Energy distance at the other extreme. Due to the relationship between distances and kernels, we will also establish connections to the kernel-based multivariate test by [11] called the Maximum Mean Discrepancy (MMD).

We summarize connections between the univariate Wasserstein test and popular univariate data analysis tools like quantile–quantile (QQ) plots and the Kolmogorov–Smirnov test. Finally, the desire to design a univariate distribution-free Wasserstein test will lead us to the formal study of Receiver Operating Characteristic (ROC) and Ordinal Dominance (ODC) curves, relating to work by [12].

While we connect a wide variety of popular and seemingly disparate families of tests, there are still further classes of tests that we do not have space to discuss. Some examples of tests quite different from the ones studied here include rank based tests as covered by the excellent book [13], and graphical tests that include spanning tree methods by [14] (generalizing the runs test by [15]), nearest-neighbor based tests by [16,17], and the cross-match tests by [18]. The book by [19] is also a useful reference.

The rest of this paper proceeds as follows. In Section 2, we formally present the notation and setup of nonparametric two-sample testing, as well as briefly introduce three different ways of comparing distributions—using cumulative distribution functions (CDFs), quantile functions (QFs) and characteristic functions (CFs). The main contribution of this paper is Section 3, where we introduce the entropy-smoothed Wasserstein distance, and we form a novel connection between the multivariate Wasserstein distance to the multivariate Energy Distance, and to the kernel MMD. In Section 4, we discuss the relation between the univariate Wasserstein two-sample test to PP and QQ plots/tests, including the popular Kolmogorov–Smirnov test. In Section 6, we run some simulations to compare the different classes of tests discussed. Lastly, in Section 5, we will design a univariate Wasserstein test statistic that is also “distribution-free” unlike its classical counterpart, providing a careful and rigorous analysis of its limiting distribution by connecting it to ROC/ODC curves. In summary, Section 3, Section 4 and Section 5, respectively, discuss the following connections:

$$\mathrm{Wasserstein}\stackrel{\mathrm{entropic}\phantom{\rule{4.pt}{0ex}}\mathrm{smoothing}}{\to}\text{EnergyDistance}(\mathrm{ED})\stackrel{\mathrm{kernels}}{\to}\mathrm{MMD};$$

$$\mathrm{Wasserstein}\stackrel{\mathrm{univariate}\phantom{\rule{4.pt}{0ex}}\mathrm{setting}}{\to}\mathrm{QQ}/\text{PPplots}\stackrel{\mathrm{change}\phantom{\rule{4.pt}{0ex}}\mathrm{of}\phantom{\rule{4.pt}{0ex}}\mathrm{norm}}{\to}\mathrm{Kolmogorov}\u2013\mathrm{Smirnov};$$

$$\mathrm{Wasserstein}\stackrel{\mathrm{distribution}-\mathrm{free}\phantom{\rule{4.pt}{0ex}}\mathrm{variant}}{\to}\text{ODC curve}\stackrel{\mathrm{axis}\phantom{\rule{4.pt}{0ex}}\mathrm{reversal}}{\to}\text{ROC curve}.$$

We view the similarities and differences between these above tests through two lenses. The first is the population viewpoint of how different tests work with different representations of distributions; most of these tests are based on differences between quantities that completely specify a distribution—(a) CDFs; (b) QFs; and (c) CFs. The second viewpoint is the finite sample behavior of these statistics under the null hypothesis; most of these tests have null distributions based on norms of Brownian bridges, alternatively viewed as infinite sums of weighted chi-squared distributions (due to the Karhunen–Loeve expansion). We will return to these points as the paper proceeds.

More formally, given i.i.d. samples ${X}_{1},\phantom{\rule{3.33333pt}{0ex}}...,\phantom{\rule{3.33333pt}{0ex}}{X}_{n}$∼P and ${Y}_{1},\phantom{\rule{3.33333pt}{0ex}}...,\phantom{\rule{3.33333pt}{0ex}}{Y}_{m}$∼Q, where P and Q are probability measures on ${\mathbb{R}}^{d}$, we denote by ${P}_{n}$ and ${Q}_{m}$ the corresponding empirical measures. A test η is a function from the data ${D}_{n,m}:=\{{X}_{1},...{X}_{n},{Y}_{1},...,{Y}_{m}\}\in {\mathbb{R}}^{d(n+m)}$ to $\{0,1\}$ (or to $[0,1]$ if it is a randomized test), where 0/1 indicates acceptance/rejection of the null hypothesis.

Most tests proceed by calculating a scalar test statistic ${T}_{n,m}:=T\left({D}_{n,m}\right)\in \mathbb{R}$ and deciding ${H}_{0}$ or ${H}_{1}$ depending on whether ${T}_{n,m}$, after suitable normalization, is smaller or larger than a threshold ${t}_{\alpha}$. ${t}_{\alpha}$ is calculated based on a prespecified false positive rate α, chosen so that ${\mathbb{E}}_{{H}_{0}}\eta \le \alpha $, at least asymptotically. Indeed, all tests considered in this paper are of the form

$$\eta ({X}_{1},...,{X}_{n},{Y}_{1},...,{Y}_{m})=\mathbb{I}\left({T}_{n,m}>{t}_{\alpha}\right).$$

We follow the Neyman–Pearson paradigm, where a test is judged by its power ${\mathbb{E}}_{{H}_{1}}\eta $ which is some function $\varphi (m,n,d,P,Q,\alpha )$. We say that a test η is consistent, in the classical sense, when

$$\varphi \to 1\text{}\mathrm{as}\text{}m,n\to \infty ,\alpha \to 0.$$

All the tests we consider in this paper will be consistent in the classical sense mentioned above. Establishing general conditions under which these tests are consistent in the high-dimensional setting is largely open. All the test statistics considered here are of the form that they are typically small under ${H}_{0}$ and large under ${H}_{1}$ (usually with appropriate scaling, they converge to zero and to infinity, respectively, with infinite samples). The aforementioned threshold ${t}_{\alpha}$ will be determined by the distribution of the test statistic being used under the null hypothesis (i.e., assuming the null was true, we would like to know the typical variation of the statistic, and we reject the null if our observation is far from what is typically expected under the null). This naturally leads us to study the null distribution of our test statistic, i.e., the distribution of our statistic under the null hypothesis. Since these are crucial to running and understanding the corresponding tests, we will pursue their description in detail in this paper.

The literature broadly has three dominant ways of comparing distributions, both in one and in multiple dimensions. These are based on three different ways of characterizing distributions—CDFs, CFs and QFs. Many of the tests we will consider involve calculating differences between (empirical estimates of) these quantities.

For example, it is well known that the Kolmogorov–Smirnov (KS) test by [20,21] involves differences in empirical CDFs. We shall later see that in one dimension, the Wasserstein distance calculates differences in QFs.

The KS test, the related Cramer von-Mises criterion by [22,23], and Anderson–Darling test by [24] are very popular in one dimension, but their usage has been more restricted in higher dimensions. This is mostly due to the curse of dimensionality involved with estimating multivariate empirical CDFs. While there has been work on generalizing these popular one-dimensional to higher dimensions, like [25], these are seemingly not the most common multivariate tests.

Kernel and distance based tests have recently gained in popularity. As we will recap in more detail in later sections, it is known that the Gaussian kernel MMD implicitly calculates a (weighted) difference in CFs and the Euclidean energy distance implicitly works with a difference in (projected) CDFs.

The family of p-Wasserstein distances is a by-product of optimal transport theory [26]. Optimal transport can be used to compare probability measures in metric spaces; we consider here the classical case where that metric space is ${\mathbb{R}}^{d}$ endowed with the usual Euclidean metric.

Given an exponent $p\ge 1$, the definition of the p-Wasserstein distance reads:

For $p\in [1,\infty )$ and Borel probability measures $P,Q$ on ${\mathbb{R}}^{d}$ with finite p-moments, their p-Wasserstein distance ([26], Section 6) is
where $\Gamma (P,Q)$ is the set of all joint probability measures on ${\mathbb{R}}^{d}\times {\mathbb{R}}^{d}$ whose marginals are $P,Q$, i.e., for all subsets $A\subset {\mathbb{R}}^{d}$, we have $\pi (A\times {\mathbb{R}}^{d})=P\left(A\right)$ and $\pi ({\mathbb{R}}^{d}\times A)=Q\left(A\right)$.

$${W}_{p}(P,Q)={\left(\underset{\pi \in \Gamma (P,Q)}{inf}{\int}_{{\mathbb{R}}^{d}\times {\mathbb{R}}^{d}}{\parallel X-Y\parallel}^{p}d\pi \right)}^{1/p},$$

A remarkable feature of Wasserstein distances is that Definition 1 applies to all measures regardless of their absolute continuity with respect to the Lebesgue measure: The same definition works for both empirical measures and for their densities if they exist.

Writing ${\mathbf{1}}_{n}$ for the n-dimensional vector of ones, when comparing two empirical measures with uniform (the Wasserstein machinery works also for non-uniform weights. We do not mention this in this paper because all of the measures we consider in the context of two-sample testing are uniform) weight vectors ${\mathbf{1}}_{n}/n$ and ${\mathbf{1}}_{m}/m$, the Wasserstein distance ${W}_{p}({P}_{n},{Q}_{m})$ exponentiated to the power p is the optimum of a network flow problem known as the transportation problem ([27], Section 7.2). This problem has a linear objective and a polyhedral feasible set, defined, respectively, through the matrix ${M}_{XY}$ of pairwise distances between elements of X and Y raised to the power p:
and the polytope ${U}_{nm}$ defined as the set of $n\times m$ nonnegative matrices such that their row and column sums are equal to ${\mathbf{1}}_{n}/n$ and ${\mathbf{1}}_{m}/m$, respectively:

$${M}_{XY}:=[\parallel {X}_{i}-{Y}_{j}{{\parallel}^{p}]}_{ij}\in {\mathbb{R}}^{n\times m},$$

$${U}_{nm}:=\{T\in {\mathbb{R}}_{+}^{n\times m}\phantom{\rule{0.277778em}{0ex}}:\phantom{\rule{0.277778em}{0ex}}T{\mathbf{1}}_{m}={\mathbf{1}}_{n}/n,\phantom{\rule{0.166667em}{0ex}}{T}^{T}{\mathbf{1}}_{n}={\mathbf{1}}_{m}/m\}.$$

Let $\langle A,B\phantom{\rule{0.166667em}{0ex}}\rangle :=trace\left({A}^{T}B\right)$ be the usual Frobenius dot-product of matrices. Combining Equations (2) and (3), we have that ${W}_{p}^{p}({P}_{n},{Q}_{m})$ is the optimum of a linear program S of $n\times m$ variables,
of feasible set ${U}_{nm}$ and cost matrix ${M}_{XY}$.

$${W}_{p}^{p}({P}_{n},{Q}_{m})=\underset{T\in {U}_{nm}}{min}\langle T,{M}_{XY}\phantom{\rule{0.166667em}{0ex}}\rangle ,$$

We finish this section by pointing out that the rate of convergence as $n,m\to \infty $ of ${W}_{p}({P}_{n},{Q}_{m})$ towards ${W}_{p}(P,Q)$ gets slower as the dimension d grows under mild assumptions. For simplicity of exposition, consider $m=n$. For any $p\in [1,\infty )$, it follows from [28] that for $d\ge 3$, the difference between ${W}_{p}({P}_{n},{Q}_{n})$ and ${W}_{p}(P,Q)$ scales as ${n}^{-1/d}$. We also point out that when $d=2$, the rate actually scales as $\frac{\sqrt{ln\left(n\right)}}{\sqrt{n}}$ (see [29]). Finally, we note that when considering $p=\infty $, the rates of convergence are different to those when $1\le p<\infty $ . The work of [30,31,32] shows that the rate of convergence of ${W}_{\infty}({P}_{n},{Q}_{n})$ towards ${W}_{\infty}(P,Q)$ is of the order ${\left(\frac{ln\left(n\right)}{n}\right)}^{1/d}$ when $d\ge 3$ and $\frac{{(ln\left(n\right))}^{3/4}}{{n}^{1/2}}$ when $d=2$. Hence, the original Wasserstein distance by itself may not be a favorable choice for a multivariate two-sample test.

Aside from the slow convergence rate of the Wasserstein distance between samples from two different measures to their distance in population, computing the optimum of Equation (4) is expensive. This can be easily seen by noticing that the transportation problem boils down to an optimal assignment problem when $n=m$. Since the resolution of the latter has a cubic cost in n, all known algorithms that can solve the optimal transport problem scale at least super-cubicly in n. Using an idea that can be traced back as far as Schrodinger [33], Cuturi [34] recently proposed to use an entropic regularization of the optimal transport problem, in order to define the Sinkhorn divergence between $P,Q$ parameterized by $\lambda \ge 0$ as
where $E\left(T\right)$ is the entropy of T seen as a discrete joint probability distribution, namely $E\left(T\right)$: = −${\sum}_{ij}{T}_{ij}log\left({T}_{ij}\right).$

$${S}_{\lambda}^{p}(P,Q):=\underset{T\in {U}_{nm}}{min}\phantom{\rule{0.166667em}{0ex}}\lambda \langle T,{M}_{XY}\phantom{\rule{0.166667em}{0ex}}\rangle -E\left(T\right),$$

This approach has two benefits: (i) because $E\left(T\right)$ is 1-strongly convex with respect to the ${\ell}_{1}$ norm, the regularized problem is itself strongly convex and admits a unique optimal solution, written ${T}_{\lambda}$, as opposed to the initial OT problem, for which the minimizer may not be unique; (ii) this optimal solution ${T}_{\lambda}$ is a diagonal scaling of ${e}^{-{M}_{XY}}$, the element-wise exponential matrix of $-{M}_{XY}$. One can easily show using the Lagrange method of multipliers that there must exist two non-negative vectors $u\in {\mathbb{R}}^{n},v\in {\mathbb{R}}^{m}$ such that ${T}_{\lambda}$: =${D}_{u}{e}^{-{M}_{XY}}{D}_{v}$, where ${D}_{u}$ ${D}_{v}$ are diagonal matrices with u and v on their diagonal. The solution to this diagonal scaling problem can be found efficiently through Sinkhorn’s algorithm [35], which has a linear convergence rate [36]. Sinkhorn’s algorithm can be implemented in a few lines of code that only require matrix vector products and elementary operations, hence they are easily parallelized on modern hardware.

An interesting class of tests are distance-based “energy statistics” as introduced originally by [9], and later by [10]. The statistic, called the Cramer statistic by the latter paper and Energy Distance by the former, corresponds to the population quantity
where $X,{X}^{\prime}\sim P$ and $Y,{Y}^{\prime}\sim Q$ (all i.i.d.). The associated test statistic is

$$\mathrm{ED}\phantom{\rule{3.33333pt}{0ex}}:=\phantom{\rule{3.33333pt}{0ex}}2\mathbb{E}\parallel X-Y\parallel -\mathbb{E}\parallel X-{X}^{\prime}\parallel -\mathbb{E}\parallel Y-{Y}^{\prime}\parallel ,$$

$$\begin{array}{ccc}\hfill {\mathrm{ED}}_{b}& :=& \frac{2}{mn}\sum _{i=1}^{n}\sum _{j=1}^{m}\parallel {X}_{i}-{Y}_{j}\parallel -\frac{1}{{n}^{2}}\sum _{i,j=1}^{n}\parallel {X}_{i}-{X}_{j}\parallel -\frac{1}{{m}^{2}}\sum _{i,j=1}^{m}\parallel {Y}_{i}-{Y}_{j}\parallel .\hfill \end{array}$$

It was proved by the authors that $\mathrm{ED}(P,Q)=0$ iff $P=Q$. Hence, rejecting when ${\mathrm{ED}}_{b}$ is larger than an appropriate threshold leads to a test which is consistent against all fixed alternatives where $P\ne Q$ under mild conditions (like finiteness of $\mathbb{E}\left[X\right],\mathbb{E}\left[Y\right]$); see aforementioned references for details. Then, the Sinkhorn divergence defined in Equation (5) can be linked to the the energy distance when the parameter λ is set to $\lambda =0$— namely when only entropy is considered in the resolution of Equation (5), through the following formula:

$${\mathrm{ED}}_{b}=2{S}_{0}^{1}({P}_{n},{Q}_{m})-{S}_{0}^{1}({P}_{n},{P}_{n})-{S}_{0}^{1}({Q}_{m},{Q}_{m}).$$

Indeed, notice first that the solution to Equation (5) at $\lambda =0$ is the maximum entropy table in ${U}_{nm}$, namely the outer product $\left({\mathbf{1}}_{n}{\mathbf{1}}_{m}^{T}\right)/nm$ of the marginals ${\mathbf{1}}_{n}/n$ and ${\mathbf{1}}_{m}/m$. Hence, Equation (6) follows from the observations that

$$\begin{array}{cc}\hfill {S}_{0}^{1}({P}_{n},{Q}_{m})& =\frac{1}{nm}\sum _{i,j}\parallel {X}_{i}-{Y}_{j}\parallel ,\hfill \\ \hfill {S}_{0}^{1}({P}_{n},{P}_{n})& =\frac{1}{{n}^{2}}\sum _{i,j=1}^{n}\parallel {X}_{i}-{X}_{j}\parallel ,\hfill \\ \hfill {S}_{0}^{1}({Q}_{m},{Q}_{m})& =\frac{1}{{m}^{2}}\sum _{i,j=1}^{m}\parallel {Y}_{i}-{Y}_{j}\parallel .\hfill \end{array}$$

It is also known that the population energy distance is related to the integrated difference in CDFs, i.e.,
where ${F}_{X}(a,t)=P({a}^{T}X\le t)$ (similarly ${F}_{Y}(a,t)$) is the population CDF of X when projected along direction a and ${S}^{d-1}$ is the surface of the d-dimensional unit sphere; see [9] for a proof.

$$\mathrm{ED}(P,Q)=\underset{(a,t)\in {S}^{d-1}\times \mathbb{R}}{\int}{[{F}_{X}(a,t)-{F}_{Y}(a,t)]}^{2}\mathrm{d}a\phantom{\rule{4pt}{0ex}}\mathrm{d}t,$$

Another popular class of tests that has emerged over the last decade are kernel-based tests introduced independently by [37,38], and expanded on in [11]. Without getting into technicalities that are irrelevant for this paper, the Maximum Mean Discrepancy between $P,Q$ is defined as
where ${\mathcal{H}}_{k}$ is a Reproducing Kernel Hilbert Space associated with Mercer kernel $k(\xb7,\xb7)$, and ${\parallel f\parallel}_{{\mathcal{H}}_{k}}\le 1$ is its unit norm ball.

$$\mathrm{MMD}({\mathcal{H}}_{k},P,Q):=\underset{{\parallel f\parallel}_{{\mathcal{H}}_{k}}\le 1}{max}{\mathbb{E}}_{P}f\left(X\right)-{\mathbb{E}}_{Q}f\left(Y\right),$$

While it is easy to see that $\mathrm{MMD}\ge 0$ always, and also that $P=Q$ implies $\mathrm{MMD}=0$, Reference [37] shows that if k is “characteristic”, the equality holds iff $P=Q$. The Gaussian kernel $k(a,b)=exp(-\parallel a-b{\parallel}^{2}/{\gamma}^{2})$ is a popular example of a characteristic kernel, and in this case, $\mathrm{MMD}$ can be interpreted as the integrated difference between characteristic functions. Indeed, by Bochner’s theorem (see [39]), the population quantity ${\mathrm{MMD}}^{2}$ with the Gaussian kernel is precisely (up to constants)
where ${\phi}_{X}\left(t\right)={\mathbb{E}}_{x\sim P}\left[{e}^{-i{t}^{T}x}\right]$ is the characteristic function of X at frequency t (similarly ${\phi}_{Y}\left(t\right)$). Using the Riesz representation theorem and the reproducing property of ${\mathcal{H}}_{k}$, one can argue that $\mathrm{MMD}({\mathcal{H}}_{k},P,Q)={\parallel {\mathbb{E}}_{P}k(X,.)-{\mathbb{E}}_{Q}k(Y,.)\parallel}_{{\mathcal{H}}_{k}}$ and conclude that

$${\int}_{{\mathbb{R}}^{d}}{|{\phi}_{X}\left(t\right)-{\phi}_{Y}\left(t\right)|}^{2}{e}^{-{\gamma}^{2}{\parallel t\parallel}^{2}}\mathrm{d}t,$$

$${\mathrm{MMD}}^{2}=\mathbb{E}k(X,{X}^{\prime})+\mathbb{E}k(Y,{Y}^{\prime})-2\mathbb{E}k(X,Y).$$

This gives rise to a natural associated test statistic, a plugin estimator of ${\mathrm{MMD}}^{2}$:

$$\begin{array}{ccc}\hfill {\mathrm{MMD}}_{u}^{2}\left(k(\xb7,\xb7)\right)& :=& \frac{1}{{n}^{2}}\sum _{i,j=1}^{n}k({X}_{i},{X}_{j})+\frac{1}{{m}^{2}}\sum _{i,j=1}^{m}k({Y}_{i},{Y}_{j})-\frac{2}{mn}\sum _{i=1}^{n}\sum _{j=1}^{m}k({X}_{i},{Y}_{j}).\hfill \end{array}$$

At first sight, the Energy Distance and the MMD look like fairly different tests. However, there is a natural connection that proceeds in two steps. Firstly, there is no reason to stick to only the Euclidean norm ${\parallel \xb7\parallel}_{2}$ to measure distances for ED—the test can be extended to other norms, and in fact also other metrics; Reference [40] explains the details for the closely related independence testing problem. Following that, Reference [41] discusses the relationship between distances and kernels (again for independence testing, but the same arguments also hold in the two-sample testing setting). Loosely speaking, for every kernel k, there exists a metric d (and also vice versa), given by $d(x,y):=\left(k\right(x,x)+k(y,y\left)\right)/2-k(x,y)$, such that MMD with kernel k equals ED with metric d. This is a very strong connection between these two families of tests—the energy distance is a special case of the kernel MMD, corresponding to a particular choice of kernel, and the kernel MMD itself corresponds to an extremely smoothed Wasserstein distance, for a particular choice of distance.

For univariate random variables, a PP plot is a graphical way to view differences in empirical CDFs, while QQ plots are analogous to comparing QFs. Instead of relying on graphs, we can also make such tests more formal and rigorous as follows. We first present some results on the asymptotic distribution of the difference between ${P}_{n}$ and ${Q}_{m}$ when using the distance between the CDFs ${F}_{n}$ and ${G}_{m}$ and then later when using the distance between the QFs ${F}_{n}^{-1}$ and ${G}_{m}^{-1}$. For simplicity, we assume that both distributions P and Q are supported on the interval $[0,1]$; we remark that under mild assumptions on P and Q, the results we present in this section still hold without such a boundedness assumption. We assume for simplicity that the CDFs F and G have positive densities on $[0,1]$.

We start by noting ${F}_{n}$ may be interpreted as a random element taking values in the space $\mathcal{D}\left(\right[0,1\left]\right)$ of right continuous functions with left limits. It is well known that
where $\mathbb{B}$ is a standard Brownian bridge in $[0,1]$ and where the weak convergence ${\to}_{w}$ is understood as convergence of probability measures in the space $\mathcal{D}\left(\right[0,1\left]\right)$; see Chapter 3 in [42] for details. From this fact and the independence of the samples, it follows that under the null hypothesis ${H}_{0}:P=Q$, as $n,m\to \infty $

$$\sqrt{n}\left({F}_{n}-F\right){\to}_{w}\mathbb{B}\circ F,$$

$$\sqrt{\frac{mn}{n+m}}\left({F}_{n}-{G}_{m}\right)=\sqrt{\frac{mn}{n+m}}\left({F}_{n}-F\right)+\sqrt{\frac{mn}{n+m}}\left(G-{G}_{m}\right){\to}_{w}\mathbb{B}\circ F.$$

The previous fact and continuity of the function $h\in \mathcal{D}\left([0,1]\right)\mapsto {\int}_{0}^{1}{\left(h\left(t\right)\right)}^{2}dt$ imply that as $n,m\to \infty $, we have under the null,

$$\frac{mn}{n+m}{\int}_{0}^{1}{\left({F}_{n}\left(t\right)-{G}_{m}\left(t\right)\right)}^{2}dt{\to}_{w}{\int}_{0}^{1}{\left(\mathbb{B}\left(F\left(t\right)\right)\right)}^{2}dt.$$

Observe that the above asymptotic null distribution depends on F, which is unknown in practice. This is an obstacle when considering any ${L}^{p}$-distance, with $1\le p<\infty $, between the empirical cdfs ${F}_{n}$ and ${G}_{m}$. Luckily, a different situation occurs when one considers the ${L}^{\infty}$-distance between ${F}_{n}$ and ${G}_{m}$. Under the null, using Equation (7) again, we deduce that
where the equality in the previous expression follows from the fact that the continuity of F implies that the interval $[0,1]$ is mapped onto the interval $[0,1]$. This is known as the Kolmogorov–Smirnov test, and is hence appropriate for two-sample problems. A related statistic, called the Anderson-Darling test, will also be considered in the experiments.

$$\sqrt{\frac{mn}{n+m}}\parallel {F}_{n}-{G}_{m}{\parallel}_{\infty}{\to}_{w}{\parallel \mathbb{B}\circ F\parallel}_{\infty}={\parallel \mathbb{B}\parallel}_{\infty},$$

We now turn our attention to QQ (quantile–quantile) plots and specifically the ${L}^{2}$-distance between ${F}_{n}^{-1}$ and ${G}_{m}^{-1}$. It can be shown that if F has a differentiable density f which (for the sake of simplicity) we assume is bounded away from zero, then

$$\sqrt{n}({F}_{n}^{-1}-{F}^{-1}){\to}_{w}\frac{\mathbb{B}}{f\circ {F}^{-1}}.$$

For a proof of the above statement, see Chapter 18 in [43]; for an alternative proof where the weak convergence is considered in the space of probability measures on ${L}^{2}\left((0,1)\right)$ (as opposed to the space $\mathcal{D}\left(\right[0,1\left]\right)$ we have been considering thus far), see [8]. We note that from the previous result and independence, it follows that under the null hypothesis ${H}_{0}:P=Q$,

$$\sqrt{\frac{mn}{n+m}}({F}_{n}^{-1}-{G}_{m}^{-1}){\to}_{w}\frac{\mathbb{B}}{f\circ {F}^{-1}}.$$

In particular, by continuity of the function $h\in {L}^{2}\left((0,1)\right)\mapsto {\int}_{0}^{1}{\left(h\left(t\right)\right)}^{2}dt$, we deduce that

$$\frac{mn}{n+m}{\int}_{0}^{1}{({F}_{n}^{-1}-{G}_{m}^{-1})}^{2}dt{\to}_{w}{\int}_{0}^{1}\frac{{\left(\mathbb{B}\left(t\right)\right)}^{2}}{{(f\circ {F}^{-1}\left(t\right))}^{2}}dt.$$

Hence, as was the case when we considered the difference of the cdfs ${F}_{n}$ and ${G}_{m}$, the asymptotic distribution of the ${L}^{2}$-difference (or analogously any ${L}^{p}$-difference for finite p) of the empirical quantile functions is also distribution dependent. Note, however, that there is an important difference between QQ and PP plots when using the ${L}^{\infty}$ norm. We saw that the asymptotic distribution of the ${L}^{\infty}$ norm of the difference of ${F}_{n}$ and ${G}_{m}$ is (under the null hypothesis) distribution free. Unfortunately, in the quantile case, we obtain
which, of course, is distribution dependent. Since one would have to resort to computer-intensive Monte-Carlo techniques (like bootstrap or permutation testing) to control type-1 error, these tests are sometimes overlooked (though with modern computing speeds, they merit further study).

$$\sqrt{\frac{mn}{n+m}}\parallel {F}_{n}^{-1}-{G}_{n}^{-1}{\parallel}_{\infty}{\to}_{w}{\parallel \frac{\mathbb{B}}{f\circ {F}^{-1}}\parallel}_{\infty},$$

Recall that, for $p\in [1,\infty )$, the p-Wasserstein distance between two probability measures $P,Q$ on $\mathbb{R}$ with finite p-moments is given by Equation (1).

Because the Wasserstein distance measures the cost of transporting mass from the original distribution P into the target distribution Q, one can say that it measures “horizontal” discrepancies between P and Q. Intuitively, two probability distributions P and Q that are different over “long” (horizontal) regions will be far away from each other in the Wasserstein distance sense because, in that case, mass has to travel long distances to go from the original distribution to the target distribution. In the one-dimensional case (in contrast with what happens in dimension $d>1$), the p-Wasserstein distance has a simple interpretation in terms of the quantile functions ${F}^{-1}$ and ${G}^{-1}$ of P and Q, respectively. The reason for this is that the optimal way to transport mass from P to Q has to satisfy a certain monotonicity property that we describe in the proof of the following proposition. This is a well known fact that can be found, for example, in [19].

The p-Wasserstein distance between two probability measures P and Q on $\mathbb{R}$ with p-finite moments can be written as
where ${F}^{-1}$ and ${G}^{-1}$ are the quantile functions of P and Q, respectively.

$${W}_{p}^{p}(P,Q)={\int}_{0}^{1}{|{F}^{-1}\left(t\right)-{G}^{-1}\left(t\right)|}^{p}dt,$$

Having considered the p-Wasserstein distance ${W}_{p}(P,Q)$ for $p\in [1,\infty )$ in Proposition 1, we conclude this section by considering the case $p=\infty $. Let $P,Q$ be two probability measures on $\mathbb{R}$ with bounded support. That is, assume that there exists a number $N>0$ such that $supp\left(P\right)\subseteq [-N,N]$ and $supp\left(Q\right)\subseteq [-N,N]$. We define the ∞-Wasserstein distance between P and Q by

$${W}_{\infty}(P,Q):=\underset{\pi \in \Gamma (P,Q)}{inf}esssu{p}_{\pi}|x-y|.$$

Proceeding as in the case $p\in [1,\infty )$, it is possible to show that the ∞-Wasserstein distance between P and Q with bounded supports can be written in terms of the difference of the corresponding quantile functions as

$${W}_{\infty}(P,Q)={\parallel {F}^{-1}-{G}^{-1}\parallel}_{\infty}.$$

The Wasserstein distance is called the Mallow’s distance in the statistical literature, where it has been studied due to its ability to capture weak convergence precisely—${W}_{p}({F}_{n},F)$ converges to 0 if and only if ${F}_{n}$ converges in distribution to F and also the p-th moment of X under ${F}_{n}$ converges to the corresponding moment under F; see [44,45,46]. It is also related to the Kantorovich–Rubinstein metric from optimal transport theory.

As we earlier saw, under ${H}_{0}:P=Q$, the statistic $\frac{mn}{n+m}{\int}_{0}^{1}{\left({F}_{n}^{-1}\left(t\right)-{G}_{m}^{-1}\left(t\right)\right)}^{2}dt$ has an asymptotic distribution that is not distribution free, i.e., it depends on F. We also saw that as opposed to what happens with the asymptotic distribution of the ${L}^{\infty}$ distance between ${F}_{n}$ and ${G}_{m}$, the asymptotic distribution of $\parallel {F}_{n}^{-1}-{G}_{m}^{-1}{\parallel}_{\infty}$ does depend on the cdf F. In this section, we show how we can construct a distribution-free Wasserstein test by connecting it to the theory of ROC and ODC curves.

Let P and Q be two distributions on $\mathbb{R}$ with cdfs F and G and quantile functions ${F}^{-1}$ and ${G}^{-1}$, respectively. We define the ROC curve between F and G as the function.

$$ROC\left(t\right):=1-F\left({G}^{-1}(1-t)\right),\phantom{\rule{1.em}{0ex}}t\in [0,1].$$

In addition, we define their ODC curve by

$$ODC\left(t\right):=G\left({F}^{-1}\left(t\right)\right),\phantom{\rule{1.em}{0ex}}t\in [0,1].$$

The following are properties of the ROC curve (see [12]):

- The $ROC$ curve is increasing and $ROC\left(0\right)=0$, $ROC\left(1\right)=1$.
- If $G\left(t\right)\ge F\left(t\right)$ for all t, then $ROC\left(t\right)\ge t$ for all t.
- If $F,G$ have densities with monotone likelihood ratio, then the ROC curve is concave.
- The area under the ROC curve is equal to $\mathbb{P}(Y<X)$, where Y∼Q and X∼P.

Intuitively speaking, the faster the ROC curve increases towards the value 1, the easier it is to distinguish the distributions P and Q. Observe from their definitions that the ROC curve can be obtained from the ODC curve after reversing the axes. Given this, we focus from this point on only one of them, the ODC curve being more convenient.

The first observation about the ODC curve is that it can be regarded as the quantile function of the distribution ${G}_{\u266f}P$ (the push forward of P by G) on $[0,1]$, which is defined by

$${G}_{\u266f}P\left([0,\alpha )\right):=P\left({G}^{-1}\left([0,\alpha )\right)\right),\phantom{\rule{1.em}{0ex}}\alpha \in [0,1].$$

Similarly, we can consider the measure ${{G}_{m}}_{\u266f}{P}_{n}$, that is, the push forward of ${P}_{n}$ by ${G}_{m}$. We crucially note that the empirical ODC curve ${G}_{m}\circ {F}_{n}^{-1}$ is the quantile function of ${{G}_{m}}_{\u266f}{P}_{n}$. From Section 4, we deduce that
for every $p\in [1,\infty )$ and also

$${W}_{p}^{p}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)={\int}_{0}^{1}{|{G}_{m}\circ {F}_{n}^{-1}\left(t\right)-G\circ {F}^{-1}\left(t\right)|}^{p}dt$$

$${W}_{\infty}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)={\left||{G}_{m}\circ {F}_{n}^{-1}-G\circ {F}^{-1}|\right|}_{\infty}.$$

That is, the p-Wasserstein distance between the measures ${{G}_{m}}_{\u266f}{P}_{n}$ and ${G}_{\u266f}P$ can be computed by considering the ${L}^{p}$ distance of the ODC curve and its empirical version.

First, we argue that under the null hypothesis ${H}_{0}:P=Q$, the distribution of the empirical ODC curve is actually independent of P. In particular, ${W}_{p}^{p}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)$ and ${W}_{\infty}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)$ are distribution free under the null! This is the content of the next lemma, proved in the Appendix.

Let $F,G$ be two continuous and strictly increasing CDFs and let ${F}_{n}$ and ${G}_{m}$ be the empirical CDFs. Consider the (unknown) random variables, which are distributed uniformly on $[0,1]$,

$${U}_{k}^{X}:=F\left({X}_{k}\right),\phantom{\rule{4pt}{0ex}}{U}_{k}^{Y}:=G\left({Y}_{k}\right).$$

Let ${F}_{n}^{U}$ be the empirical CDF associated with the (uniform) ${U}^{X}$s and let ${G}_{m}^{U}$ be the empirical CDF associated with the (uniform) ${U}^{Y}$s. Then, under the null ${H}_{0}:F=G$, we have

$${G}_{m}\left({X}_{k}\right)={G}_{m}^{U}\left({U}_{k}^{X}\right),\phantom{\rule{1.em}{0ex}}\forall k\in \left\{1,\cdots ,n\right\}.$$

In particular, we have ${G}_{m}\circ {F}_{n}^{-1}\left(t\right)={G}_{m}^{U}\circ {{F}_{n}^{U}}^{-1}\left(t\right),\phantom{\rule{1.em}{0ex}}\forall t\in [0,1].$

We denote by ${Y}_{\left(1\right)}\le \cdots \le {Y}_{\left(m\right)}$ the order statistic associated to the Ys. For $k=1,\cdots ,m-1$ and $t\in (0,1)$, we have ${G}_{m}\left(t\right)=\frac{k}{m}$ if and only if $t\in [{Y}_{\left(k\right)},{Y}_{(k+1)})$, which holds if and only if $t\in [{F}^{-1}\left({U}_{\left(k\right)}^{Y}\right),{F}^{-1}\left({U}_{(k+1)}^{Y}\right))$, which, in turn, is equivalent to $F\left(t\right)\in [{U}_{\left(k\right)}^{Y},{U}_{(k+1)}^{Y})$. Thus, ${G}_{m}\left(t\right)=\frac{k}{m}$ if and only if ${G}_{m}^{U}\left(F\left(t\right)\right)=\frac{k}{m}$. From the previous observations, we conclude that ${G}_{m}={G}_{m}^{U}\circ F$. Finally, since ${X}_{k}={F}^{-1}\left({U}_{k}^{X}\right)$, we conclude that

$${G}_{m}\left({X}_{k}\right)={G}_{m}^{U}\circ F\circ {F}^{-1}\left({U}_{k}^{X}\right)={G}_{m}^{U}\left({U}_{k}^{X}\right).$$

This concludes the proof. ☐

Note that since ${U}_{k}^{X},{U}_{k}^{Y}$ are obviously instantiations of uniformly distributed random variables, the right hand side of the last equation only involves uniform random variables, and hence the distribution of ${G}_{m}\circ {F}_{n}^{-1}$ is independent of $F,G$ under the null. Now, we are almost done, and this above lemma will imply that the Wasserstein distance between ${G}_{m}\circ {F}_{n}^{-1}$ and the uniform distribution $U[0,1]$ (since $G\circ {F}^{-1}\left(t\right)=t={U}^{-1}\left(t\right)=U\left(t\right)$ for $t\in [0,1]$ when $G=F$) also does not depend on $F,G$.

More formally, one may establish a result on the asymptotic distribution of the statistic ${W}_{p}^{p}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)$ and ${W}_{\infty}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)$. We do this by first considering the asymptotic distribution of the difference between the empirical ODC curve and the population ODC curve regarding both of them as elements in the space $\mathcal{D}\left(\right[0,1\left]\right)$. This is the content of the following Theorem which follows directly from the work of [47] (see [12]).

Suppose that F and G are two CDFs with densities $f,g$ satisfying
for all $t\in [0,1]$. In addition, assume that $\frac{n}{m}\to \lambda \in [0,\infty )$ as $n,m\to \infty $. Then,
where ${B}_{1}$ and ${B}_{2}$ are two independent Brownian bridges and where the weak convergence must be interpreted as weak convergence in the space of probability measures on the space $\mathcal{D}\left(\right[0,1\left]\right)$.

$$\frac{g\left({F}^{-1}\left(t\right)\right)}{f\left({F}^{-1}\left(t\right)\right)}\le C,$$

$$\sqrt{\frac{mn}{n+m}}\left({G}_{m}\left({F}_{n}^{-1}(\xb7)\right)-G\left({F}^{-1}(\xb7)\right)\right){\to}_{w}\sqrt{\frac{\lambda}{\lambda +1}}{B}_{1}(G\circ {F}^{-1}(\xb7))+\sqrt{\frac{1}{\lambda +1}}\frac{g\left({F}^{-1}(\xb7)\right)}{f\left({F}^{-1}(\xb7)\right)}{B}_{2}(\xb7),$$

As a corollary, under the null hypothesis ${H}_{0}$: $P=Q$, we obtain the following. Suppose that the CDF F of P is continuous and strictly increasing. Then,

$$\begin{array}{cc}\hfill \frac{mn}{n+m}{W}_{2}^{2}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)& =\frac{mn}{n+m}{\int}_{0}^{1}{({G}_{m}\left({F}_{n}^{-1}\left(t\right)\right)-t)}^{2}dt{\to}_{w}{\int}_{0}^{1}{\left(\mathbb{B}\left(t\right)\right)}^{2}dt,\hfill \end{array}$$

$$\begin{array}{cc}\hfill \sqrt{\frac{mn}{n+m}}{W}_{\infty}({{G}_{m}}_{\u266f}{P}_{n},{G}_{\u266f}P)& =\sqrt{\frac{mn}{n+m}}\underset{t\in [0,1]}{sup}|{G}_{m}\left({F}_{n}^{-1}\left(t\right)\right)-t|{\to}_{w}\underset{t\in [0,1]}{sup}\left|\mathbb{B}\left(t\right)\right|.\hfill \end{array}$$

To see this, note that by Lemma 1 that it suffices to consider $F\left(t\right)=t$ in $[0,1]$. In that case, the assumptions of Theorem 1 are satisfied and the result follows directly. The latter test based on the infinity norm is extremely similar to the Kolmogorov–Smirnov test in theory and practice—one may also note the similarity of the above expressions with Equations (9) and (10).

The takeaway message of this section is that instead of considering the Wasserstein distance between ${F}_{m}$ and ${G}_{n}$, whose null distribution depends on unknown F, one can instead consider the Wasserstein distance between ${G}_{m}\left({F}_{n}^{-1}\right)$ and the uniform distribution $U[0,1]$, since its null distribution is independent of F.

One cannot, in general, have results comparing the powers of different nonparametric tests. Which test achieves a higher power depends on the class of alternatives being considered—some tests are more sensitive to deviations near the median, others are more sensitive to differences in the tails, and yet others are more sensitive to deviations that are not represented in the original space but instead in an underlying Hilbert space embedding of distributions (MMD and ED are examples of this). Hence, the statistical literature has very sparse results on theoretical comparisons between distributions, and one must often resort to experiments to get a sense of their relative performance on examples of interest.

In this section, we report results for two-sample tests run with the following example distributions (the parameters for the k-th pair of distributions (for $k=1,2,3,4$) so that the distributions have their first k-1 central moments as identical, but differ in their k-th central moments):

- Beta(2,2) versus Beta(1.8,2.16);
- Exponential(1), equivalently Gamma(1,1), versus Gamma(2,0.5);
- Standard Normal versus Student’s t;
- Generalized extreme value versus Generalized Pareto.

We use some common test statistics that have already been mentioned in this paper—Kolmogorov–Smirnov, Anderson–Darling, Maximum Mean Discrepancy (MMD), ROC (infinity norm) and the smoothed Wasserstein distance with four regularizations: 0 (corresponding to Energy Distance), 10, 50 and infinity (corresponding to Wasserstein distance).

All of these statistics are nonparametric, in the sense that they do not assume a particular form or have access to the true underlying PDFs. Nevertheless, all of the examples that we construct are parametric, so we also include the “oracle” likelihood ratio test (we term it as an oracle since it uses extra knowledge, namely the exact form of the PDFs, to which the other tests do not have access).

One may note from Figure 1 that the precision-recall curve of nonparametric tests are often much worse than the oracle likelihood ratio test, and this is indeed to be expected—the true utility of the nonparametric tests would be observed in a real-world example where one wishes to abstain from making any (possibly wrong, biased or misleading) parametric assumptions. As might be expected from the discussion at the start of the section, the tests are rather difficult to compare. Among the tests considered, the ordering of the curves changes over different experiments, and even within the class of Wasserstein tests. While general comparisons are difficult, there is a need for theoretical analysis comparing classes of tests in special cases of practical interest (for example, mean-separated Gaussians).

The role of entropic smoothing parameter λ is also currently unclear, and whether there is a data dependent way to pick it so as to maximize power. This could be an interesting direction of future research.

In this paper, we connect a wide variety of univariate and multivariate test statistics, with the central piece being the Wasserstein distance. The Wasserstein statistic is closely related to univariate tests like the Kolmogorov–Smirnov test, graphical QQ plots, and a distribution-free variant of the test is proposed by connecting it to ROC/ODC curves. Through entropic smoothing, the Wasserstein test is also related to the multivariate tests of Energy Distance and hence transitively to the Kernel Maximum Mean Discrepancy. We hope that this is a useful resource to connect the different families of two-sample tests, many of which can be analyzed under the two umbrellas of our paper—whether they differentiate between CDFs, QFs or CFs, and what their null distributions look like. Many questions remain open—for example, the role of smoothing parameter λ.

Aaditya Ramdas acknowledges Yuxiang Wang for sharing code. The authors thank José Chacón for pointing out the literature on ROC/ODC.

Marco Cuturi noticed the connection between smoothed Wasserstein distance and Energy Distance, Aaditya Ramdas and Nicolas Garcia Trillos derived connections to ROC/ODC curves, Nicolas Garcia Trillos derived the null distributions, Aaditya Ramdas ran the experiments, all authors contributed to writing. All authors have read and approved the final manuscript.

The authors declare no conflict of interest.

We first observe that the infimum in the definition of ${W}_{p}(P,Q)$ can be replaced by minimum, namely, there exists a transportation plan $\pi \in \Gamma (P,Q)$ that achieves the infimum in Equation (1). This can be deduced in a straightforward way by noting that the expression ${\int}_{\mathbb{R}\times \mathbb{R}}{|x-y|}^{p}d\pi (x,y)$ is linear in π and that the set $\Gamma (P,Q)$ is compact in the sense of weak convergence of probability measures on $\mathbb{R}\times \mathbb{R}$. Let us denote by ${\pi}^{*}$ an element in $\Gamma (P,Q)$ realizing the minimum in Equation (1). Let $({x}_{1},{y}_{1})\in supp\left({\pi}^{*}\right)$ and $({x}_{2},{y}_{2})\in supp\left({\pi}^{*}\right)$ (here $supp\left({\pi}^{*}\right)$ stands for the support of π) and suppose that ${x}_{1}<{x}_{2}$. We claim that the optimality of ${\pi}^{*}$ implies that ${y}_{1}\le {y}_{2}$. To see this, suppose for the sake of contradiction that this is not the case, that is, suppose that ${y}_{2}<{y}_{1}$. We claim that in that case

$${|{x}_{1}-{y}_{2}|}^{p}+{|{x}_{2}-{y}_{1}|}^{p}<{|{x}_{1}-{y}_{1}|}^{p}+{|{x}_{2}-{y}_{2}|}^{p}.$$

Note that for $p=1$, this follows in a straightforward way. For the case $p>1$, first note that ${x}_{1}<{x}_{2}$ and ${y}_{2}<{y}_{1}$ imply that there exists $t\in (0,1)$ such that $t{x}_{1}+(1-t){y}_{1}=t{x}_{2}+(1-t){y}_{2}$. Now, note that
because the points ${x}_{1}$, ${y}_{2}$ and $t{x}_{1}+(1-t){y}_{1}$ all lie on the same line segment. However, then, using the fact that $t{x}_{1}+(1-t){y}_{1}=t{x}_{2}+(1-t){y}_{2}$, we can rewrite the previous expression as

$$|{x}_{1}-{y}_{2}|=|{x}_{1}-\left(t{x}_{1}+(1-t){y}_{1}\right)|+|\left(t{x}_{1}+(1-t){y}_{1}\right)-{y}_{2}|$$

$$|{x}_{1}-{y}_{2}|=(1-t)|{x}_{1}-{y}_{1}|+t|{y}_{2}-{x}_{2}|.$$

Using the strict convexity of the function $t\mapsto {t}^{p}$ (when $p>1$), we deduce that

$${|{x}_{1}-{y}_{2}|}^{p}<(1-t){|{x}_{1}-{y}_{1}|}^{p}+t{|{x}_{2}-{y}_{2}|}^{p}.$$

In a similar fashion, we obtain

$${|{x}_{2}-{y}_{1}|}^{p}<t{|{x}_{1}-{y}_{1}|}^{p}+(1-t){|{x}_{2}-{y}_{2}|}^{p}.$$

Adding the previous two inequalities we obtain Equation (A1). Note, however, that (A1) contradicts the optimality of ${\pi}^{*}$ because it shows that ${\pi}^{*}$ is not cyclically monotone, which essentially means that it is possible to rearrange the way mass is transported from P to Q by ${\pi}^{*}$ in order to reduce the transportation cost (it would be cheaper to send mass from ${x}_{1}$ to ${y}_{2}$ and from ${x}_{2}$ to ${y}_{1}$ than to send mass from ${x}_{1}$ to ${y}_{1}$ and from ${x}_{2}$ to ${y}_{2}$). Therefore, we conclude that if $({x}_{1},{y}_{1})\in supp\left({\pi}^{*}\right)$, $({x}_{2},{y}_{2})\in {\pi}^{*}$ and ${x}_{1}<{x}_{2}$, then ${y}_{1}\le {y}_{2}$.

Now, for $x\in supp\left(P\right)$ and $y\in supp\left(Q\right)$, we claim that $(x,y)\in supp\left({\pi}^{*}\right)$ if and only if $F\left(x\right)=G\left(y\right)$. To see this, note that from the monotonicity property just established, we deduce that $(x,y)\in supp\left({\pi}^{*}\right)$ if and only if ${\pi}^{*}(\mathbb{R},(-\infty ,y])={\pi}^{*}\left((-\infty ,x]\right),(-\infty ,y])={\pi}^{*}((-\infty ,x],\mathbb{R})$. In turn, the fact that ${\pi}^{*}\in \Gamma (P,Q)$ implies that ${\pi}^{*}((-\infty ,x],\mathbb{R})=F\left(x\right)$ and ${\pi}^{*}(\mathbb{R},(-\infty ,y])=G\left(y\right)$. From the previous relation, we conclude that
as we wanted to show. ☐

$${\int}_{\mathbb{R}\times \mathbb{R}}{|x-y|}^{p}d{\pi}^{*}(x,y)={\int}_{supp\left({\pi}^{*}\right)}{|x-y|}^{p}d{\pi}^{*}(x,y)={\int}_{0}^{1}{|{F}^{-1}\left(t\right)-{G}^{-1}\left(t\right)|}^{p}dt,$$

- Freitag, G.; Czado, C.; Munk, A. A nonparametric test for similarity of marginals—with applications to the assessment of population bioequivalence. J. Stat. Plan. Inference
**2007**, 137, 697–711. [Google Scholar] [CrossRef] - Munk, A.; Czado, C. Nonparametric validation of similar distributions and assessment of goodness of fit. J. R. Stat. Soc. Ser. B Stat. Methodol.
**1998**, 60, 223–241. [Google Scholar] [CrossRef] - Álvarez-Esteban, P.C.; Del Barrio, E.; Cuesta-Albertos, J.A.; Matrán, C. Similarity of samples and trimming. Bernoulli
**2012**, 18, 606–634. [Google Scholar] [CrossRef] - Alvarez-Esteban, P.C.; Del Barrio, E.; Cuesta-Albertos, J.A.; Matrán, C. Trimmed comparison of distributions. J. Am. Stat. Assoc.
**2008**, 103, 697–704. [Google Scholar] [CrossRef] - Cuesta-Albertos, J.A.; Matrán, C.; Rodriguez-Rodriguez, J.M.; del Barrio, E. Tests of goodness of fit based on the L_2-wasserstein distance. Ann. Stat.
**1999**, 27, 1230–1239. [Google Scholar] - Del Barrio, E.; Cuesta-Albertos, J.A.; Matrán, C.; Csörgö, S.; Cuadras, C.M.; de Wet, T.; Giné, E.; Lockhart, R.; Munk, A.; Stute, W. Contributions of empirical and quantile processes to the asymptotic theory of goodness-of-fit tests. Test
**2000**, 9, 1–96. [Google Scholar] [CrossRef] - Del Barrio, E.; Giné, E.; Utzet, F.; et al. Asymptotics for l2 functionals of the empirical quantile process, with applications to tests of fit based on weighted wasserstein distances. Bernoulli
**2005**, 11, 131–189. [Google Scholar] [CrossRef] - Del Barrio, E. Empirical and quantile processes in the asymptotic theory of goodness-of-fit tests. In Proceedings of European Mathematical Society Summer School on Theory and Statistical Applications of Empirical Processes, Laredo, Spain, 29 August–3 September 2004.
- Székely, G.J.; Rizzo, M.L. Testing for equal distributions in high dimension. InterStat
**2004**, 5, 1–6. [Google Scholar] - Baringhaus, L.; Franz, C. On a new multivariate two-sample test. J. Multivar. Anal.
**2004**, 88, 190–206. [Google Scholar] [CrossRef] - Gretton, A.; Borgwardt, K.; Rasch, M.; Schoelkopf, B.; Smola, A. A kernel two-sample test. J. Mach. Learn. Res.
**2012**, 13, 723–773. [Google Scholar] - Hsieh, F.; Turnbull, B.W. Nonparametric and semiparametric estimation of the receiver operating characteristic curve. Ann. Stat.
**1996**, 24, 25–40. [Google Scholar] [CrossRef] - Lehmann, E.L.; D’Abrera, H.J.M. Nonparametrics: Statistical Methods Based on Ranks; Springer: New York, NY, USA, 2006. [Google Scholar]
- Friedman, J.H.; Rafsky, L.C. Multivariate generalizations of the wald-wolfowitz and smirnov two-sample tests. Ann. Stat.
**1979**, 7, 697–717. [Google Scholar] [CrossRef] - Wald, A.; Wolfowitz, J. On a test whether two-samples are from the same population. Ann. Math. Stat.
**1940**, 11, 147–162. [Google Scholar] [CrossRef] - Schilling, M.F. Multivariate two-sample tests based on nearest neighbors. J. Am. Stat. Assoc.
**1986**, 81, 799–806. [Google Scholar] [CrossRef] - Henze, N. A multivariate two-sample test based on the number of nearest neighbor type coincidences. Ann. Stat.
**1988**, 16, 772–783. [Google Scholar] [CrossRef] - Rosenbaum, P.R. An exact distribution-free test comparing two multivariate distributions based on adjacency. J. R. Stat. Soc. Ser. B Stat. Methodol.
**2005**, 67, 515–530. [Google Scholar] [CrossRef] - Thas, O. Comparing Distributions; Springer: New York, NY, USA, 2010. [Google Scholar]
- Kolmogorov, A.N. Sulla determinazione empirica di una legge di distribuzione. Giornale dell’Istituto Italiano degli Attuari
**1933**, 4, 83–91. (In Italian) [Google Scholar] - Smirnov, N. Table for estimating the goodness of fit of empirical distributions. Ann. Math. Stat.
**1948**, 19, 279–281. [Google Scholar] [CrossRef] - Cramér, H. On the composition of elementary errors: First paper: Mathematical deductions. Scand. Actuar. J.
**1928**, 1928, 13–74. [Google Scholar] [CrossRef] - Von Mises, R. Wahrscheinlichkeit statistik und wahrheit. In Schriften zur Wissenschaftlichen Weltauffassung; Springer: Vienna, Austria, 1928. (In German) [Google Scholar]
- Anderson, T.W.; Darling, D.A. Asymptotic theory of certain “goodness of fit” criteria based on stochastic processes. Ann. Math. Stat.
**1952**, 23, 193–212. [Google Scholar] [CrossRef] - Bickel, P.J. A distribution free version of the smirnov two-sample test in the p-variate case. Ann. Math. Stat.
**1969**, 40, 1–23. [Google Scholar] [CrossRef] - Villani, C. Optimal Transport: Old and New; Springer: New York, NY, USA, 2009; Volume 338. [Google Scholar]
- Bertsimas, D.; Tsitsiklis, J.N. Introduction to Linear Optimization; Athena Scientific: Belmont, MA, USA, 1997. [Google Scholar]
- Dudley, R.M. The speed of mean Glivenko-Cantelli convergence. Ann. Math. Stat.
**1968**, 40, 40–50. [Google Scholar] [CrossRef] - Ajtai, M.; Komlós, J.; Tusnády, G. On optimal matchings. Combinatorica
**1994**, 4, 259–264. [Google Scholar] [CrossRef] - García, N.; Slepčev, D. On the rate of convergence of empirical measures in ∞-transportation distance. arXiv
**2014**. [Google Scholar] - Leighton, T.; Shor, P. Tight bounds for minimax grid matching with applications to the average case analysis of algorithms. Combinatorica
**1989**, 9, 161–187. [Google Scholar] [CrossRef] - Shor, P.W.; Yukich, J.E. Minimax grid matching and empirical measures. Ann. Probab.
**1991**, 19, 1338–1348. [Google Scholar] [CrossRef] - Schrodinger, E. Uber die Umkehrung der Naturgesetze; Akad. d. Wissenschaften: Berlin, Germany, 1931; pp. 144–153. (In German) [Google Scholar]
- Cuturi, M. Sinkhorn distances: Lightspeed computation of optimal transport. In Proceedings of the Advances in Neural Information Processing Systems 26 (NIPS 2013), Lake Tahoe, NV, USA, 5–10 December 2013; pp. 2292–2300.
- Sinkhorn, R. Diagonal equivalence to matrices with prescribed row and column sums. Am. Math. Mon.
**1967**, 74, 402–405. [Google Scholar] [CrossRef] - Franklin, J.; Lorenz, J. On the scaling of multidimensional matrices. Linear Algebra Appl.
**1989**, 114, 717–735. [Google Scholar] [CrossRef] - Gretton, A.; Borgwardt, K.M.; Rasch, M.; Schölkopf, B.; Smola, A.J. A kernel method for the two-sample-problem. arXiv
**2008**. [Google Scholar] - Fernández, V.A.; Jiménez-Gamero, M.D.; Muñoz-García, J. A test for the two-sample problem based on empirical characteristic functions. Comput. Stat. Data Anal.
**2008**, 52, 3730–3748. [Google Scholar] [CrossRef] - Rudin, W. Fourier Analysis on Groups; Interscience Publishers: New York, NY, USA, 1962. [Google Scholar]
- Lyons, R. Distance covariance in metric spaces. Ann. Probab.
**2013**, 41, 3284–3305. [Google Scholar] [CrossRef] - Sejdinovic, D.; Sriperumbudur, B.; Gretton, A.; Fukumizu, K. Equivalence of distance-based and RKHS-based statistics in hypothesis testing. Ann. Stat.
**2013**, 41, 2263–2291. [Google Scholar] [CrossRef] - Billingsley, P. Convergence of Probability Measures; John Wiley & Sons, Inc.: New York, NY, USA, 1968. [Google Scholar]
- Shorack, G.R.; Wellner, J.A. Empirical Processes with Applications to Statistics; SIAM: Philadelphia, PA, USA, 1986. [Google Scholar]
- Bickel, P.J.; Freedman, D.A. Some asymptotic theory for the bootstrap. Ann. Stat.
**1981**, 9, 1196–1217. [Google Scholar] [CrossRef] - Dobrushin, R.L. Prescribing a system of random variables by conditional distributions. Theory Probab. Appl.
**1970**, 15, 458–486. [Google Scholar] [CrossRef] - Mallows, C.L. A note on asymptotic joint normality. Ann. Math. Stat.
**1972**, 43, 508–515. [Google Scholar] [CrossRef] - Komlós, J.; Major, P.; Tusnády, G. An approximation of partial sums of independent RV’s, and the sample DF. II. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete
**1976**, 34, 33–58. [Google Scholar] [CrossRef]

© 2017 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license ( http://creativecommons.org/licenses/by/4.0/).