I would like to run some two dimensional Kolmogorov–Smironov tests to determine whether a twodimensional distribution fits with a reference.
Is there any package or application that I could use in a relatively straightforward fashion? Or is there a different algorithm that is preferrable? I have just a basic statistical knowledge.
Answer
Python implementation
I have written a python implementation using numpy. You can find the code here, you may find more infomation in the docstring in the code.
And here’s another one (not by me). This Notebook provide a Python implementation for 2D KS test with 2 samples. The .py
file can be downloaded here. The code seems to be a straight translation of C
code, the efficiency might be a problem if sample size is large.
However you’d better check the codes (no matter which one) with the original papers/books before you use. The python implementations of 2d KS test are far less checked than the ones in R.
More infomation
The algorithm is first developed in two papers (as I see)
 Peacock, J.A. 1983, TwoDimensional GoodnessofFit Testing in Astronomy
 Fasano, G. and Franceschini, A. 1987, A Multidimensional Version of the KolmogorovSmirnov Test.
A nice introduction and the C
implementation can be found in

Press, W.H. et al. 1992, Numerical Recipes in C, Section 14.7, p645.
You can find
C++/Fortran
implementation in other versions of the book.
Here’s a post titled Beware the KolmogorovSmirnov test is also related to the subject, you may want to have a look. It encourages using resample method to evaluate the pvalue with given KS distance.
Attribution
Source : Link , Question Author : Manuel J Gomez , Answer Author : Community