View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Two-dimensional (2D) paired Kolmogorov-Smirnov test

5.0 | 1 rating Rate this file 17 Downloads (last 30 days) File Size: 2.6 KB File ID: #38617 Version: 1.2

Two-dimensional (2D) paired Kolmogorov-Smirnov test


Dylan Muir (view profile)


16 Oct 2012 (Updated )

Performs a two-sample, two-tailed, two-dimensional Kolmogorov-Smirnov test, with accurate p-values

| Watch this File

File Information

The two-sample Kolmogorov-Smirnov test is a statistical test used to determine whether two sets of data arise from the same or different distributions. The null hypothesis is that both data sets were drawn from the same continuous distribution. The test included here is designed to compare two-dimensional distributions.
The algorithm in this function is taken from Peacock [1].
Usage: [H, pValue, KSstatistic] = kstest_2s_2d(x1, x2 <, alpha>)

'x1' is an [Nx2] matrix, each row containing a two-dimensional sample. 'x2' is an [Mx2] matrix, each row likewise containing a two-dimensional sample. The optional argument 'alpha' is used to set the desired significance level for rejecting the null hypothesis.

'H' is a logical value: true indicates that the null hypothesis should be rejected. 'pValue' is an estimate for the P value of the test statistic. 'KSstatistic' is the raw value for the test statistic ('D' in [1]).

In contrast to kstest2, this function can only perform a two-tailed test. This is because Peacock does not provide a method for estimating P in the one-tailed case [1]. Suggestions for a one-tailed test are welcome.

[1] J. A. Peacock, "Two-dimensional goodness-of-fit testing in astronomy", Monthly Notices Royal Astronomy Society 202 (1983) 615-627. Available from:

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
29 May 2013 Noushin Farnoud

23 Oct 2012 1.1

Updated description and summary

22 Sep 2016 1.2

Updated formatting

06 Oct 2016 1.2

Updated description

24 Oct 2016 1.2

Updated description

13 Dec 2016 1.2

Updated description

Contact us