Skip to content

Python implementation of an extension of the Kolmogorov-Smirnov test for multivariate samples

License

Notifications You must be signed in to change notification settings

o-laurent/multivariate-ks-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multivariate extension of the Kolmogorov-Smirnov test

This repository implements the extension of the KS test proposed by Michael Naaman in On the tight constant in the multivariate Dvoretzky–Kiefer–Wolfowitz inequality in the one and two-sample cases.

This package was translated from the original MATLAB code provided by the author.

Please feel free to open an issue if you have any problems or questions.

Installation

Clone the repository and install it with pip:

cd multivariate-ks-test && pip install .

Please raise an issue if you want to install it from PyPI.

Usage example

import numpy as np

from mks_test import mkstest

# Generate two samples from a 5D Normal distribution
n = 100
d = 5
mu = np.zeros(d)
sigma = np.eye(d)
X = np.random.multivariate_normal(mu, sigma, n)
Y = np.random.multivariate_normal(mu, sigma, n)

# Compute the test statistic
mkstest(X, Y, alpha=0.05, verbose=True)
# returns False - you can't reject that the two samples are drawn from the same distribution

Reference

If you find this code useful, you may cite the following paper:

@article{naaman2021tight,
  title={On the tight constant in the multivariate Dvoretzky--Kiefer--Wolfowitz inequality},
  author={Naaman, Michael},
  journal={Statistics \& Probability Letters},
  year={2021},
}

About

Python implementation of an extension of the Kolmogorov-Smirnov test for multivariate samples

Topics

Resources

License

Stars

Watchers

Forks

Languages