# Energy distance

Energy distance is a statistical distance between probability distributions. If X and Y are independent random vectors in Rd with cumulative distribution functions (cdf) F and G respectively, then the energy distance between the distributions F and G is defined to be the square root of

${\displaystyle D^{2}(F,G)=2\mathbb {E} \|X-Y\|-\mathbb {E} \|X-X'\|-\mathbb {E} \|Y-Y'\|\geq 0,}$

where (X, X', Y, Y') are independent, the cdf of X and X' is F, the cdf of Y and Y' is G, ${\displaystyle \mathbb {E} }$ is the expected value, and || . || denotes the length of a vector. Energy distance satisfies all axioms of a metric thus energy distance characterizes the equality of distributions: D(F,G) = 0 if and only if F = G. Energy distance for statistical applications was introduced in 1985 by Gábor J. Székely, who proved that for real-valued random variables ${\displaystyle D^{2}(F,G)}$ is exactly twice Harald Cramér's distance:[1]

${\displaystyle \int _{-\infty }^{\infty }(F(x)-G(x))^{2}\,dx.}$

For a simple proof of this equivalence, see Székely (2002).[2]

In higher dimensions, however, the two distances are different because the energy distance is rotation invariant while Cramér's distance is not. (Notice that Cramér's distance is not the same as the distribution-free Cramer-von-Mises criterion.)

## Generalization to metric spaces

One can generalize the notion of energy distance to probability distributions on metric spaces. Let ${\displaystyle (M,d)}$ be a metric space with its Borel sigma algebra ${\displaystyle {\mathcal {B}}(M)}$. Let ${\displaystyle {\mathcal {P}}(M)}$ denote the collection of all probability measures on the measurable space ${\displaystyle (M,{\mathcal {B}}(M))}$. If μ and ν are probability measures in ${\displaystyle {\mathcal {P}}(M)}$, then the energy-distance ${\displaystyle D}$of μ and ν can be defined as the square root of

${\displaystyle D^{2}(\mu ,\nu )=2\mathbb {E} [d(X,Y)]-\mathbb {E} [d(X,X')]-\mathbb {E} [d(Y,Y')].}$

This is not necessarily non-negative, however. If ${\displaystyle (M,d)}$ is a strongly negative definite kernel, then ${\displaystyle D}$ is a metric, and conversely.[3] This condition is expressed by saying that ${\displaystyle (M,d)}$ has negative type. Negative type is not sufficient for ${\displaystyle D}$ to be a metric; the latter condition is expressed by saying that ${\displaystyle (M,d)}$ has strong negative type. In this situation, the energy distance is zero if and only if X and Y are identically distributed. An example of a metric of negative type but not of strong negative type is the plane with the taxicab metric. All Euclidean spaces and even separable Hilbert spaces have strong negative type.[4]

In the literature on kernel methods for machine learning, these generalized notions of energy distance are studied under the name of maximum mean discrepancy.[5]

## Energy statistics

A related statistical concept, the notion of E-statistic or energy-statistic[6] was introduced by Gábor J. Székely in the 1980s when he was giving colloquium lectures in Budapest, Hungary and at MIT, Yale, and Columbia. This concept is based on the notion of Newton’s potential energy.[7] The idea is to consider statistical observations as heavenly bodies governed by a statistical potential energy which is zero only when an underlying statistical null hypothesis is true. Energy statistics are functions of distances between statistical observations.

Energy distance and E-statistic were considered as N-distances and N-statistic in Zinger A.A., Kakosyan A.V., Klebanov L.B. Characterization of distributions by means of mean values of some statistics in connection with some probability metrics, Stability Problems for Stochastic Models. Moscow, VNIISI, 1989,47-55. (in Russian), English Translation: A characterization of distributions by mean values of statistics and certain probabilistic metrics A. A. Zinger, A. V. Kakosyan, L. B. Klebanov in Journal of Soviet Mathematics (1992). In the same paper there was given a definition of strongly negative definite kernel, and provided a generalization on metric spaces, discussed above. The book [3] gives these results and their applications to statistical testing as well. The book contains also some applications to recovering the measure from its potential.

### Testing for equal distributions

Consider the null hypothesis that two random variables, X and Y, have the same probability distributions: ${\displaystyle \mu =\nu }$ . For statistical samples from X and Y:

${\displaystyle x_{1},\dots ,x_{n}}$ and ${\displaystyle y_{1},\dots ,y_{m}}$,

the following arithmetic averages of distances are computed between the X and the Y samples:

${\displaystyle A:={\frac {1}{nm}}\sum _{i=1}^{n}\sum _{j=1}^{m}\|x_{i}-y_{j}\|,B:={\frac {1}{n^{2}}}\sum _{i=1}^{n}\sum _{j=1}^{n}\|x_{i}-x_{j}\|,C:={\frac {1}{m^{2}}}\sum _{i=1}^{m}\sum _{j=1}^{m}\|y_{i}-y_{j}\|}$.

The E-statistic of the underlying null hypothesis is defined as follows:

${\displaystyle E_{n,m}(X,Y):=2A-B-C}$

One can prove [7][8] that ${\displaystyle E_{n,m}(X,Y)\geq 0}$ and that the corresponding population value is zero if and only if X and Y have the same distribution (${\displaystyle \mu =\nu }$). Under this null hypothesis the test statistic

${\displaystyle T={\frac {nm}{n+m}}E_{n,m}(X,Y)}$

converges in distribution to a quadratic form of independent standard normal random variables. Under the alternative hypothesis T tends to infinity. This makes it possible to construct a consistent statistical test, the energy test for equal distributions.[9]

The E-coefficient of inhomogeneity can also be introduced. This is always between 0 and 1 and is defined as

${\displaystyle H={\frac {D^{2}(F_{X},F_{Y})}{2\operatorname {\mathbb {E} } \|X-Y\|}}={\frac {2\mathbb {E} \|X-Y\|-\mathbb {E} \|X-X'\|-\mathbb {E} \|Y-Y'\|}{2\operatorname {\mathbb {E} } \|X-Y\|}},}$

where ${\displaystyle \mathbb {E} }$ denotes the expected value. H = 0 exactly when X and Y have the same distribution.

### Goodness-of-fit

A multivariate goodness-of-fit measure is defined for distributions in arbitrary dimension (not restricted by sample size). The energy goodness-of-fit statistic is

${\displaystyle Q_{n}=n\left({\frac {2}{n}}\sum _{i=1}^{n}\mathbb {E} \|x_{i}-X\|^{\alpha }-\mathbb {E} \|X-X'\|^{\alpha }-{\frac {1}{n^{2}}}\sum _{i=1}^{n}\sum _{j=1}^{n}\|x_{i}-x_{j}\|^{\alpha }\right),}$

where X and X' are independent and identically distributed according to the hypothesized distribution, and ${\displaystyle \alpha \in (0,2)}$. The only required condition is that X has finite ${\displaystyle \alpha }$ moment under the null hypothesis. Under the null hypothesis ${\displaystyle \mathbb {E} Q_{n}=\mathbb {E} \|X-X'\|^{\alpha }}$, and the asymptotic distribution of Qn is a quadratic form of centered Gaussian random variables. Under an alternative hypothesis, Qn tends to infinity stochastically, and thus determines a statistically consistent test. For most applications the exponent 1 (Euclidean distance) can be applied. The important special case of testing multivariate normality[8] is implemented in the energy package for R. Tests are also developed for heavy tailed distributions such as Pareto (power law), or stable distributions by application of exponents in (0,1).

## Applications

Applications include

Gneiting and Raftery[18] apply energy distance to develop a new and very general type of proper scoring rule for probabilistic predictions, the energy score.
• Robust statistics [19]
• Gene selection [20]
• Microarray data analysis[21]
• Material structure analysis[22]

Applications of energy statistics are implemented in the open source energy package[23] for R.

## References

1. ^ Cramér, H. (1928) On the composition of elementary errors, Skandinavisk Aktuarietidskrift, 11, 141–180.
2. ^ E-Statistics: The energy of statistical samples (2002) PDF
3. ^ a b Klebanov, L. B. (2005) N-distances and their Applications, Karolinum Press, Charles University, Prague.
4. ^ Lyons, R. (2013). "Distance Covariance in Metric Spaces". The Annals of Probability. 41 (5): 3284–3305. doi:10.1214/12-aop803. [1]
5. ^ Sejdinovic, D.; Sriperumbudur, B.; Gretton, A. & Fukumizu, K. (2013). "Equivalence of distance-based and RKHS-based statistics in hypothesis testing". The Annals of Statistics. 41 (5): 2263–2291. doi:10.1214/13-aos1140. [2]
6. ^ G. J. Szekely and M. L. Rizzo (2013). Energy statistics: statistics based on distances. Journal of Statistical Planning and Inference Volume 143, Issue 8, August 2013, pp. 1249-1272. [3]
7. ^ a b Székely, G.J. (2002) E-statistics: The Energy of Statistical Samples, Technical Report BGSU No 02-16.
8. ^ a b c Székely, G. J.; Rizzo, M. L. (2005). "A new test for multivariate normality". Journal of Multivariate Analysis. 93 (1): 58–80. doi:10.1016/j.jmva.2003.12.002. Reprint
9. ^ G. J. Szekely and M. L. Rizzo (2004). Testing for Equal Distributions in High Dimension, InterStat, Nov. (5). Reprint.
10. ^ Székely, G. J. and Rizzo, M. L. (2005) Hierarchical Clustering via Joint Between-Within Distances: Extending Ward's Minimum Variance Method, Journal of Classification, 22(2) 151–183
11. ^ Varin, T., Bureau, R., Mueller, C. and Willett, P. (2009). "Clustering files of chemical structures using the Szekely-Rizzo generalization of Ward's method". Journal of Molecular Graphics and Modelling. 28 (2): 187–195. doi:10.1016/j.jmgm.2009.06.006. PMID 19640752. "eprint".
12. ^ M. L. Rizzo and G. J. Székely (2010). DISCO Analysis: A Nonparametric Extension of Analysis of Variance, Annals of Applied Statistics Vol. 4, No. 2, 1034–1055. PDF
13. ^ Szekely, G. J. and Rizzo, M. L. (2004) Testing for Equal Distributions in High Dimension, InterStat, Nov. (5). Reprint.
14. ^ Ledlie, Jonathan and Pietzuch, Peter and Seltzer, Margo, (2006). Stable and Accurate Network Coordinates,. Sovetskaia meditsina. ICDCS '06,. Washington, DC, USA: IEEE Computer Society,. pp. 74–83,. doi:10.1109/ICDCS.2006.79. ISBN 0-7695-2540-7. PMID 1154085. PDF
15. ^ Albert Y. Kim; Caren Marzban; Donald B. Percival; Werner Stuetzle (2009). "Using labeled data to evaluate change detectors in a multivariate streaming environment". Signal Processing. 89 (12): 2529–2536. doi:10.1016/j.sigpro.2009.04.011. ISSN 0165-1684. [4] Preprint:TR534.
16. ^ Székely, G. J., Rizzo M. L. and Bakirov, N. K. (2007). "Measuring and testing independence by correlation of distances", The Annals of Statistics, 35, 2769–2794. PDF
17. ^ Székely, G. J. and Rizzo, M. L. (2009). "Brownian distance covariance", The Annals of Applied Statistics, 3/4, 1233–1308. PDF
18. ^ T. Gneiting; A. E. Raftery (2007). "Strictly Proper Scoring Rules, Prediction, and Estimation". Journal of the American Statistical Association. 102 (477): 359–378. doi:10.1198/016214506000001437. Reprint
19. ^ Klebanov L.B. A class of Probability Metrics and its Statistical Applications, Statistics in Industry and Technology: Statistical Data Analysis, Yadolah Dodge, Ed. Birkhauser, Basel, Boston, Berlin, 2002,241-252.
20. ^ Statistics and Data Analysis, 2006, 50, 12, 3619-3628Rui Hu, Xing Qiu, Galina Glazko, Lev Klebanov, Andrei Yakovlev Detecting intergene correlation changes in microarray analysis: a new approach to gene selection, BMCBioinformatics, Vol.10, 20 (2009), 1-15.
21. ^ Yuanhui Xiao, Robert Frisina, Alexander Gordon, Lev Klebanov, Andrei Yakovlev Multivariate Search for Differentially Expressed Gene Combinations BMC Bioinformatics, 2004, 5:164; Antoni Almudevar, Lev Klebanov, Xing Qiu, Andrei Yakovlev Utility of correlation measures in analysis of gene expression, In: NeuroRX, 2006, 3, 3, 384-395; Klebanov Lev, Gordon Alexander, Land Hartmut, Yakovlev Andrei A permutation test motivated by microarray data analysis
22. ^ Viktor Benes, Radka Lechnerova, Lev Klebanov, Margarita Slamova, Peter Slama Statistical comparison of the geometry of second-phase particles, Materials Characterization , Vol. 60 (2009 ), 1076 - 1081.
23. ^ "energy: R package version 1.6.2". Retrieved 30 January 2015.