# Is there a multivariate two-sample Kolmogorov–Smirnov test?

Is there a multivariate alternative to two-sample Kolmogorov–Smirnov test? What I mean is a test that can be used to check whenever two underlying multidimensional distributions differ.

• I am facing the same question. Have you learned anything useful and made any conclusions? I do see the answer, but beyond it I wonder about your experience with the suggestions and what worked best. Commented Mar 31, 2021 at 14:06
• @RichardHardy nope.
– Tim
Commented Mar 31, 2021 at 14:22

A 2004 article On a new multivariate two-sample test by Baringhaus and Franz maybe helpful, they provided a brief literature review on the two-sample multivariate GoF tests and then a R package cramer. As the package name suggested their method is related to Cramer's test, a predecessor of Cramer-von Mises.

For one-sample problem Justel et al. developed a generalization of Kolmogorov-Smirnov test. In general it seems the difficulty in multivariate case rooted from extending the definition of EDF (empirical distribution function), so methods based on other measures are worth exploring, e.g. multivariate tests based on ECF (empirical characteristic function) by Fan.

• Please spell out abbrevs EDF, ECF Commented Apr 13, 2017 at 22:24
• @kjetilbhalvorsen: fixed, though it's quite clear what they are once click the links provided. Commented Apr 13, 2017 at 23:00
• Is there a python implementation of this? Commented May 4, 2022 at 21:15
• @CarlosMougan: Not that I know of. But you can find the source code in the package page I linked (or here), which doesn't seem to be too difficult to convert to python. Commented Jun 15, 2022 at 10:02

Yes, the two sample KS test was extended to the multivariate case in 2021. https://www.sciencedirect.com/science/article/pii/S016771522100050X

• While the link maybe helpful in answering OP's query, in the long run, link only answers prove useless once the link dies. So, it would be appreciable if you are able to jot down the crux of what has been presented there. Commented Jan 2, 2023 at 17:06

For a practical application of the multivariate KS distance in high dimensions, see my article New Python Library to Evaluate AI-generated Data and Compare Models. I actually created a Python library to do the computations.