{'fraction_non_alphanumeric': 0.04610009017132552, 'fraction_numerical': 0.01608994589720469, 'mean_word_length': 4.356021732568669, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Hypothesis testing using pairwise distances and associated kernels (with Appendix)

We provide a unifying framework linking two classes of statistics used in two-sample and independence testing: on the one hand, the energy distances and distance covariances from the statistics literature; on the other, distances between embeddings of distributions to reproducing kernel Hilbert spaces (RKHS), as established in machine learning. The equivalence holds when energy distances are computed with semimetrics of negative type, in which case a kernel may be defined such that the RKHS distance between distributions corresponds exactly to the energy distance. We determine the class of probability distributions for which kernels induced by semimetrics are characteristic (that is, for which embeddings of the distributions to an RKHS are injective). Finally, we investigate the performance of this family of kernels in two-sample and independence tests: we show in particular that the energy distance most commonly employed in statistics is just one member of a parametric family of kernels, and that other choices from this family can yield more powerful tests.


Introduction
The problem of testing statistical hypotheses in high dimensional spaces is particularly challenging, and has been a recent focus of considerable work in the statistics and machine learning communities. On the statistical side, two-sample testing in Euclidean spaces (of whether two independent samples are from the same distribution, or from different distributions) can be accomplished using a so-called energy distance as a statistic (Székely & Rizzo, 2004;2005). Such tests are consistent against all alternatives as long as the random variables have finite first moments. A related dependence measure between vectors of high dimension is the distance covariance (Székely et al., 2007;Székely & Rizzo, 2009), and the resulting test is again consistent for variables with bounded first moment. The distance covariance has had a major impact in the statistics community, with Székely & Rizzo (2009) being accompanied by an editorial introduction and discussion. A particular advantage of energy distance-based statistics is their compact representation in terms of certain expectations of pairwise Euclidean distances, which leads to straightforward empirical estimates. As a follow-up work, Lyons (2011) generalized the notion of distance covariance to metric spaces of negative type (of which Euclidean spaces are a special case).
On the machine learning side, two-sample tests have been formulated based on embeddings of probability distributions into reproducing kernel Hilbert spaces (Gretton et al., 2012), using as the test statistic the difference between these embeddings: this statistic is called the maximum mean discrepancy (MMD). This distance measure was applied to the problem of testing for independence, with the associated test statistic being the Hilbert-Schmidt Independence Criterion (HSIC) (Gretton et al., 2005a;Smola et al., 2007;Zhang et al., 2011). Both tests are shown to be consistent against all alternatives when a characteristic RKHS is used Sriperumbudur et al., 2010). Such tests can further be generalized to structured and non-Euclidean domains, such as text strings, graphs or groups .
Despite their striking similarity, the link between energy distance-based tests and kernel-based tests has been an open question.
In the discussion of Székely & Rizzo (2009), Gretton et al. (2009bGretton et al. ( , p. 1289 first explored this link in the context of independence testing, and stated that interpreting the distance-based independence statistic as a kernel statistic is not straightforward, since Bochner's theorem does not apply to the choice of weight function used in the definition of Brownian distance covariance (we briefly review this argument in Section A.3 of the Appendix). Székely & Rizzo (2009, Rejoinder, p. 1303) confirmed this conclusion, and commented that RKHS-based dependence measures do not seem to be formal extensions of Brownian distance covariance because the weight function is not integrable. Our contribution resolves this question and shows that RKHSbased dependence measures are precisely the formal extensions of Brownian distance covariance, where the problem of non-integrability of weight functions is circumvented by using translation-variant kernels, i.e., distance-induced kernels, a novel family of kernels that we introduce in Section 2.2.
In the case of two-sample testing, we demonstrate that energy distances are in fact maximum mean discrepancies arising from the same family of distance-induced kernels. A number of interesting consequences arise from this insight: first, we show that the energy distance (and distance covariance) derives from a particular parameter choice from a larger family of kernels: this choice may not yield the most sensitive test. Second, results from Gretton et al. (2009a); Zhang et al. (2011) may be applied to get consistent two-sample and independence tests for the energy distance, without using bootstrap, which perform much better than the upper bound proposed by Székely et al. (2007) as an alternative to the bootstrap. Third, in relation to Lyons (2011), we obtain a new family of characteristic kernels arising from semimetric spaces of negative type (where the triangle inequality need not hold), which are quite unlike the characteristic kernels defined via Bochner's theorem (Sriperumbudur et al., 2010).
The structure of the paper is as follows: In Section 2, we provide the necessary definitions from RKHS theory, and the relation between RKHS and semimetrics of negative type. In Section 3.1, we review both the energy distance and distance covariance. We relate these quantities in Sections 3.2 and 3.3 to the Maximum Mean Discrepancy (MMD) and the Hilbert-Schmidt Independence Criterion (HSIC), respectively. We give conditions for these quantities to distinguish between probability measures in Section 4, thus obtaining a new family of characteristic kernels. Empirical estimates of these quantities and associated twosample and independence tests are described in Sec-tion 5. Finally, in Section 6, we investigate the performance of the test statistics on a variety of testing problems, which demonstrate the strengths of the new kernel family.

Definitions and Notation
In this section, we introduce concepts and notation required to understand reproducing kernel Hilbert spaces (Section 2.1), and distribution embeddings into RKHS. We then introduce semimetrics (Section 2.2), and review the relation of semimetrics of negative type to RKHS kernels.

RKHS Definitions
Unless stated otherwise, we will assume that Z is any topological space.
. If H has a reproducing kernel, it is called a reproducing kernel Hilbert space (RKHS).
According to the Moore-Aronszajn theorem (Berlinet & Thomas-Agnan, 2004, p. 19), for every symmetric, positive definite function k : Z × Z → R, there is an associated RKHS H k of real-valued functions on Z with reproducing kernel k. The map ϕ : Z → H k , ϕ : z → k(·, z) is called the canonical feature map or the Aronszajn map of k. We will say that k is a nondegenerate kernel if its Aronszajn map is injective.

Semimetrics of Negative Type
We will work with the notion of semimetric of negative type on a non-empty set Z, where the "distance" function need not satisfy the triangle inequality. Note that this notion of semimetric is different to that which arises from the seminorm, where distance between two distinct points can be zero (also called pseudonorm).
Therefore, by taking q = 1/2, we conclude that all Euclidean spaces are of negative type. While Lyons (2011, p. 9) also uses the result in Proposition 4, he studies embeddings to general Hilbert spaces, and the relation with the theory of reproducing kernel Hilbert spaces is not exploited. Semimetrics of negative type and symmetric positive definite kernels are in fact closely related, as summarized in the following Lemma based on Berg et al. (1984, Lemma 2.1, p. 74).
We call the kernel k defined above the distance-induced kernel, and say that it is induced by the semimetric ρ. For brevity, we will drop "induced" hereafter, and say that k is simply the distance kernel (with some abuse of terminology). In addition, we will typically work with distance kernels scaled by 1/2. Note that k(z 0 , z 0 ) = 0, so distance kernels are not strictly positive definite (equivalently, k(·, z 0 ) = 0). By varying "the point at the center" z 0 , one obtains a family K ρ = 1 2 [ρ(z, z 0 ) + ρ(z ′ , z 0 ) − ρ(z, z ′ )] z0∈Z of distance kernels induced by ρ. We may now express (2) from Proposition 4 in terms of the canonical feature map for the RKHS H k (proof in Appendix A.1).
Note that Proposition 7 implies that the Aronszajn map z → k(·, z) is an isometric embedding of a metric space (Z, ρ 1/2 ) into H k , for every k ∈ K ρ .

Kernels Inducing Semimetrics
We now further develop the link between semimetrics of negative type and kernels. Let k be any nondegenerate reproducing kernel on Z (for example, every strictly positive definite k is nondegenerate). Then, by Proposition 4, defines a valid semimetric ρ of negative type on Z.
We will say that k generates ρ. It is clear that every distance kernelk ∈ K ρ also generates ρ, and thatk can be expressed as: for some z 0 ∈ Z. In addition, k ∈ K ρ if and only if k(z 0 , z 0 ) = 0 for some z 0 ∈ Z. Hence, it is clear that any strictly positive definite kernel, e.g., the Gaussian kernel e −σ z−z ′ 2 , is not a distance kernel. Example 8. Let Z = R d and write ρ q (z, z ′ ) = z − z ′ q . By combining Propositions 4 and 5, ρ q is a valid semimetric of negative type for 0 < q ≤ 2. It is a metric of negative type if q ≤ 1. The corresponding distance kernel "centered at zero" is given by Example 9. Let Z = R d , and consider the Gaussian kernel k(z, z ′ ) = e −σ z−z ′ 2 . The induced semimetric is ρ(z, z ′ ) = 2 1 − e −σ z−z ′ 2 . There are many other kernels that generate ρ, however; for example, the distance kernel induced by ρ and "centered at zero" is

Distances and Covariances
In this section, we begin with a description of the energy distance, which measures distance between distributions; and distance covariance, which measures dependence. We then demonstrate that the former is a special instance of the maximum mean discrepancy (a kernel measure of distance on distributions), and the latter an instance of the Hilbert-Schmidt Independence criterion (a kernel dependence measure). We will denote by M(Z) the set of all finite signed Borel measures on Z, and by M 1 + (Z) the set of all Borel probability measures on Z. Székely & Rizzo (2004;2005) use the following measure of statistical distance between two probability measures P and Q on R d , termed the energy distance:

Energy Distance and Distance Covariance
where Z, This quantity characterizes the equality of distributions, and in the scalar case, it coincides with twice the Cramer-Von Mises distance. We may generalize it to a semimetric space of negative type (Z, ρ), with the expression for this generalized distance covariance D E,ρ (P, Q) being of the same form as (6), with the Euclidean distance replaced by ρ. Note that the negative type of ρ implies the non-negativity of D E,ρ . In Section 3.2, we will show that for every ρ, D E,ρ is precisely the MMD associated to a particular kernel k on Z. Now, let X be a random vector on R p and Y a random vector on R q . The distance covariance was introduced in Székely et al. (2007); Székely & Rizzo (2009) to address the problem of testing and measuring dependence between X and Y , in terms of a weighted L 2distance between characteristic functions of the joint distribution of X and Y and the product of their marginals. Given a particular choice of weight function, it can be computed in terms of certain expectations of pairwise Euclidean distances, Lyons (2011) established that the generalization of the distance covariance is possible to metric spaces of negative type, with the expression for this generalized distance covariance V 2 ρX ,ρY (X, Y ) being of the same form as (7), with Euclidean distances replaced by metrics of negative type ρ X and ρ Y on domains X and Y , respectively. In Section 3.3, we will show that the generalized distance covariance of a pair of random variables X and Y is precisely HSIC associated to a particular kernel k on the product of domains of X and Y .

Maximum Mean Discrepancy
The notion of the feature map in an RKHS (Section 2.1) can be extended to kernel embeddings of probability measures (Berlinet & Thomas-Agnan, 2004;Sriperumbudur et al., 2010).
Definition 10. (Kernel embedding) Let k be a kernel on Z, and P ∈ M 1 + (Z). The kernel embedding Alternatively, the kernel embedding can be defined by the Bochner expectation µ k (P ) = E Z∼P k(·, Z). By the Riesz representation theorem, a sufficient condition for the existence of µ k (P ) is that k is Borelmeasurable and that E Z∼P k 1/2 (Z, Z) < ∞. If k is a bounded continuous function, this is obviously true for all P ∈ M 1 + (Z). Kernel embeddings can be used to induce metrics on the spaces of probability measures, giving the maximum mean discrepancy (MMD), If the restriction of µ k to some P(Z) ⊆ M 1 + (Z) is well defined and injective, then k is said to be characteristic to P(Z), and it is said to be characteristic (without further qualification) if it is characteristic to M 1 Conditions under which kernels are characteristic have been studied by Sriperumbudur et al. (2008); Fukumizu et al. (2009);Sriperumbudur et al. (2010). An alternative interpretation of (8) is as an integral probability metric (Müller, 1997): see Gretton et al. (2012) for details.
In general, distance kernels are continuous but unbounded functions. Thus, kernel embeddings are not defined for all Borel probability measures, and one needs to restrict the attention to a class of Borel probability measures for which E Z∼P k 1/2 (Z, Z) < ∞ when discussing the maximum mean discrepancy. We will assume that all Borel probability measures considered satisfy a stronger condition that E Z∼P k(Z, Z) < ∞ (this reflects a finite first moment condition on random variables considered in distance covariance tests, and will imply that all quantities appearing in our results are well defined). For more details, see Section A.4 in the Appendix. As an alternative to requiring this condition, one may assume that the underlying semimetric space (Z, ρ) of negative type is itself bounded, i.e., that sup z,z ′ ∈Z ρ(z, z ′ ) < ∞.
We are now able to describe the relation between the maximum mean discrepancy and the energy distance. The following theorem is a consequence of Lemma 6, and is proved in Section A.1 of the Appendix.
Theorem 11. Let (Z, ρ) be a semimetric space of negative type and let z 0 ∈ Z. The distance kernel k induced by ρ satisfies γ 2 k (P, Q) = 1 2 D E,ρ (P, Q). In particular, γ k does not depend on the choice of z 0 .
There is a subtlety to the link between kernels and semimetrics, when used in computing the distance on probabilities. Consider again the family of distance kernels K ρ , where the semimetric ρ is itself generated from k according to (3). As we have seen, it may be that k / ∈ K ρ , however it is clear that γ 2 k (P, Q) = 1 2 D E,ρ (P, Q) whenever k generates ρ. Thus, all kernels that generate the same semimetric ρ on Z give rise to the same metric γ k on (possibly a subset of) M 1 + (Z), and γ k is merely an extension of the metric ρ 1/2 on the point masses. The kernel-based and distance-based methods are therefore equivalent, provided that we allow "distances" ρ which may not satisfy the triangle inequality.

The Hilbert-Schmidt Independence Criterion
Given a pair of jointly observed random variables (X, Y ) with values in X × Y, the Hilbert-Schmidt Independence Criterion (HSIC) is computed as the maximum mean discrepancy between the joint distribution P XY and the product of its marginals P X P Y . Let k X and k Y be kernels on X and Y, with respective RKHSs H kX and H kY . Following Smola et al. (2007, Section 2.3), we consider the MMD associated to the kernel where in the last step we used that It can be shown that this quantity is the squared Hilbert-Schmidt norm of the covariance operator between RKHSs (Gretton et al., 2005b). The following theorem demonstrates the link between HSIC and the distance covariance, and is proved in Appendix A.1.
We remark that a similar result to Theorem 12 is given by Lyons (2011, Proposition 3.16), but without making use of the RKHS equivalence. Theorem 12 is a more general statement, in the sense that we allow ρ to be a semimetric of negative type, rather than a metric. In addition to yielding a more general statement, the RKHS equivalence leads to a significantly simpler proof: the result is an immediate application of the HSIC expansion of Smola et al. (2007).

Distinguishing Probability Distributions
Lyons (2011, Theorem 3.20) shows that distance covariance in a metric space characterizes independence if the metrics satisfy an additional property, termed strong negative type. We will extend this notion to a semimetric ρ. We will say that P ∈ M 1 + (Z) has a finite first moment w.r.t. ρ if´ρ(z, z 0 )dP is finite for some z 0 ∈ Z. It is easy to see that the integraĺ ρ d ([P − Q] × [P − Q]) = −D E,ρ (P, Q) converges whenever P and Q have finite first moments w.r.t. ρ. In Appendix A.4, we show that this condition is equivalent to E Z∼P k(Z, Z) < ∞, for a kernel k that generates ρ, which implies the kernel embedding µ k (P ) is also well defined. Definition 13. The semimetric space (Z, ρ) is said to have a strong negative type if ∀P, Q ∈ M 1 + (Z) with finite first moment w.r.t. ρ, The quantity in (10) is exactly −2γ 2 k (P, Q) for all P, Q with finite first moment w.r.t. ρ. We directly obtain: Proposition 14. Let kernel k generate ρ. Then (Z, ρ) has a strong negative type if and only if k is characteristic to all probability measures with finite first moment w.r.t. ρ.
Thus, the problems of checking whether a semimetric is of strong negative type and whether its associated kernel is characteristic to an appropriate space of Borel probability measures are equivalent. This conclusion has some overlap with Lyons (2011): in particular, Proposition 14 is stated in Lyons (2011, Proposition 3.10), where the barycenter map β is a kernel embedding in our terminology, although Lyons does not consider distribution embeddings in an RKHS.

Empirical Estimates and Hypothesis Tests
In the case of two-sample testing, we are given i.i.d.
Recall that if we use a distance kernel k induced by a semimetric ρ, this estimate involves only the pairwise ρ-distances between the sample points.
In the case of independence testing, we are given i.i.d.
∼ P XY , and the resulting V-statistic estimate (HSIC) is (Gretton et al., 2005a; where K X , K Y and H are m × m matrices given by . As in the twosample case, if both k X and k Y are distance kernels, the test statistic involves only the pairwise distances between the samples, i.e., kernel matrices in (12) may be replaced by distance matrices.
We would like to design distance-based tests with an asymptotic Type I error of α, and thus we require an estimate of the (1 − α)-quantile of the Vstatistic distribution under the null hypothesis. Under the null hypothesis, both (11) and (12) converge to a particular weighted sum of chi-squared distributed independent random variables (for more details, see Section A.2). We investigate two approaches, both of which yield consistent tests: a bootstrap approach (Arcones & Giné, 1992), and a spectral approach (Gretton et al., 2009a;Zhang et al., 2011). The latter requires empirical computation of the spectrum of kernel integral operators, a problem studied extensively in the context of kernel PCA (Schölkopf et al., 1997). In the two-sample case, one computes the eigenvalues of the centred Gram ma-trixK = HKH on the aggregated samples. Here, K is a 2m × 2m matrix, with entries K ij = k(u i , u j ), u = [z w] is the concatenation of the two samples and H is the centering matrix. Gretton et al. (2009a) show that the null distribution defined using these finite sample estimates converges to the population distribution, provided that the spectrum is square-root summable. The same approach can be used for a consistent finite sample null distribution of HSIC, via computation of the eigenvalues ofK X = HK X H and K Y = HK Y H (Zhang et al., 2011). Both Székely & Rizzo (2004, p. 14) and Székely et al. (2007Székely et al. ( , p. 2782Székely et al. ( -2783 establish that the energy distance and distance covariance statistics, respectively, converge to a particular weighted sum of chi-squares of form similar to that found for the kernel-based statistics. Analogous results for the generalized distance covariance are presented by Lyons (2011, p. 7-8). These works do not propose test designs that attempt to estimate the coefficients in such representations of the null distribution, however (note also that these coefficients have a more intuitive interpretation using kernels). Besides the bootstrap, Székely et al. (2007, Theorem 6) also proposes an independence test using a bound applicable to a general quadratic form Q of centered Gaussian random variables with E[Q] = 1: ≤ α, valid for 0 < α ≤ 0.215. When applied to the distance covariance statistic, the upper bound of α is achieved if X and Y are independent Bernoulli variables. The authors remark that the resulting criterion might be over-conservative. Thus, more sensitive tests are possible by computing the spectrum of the centred Gram matrices associated to distance kernels, and we pursue this approach in the next section.

Two-sample Experiments
In the two-sample experiments, we investigate three different kinds of synthetic data. In the first, we compare two multivariate Gaussians, where the means differ in one dimension only, and all variances are equal. In the second, we again compare two multivariate Gaussians, but this time with identical means in all dimensions, and variance that differs in a single dimension. In our third experiment, we use the benchmark data of Sriperumbudur et al. (2009): one distribution is a univariate Gaussian, and the second is a univariate Gaussian with a sinusoidal perturbation of increasing frequency (where higher frequencies correspond to harder problems). All tests use a distance kernel induced by the Euclidean distance. As shown on the left plots in Figure 1, the spectral and bootstrap test designs appear indistinguishable, and they significantly outperform the test designed using the quadratic form bound, which appears to be far too conservative for the data sets considered. This is confirmed by checking the Type I error of the quadratic form test, which is significantly smaller than the test size of α = 0.05.
We also compare the performance to that of the Gaussian kernel, with the bandwidth set to the median distance between points in the aggregation of samples. We see that when the means differ, both tests perform similarly. When the variances differ, it is clear that the Gaussian kernel has a major advantage over the dis-  tance kernel, although this advantage decreases with increasing dimension (where both perform poorly). In the case of a sinusoidal perturbation, the performance is again very similar.
In addition, following Example 8, we investigate the performance of kernels obtained using the semimetric ρ(z, z ′ ) = z − z ′ q for 0 < q ≤ 2. Results are presented in the right hand plots of Figure 1. While judiciously chosen values of q offer some improvement in the cases of differing mean and variance, we see a dramatic improvement for the sinusoidal perturbation, compared with the case q = 1 and the Gaussian kernel: values q = 1/3 (and smaller) yield virtually error-free performance even at high frequencies (note that q = 1 corresponds to the energy distance described in Székely & Rizzo (2004;2005)). Additional experiments with real-world data are presented in Appendix A.6.
We observe from the simulation results that distance kernels with higher exponents are advantageous in cases where distributions differ in mean value along a single dimension (with noise in the remainder), whereas distance kernels with smaller exponents are  Figure 2. HSIC using distance kernels with various exponents and a Gaussian kernel as a function of (left) the angle of rotation for the dependence induced by rotation; (right) frequency ℓ in the sinusoidal dependence example. more sensitive to differences in distributions at finer lengthscales (i.e., where the characteristic functions of the distributions differ at higher frequencies). This observation also appears to hold true on the real-world data experiments in Appendix A.6.

Independence Experiments
To assess independence tests, we used an artificial benchmark proposed by Gretton et al. (2008): we generate univariate random variables from the ICA benchmark densities of Bach & Jordan (2002); rotate them in the product space by an angle between 0 and π/4 to introduce dependence; fill additional dimensions with independent Gaussian noise; and, finally, pass the resulting multivariate data through random and independent orthogonal transformations. The resulting random variables X and Y are dependent but uncorrelated. The case m = 1024 (sample size) and d = 4 (dimension) is plotted in Figure 2 (left). As observed by Gretton et al. (2009b), the Gaussian kernel does better than the distance kernel with q = 1. By varying q, however, we are able to obtain a wide range of performance; in particular, the values q = 1/6 (and smaller) have an advantage over the Gaussian kernel on this dataset, especially in the case of smaller angles of rotation. As for the two-sample case, bootstrap and spectral tests have indistinguishable performance, and are significantly more sensitive than the quadratic form based test, which failed to reject the null hypothesis of independence on this dataset.
In addition, we assess the test performance on sinusoidally dependent data. The distribution over the random variable pair X, Y was drawn from P XY ∝ 1 + sin(ℓx) sin(ℓy) for integer ℓ, on the support X × Y, where X := [−π, π] and Y := [−π, π]. In this way, increasing ℓ caused the departure from a uniform (independent) distribution to occur at increasing frequencies, making this departure harder to detect from a small sample size. Results are in Figure 2 (right). We note that the distance covariance outperforms the Gaussian kernel on this example, and that smaller exponents result in better performance (lower Type II error when the departure from independence occurs at higher frequencies). Finally, we note that the setting q = 1, which is described in Székely et al. (2007); Székely & Rizzo (2009), is a reasonable heuristic in practice, but does not yield the most powerful tests on either dataset.

Conclusion
We have established an equivalence between the energy distance and distance covariance, and RKHS measures of distance between distributions. In particular, energy distances and RKHS distance measures coincide when the kernel is induced by a semimetric of negative type. The associated family of kernels performs well in two-sample and independence testing: interestingly, the parameter choice most commonly used in the statistics literature does not yield the most powerful tests in many settings.
The interpretation of the energy distance and distance covariance in an RKHS setting should be of considerable interest both to statisticians and machine learning researchers, since the associated kernels may be used much more widely: in conditional dependence testing and estimates of the chi-squared distance , in Bayesian inference , in mixture density estimation (Sriperumbudur, 2011) and in other machine learning applications. In particular, the link with kernels makes these applications of the energy distance immediate and straightforward. Finally, for problem settings defined most naturally in terms of distances, and where these distances are of negative type, there is an interpretation in terms of reproducing kernels, and the learning machinery from the kernel literature can be brought to bear.
Proof. (Theorem 11) Follows directly by inserting the distance kernel from Lemma 6 into (8), and cancelling out the terms dependant on a single random variable. Define θ := γ 2 k (P, Q).
Proof. (Theorem 12) First, we note that k is a valid reproducing kernel since k ((x, y) , , and k Y (y, y ′ ) = ρ Y (y, y 0 )+ρ Y (y ′ , y 0 )−ρ Y (y, y ′ ), as distance kernels induced by ρ X and ρ Y , respectively. Indeed, a product of two reproducing kernels is always a valid reproducing kernel on the product space (Steinwart & Christmann, 2008, Lemma 4.6, p. 114). To show equality to distance covariance, we start by expanding θ := γ 2 k (P XY , P X P Y ), Note that The claim now follows by inserting the resulting expansions and cancelling the appropriate terms. Note that only the leading terms in the expansions remain.
Remark 15. It turns out that k is not characteristic to M 1 + (X × Y) -i.e., it cannot distinguish between any two distributions on X × Y, even if k X and k Y are characteristic. However, since γ k is equal to the Brownian distance covariance, we know that it can always distinguish between any P XY and its product of marginals P X P Y in the Euclidean case. Namely, note that k((x 0 , y), (x 0 , y ′ )) = k((x, y 0 ), (x ′ , y 0 )) = 0 for all x, x ′ ∈ X , y, y ′ ∈ Y. That means that for every two distinct P Y , Q Y ∈ M 1 + (Y), one has γ 2 k (δ x0 P Y , δ x0 Q Y ) = 0. Thus, kernel in (9) characterizes independence but not equality of probability measures on the product space. Informally speaking, the independence testing is an easier problem than homogeneity testing on the product space.

A.2. Spectral Tests
Assume that the null hypothesis holds, i.e., that P = Q. For a kernel k and a Borel probability measure P , define a kernel "centred" at P : ∼ P . Note that as a special case for P = δ z0 we recover the family of kernels in (4), and that E ZZ ′k P (Z, Z ′ ) = 0, i.e., µk P (P ) = 0. The centred kernel is important in characterizing the null distribution of the V-statistic. To the centred kernelk P on domain Z, one associates the integral kernel operator Sk P : L 2 P (Z) → L 2 P (Z) (see Steinwart & Christmann, 2008, p. 126-127), given by: The following theorem is a special case of Gretton et al. (2012, Theorem 12 where N i are the eigenvalues of the operator Sk P . Note that this result requires that the integral kernel operator associated to the underlying probability measure P is a trace class operator, i.e., that E Z∼P k(Z, Z) < ∞. As before, the sufficient condition for this to hold for all probability measures is that k is a bounded function. In the case of a distance kernel, this is the case if the domain Z has a bounded diameter with respect to the semimetric ρ, i.e., that sup z,z ′ ∈Z ρ(z, z ′ ) < ∞.
The null distribution of HSIC takes an analogous form to (14) of a weighted sum of chi-squares, but with coefficients corresponding to the products of the eigenvalues of integral operators Sk P X and Sk P Y . The following Theorem is in Zhang et al. (2011, Theorem 4) and gives an asymptotic form for the null distribution of HSIC. See also Lyons (2011, Remark 2.9).
where N i,j ∼ N (0, 1), i, j ∈ N, are independent and Note that if X and Y have bounded diameters w.r.t. ρ X and ρ Y , Theorem 17 applies to distance kernels induced by ρ X and ρ Y for all P X ∈ M 1 + (X ), P Y ∈ M 1 + (Y) .

A.3. A Characteristic Function Based Interpretation
The distance covariance in (7) was defined by Székely et al. (2007) in terms of a weighted distance between characteristic functions. We briefly review this interpretation here, however we show that this approach cannot be used to derive a kernel-based measure of dependence (this result was first noted by Gretton et al. (2009b), and is included here in the interests of completeness). Let X be a random vector on X =R p and Y a random vector on Y = R q . The characteristic function of X and Y , respectively, will be denoted by f X and f Y , and their joint characteristic function by for a particular choice of weight function given by where c d = π 1+d 2 /Γ( 1+d 2 ), d ≥ 1. An important aspect of distance covariance is that V(X, Y ) = 0 if and only if X and Y are independent. We next obtain a similar statistic in the kernel setting. Write Z = X × Y, and let k(z, z ′ ) = κ(z −z ′ ) be a translation invariant RKHS kernel on Z, where κ : Z → R is a bounded continuous function. Using Bochner's theorem, κ can be written as: for a finite non-negative Borel measure Λ. It follows Gretton et al. (2009b) that which is in clear correspondence with (16). However, the weight function in (17) is not integrable -so one cannot find a translation invariant kernel for which γ k coincides with the distance covariance. By contrast, note the kernel in (9) is not translation invariant.

A.4. Restriction on Probability Measures
In general, distance kernels and their products are continuous but unbounded, so kernel embeddings are not defined for all Borel probability measures. Thus, one needs to restrict the attention to a particular class of Borel probability measures for which kernel embeddings exist, and a sufficient condition for this is that E Z∼P k 1/2 (Z, Z) < ∞, by the Riesz representation theorem. Let k be a measurable reproducing kernel on Z, and denote, for θ > 0,

A.5. Distance Correlation
The notion of distance covariance extends naturally to that of distance variance V 2 (X) = V 2 (X, X) and that of distance correlation (in analogy to the Pearson product-moment correlation coefficient): Distance correlation also has a straightforward interpretation in terms of kernels as: where covariance operator Σ XY : H kX → H kY is a linear operator for which , for all f ∈ H kX and g ∈ H kY , and · HS denotes the Hilbert-Schmidt norm (Gretton et al., 2005b). It is clear that R is invariant to scaling (X, Y ) → (ǫX, ǫY ), ǫ > 0, whenever the corresponding semimetrics are homogeneous, i.e., whenever ρ X (ǫx, ǫx ′ ) = ǫρ X (x, x ′ ), and similarly for ρ Y . Moreover, R is invariant to translations (X, Y ) → (X + x ′ , Y + y ′ ), x ′ ∈ X , y ′ ∈ Y, whenever ρ X and ρ Y are translation invariant.

A.6. Further Experiments
We assessed performance of two-sample tests based on distance kernels with various exponents and compared it to that of a Gaussian kernel on real-world multivariate datasets: Health st. (microarray data from normal and tumor tissues), Subtype (microarray data from different subtypes of cancer) and Neural I/II (local field potential (LFP) electrode recordings from the Macaque primary visual cortex (V1) with and without spike events), all discussed in Gretton et al. (2009a). In contrast to Gretton et al. (2009a), we used smaller sample sizes, so that some Type II error persists. At higher sample sizes, all tests exhibit Type II error which is virtually zero. The results are reported in Table 1 below. We used the spectral test for all experiments, and the reported averages are obtained by running 1000 trials. We note that for dataset Subtype which is high dimensional but with only a small number of dimensions varying in mean, a larger exponent results in a test of greater power.