The Kolmogorov-Smirnov test is used to evaluate if histogram distributions deviated from a simulated null hypothesis (H0), comparing to the alternative hypothesis (H1). The distributions with P value < 0.05 are normally considered that deviated significantly from a null hypothesis.
- SciPy (installation guide)
SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering.
More detailed usage:
#!/usr/bin/python #Performs KS-test #Usage: python script.py sample1.txt sample2.txt #Input: distribution values separated by break line in a text file from scipy import stats import numpy as np import sys x = sys.argv y = sys.argv sample1 = np.loadtxt(x,delimiter=",") sample2 = np.loadtxt(y,delimiter=",") one_sample = stats.kstest(sample1, 'norm', alternative = 'greater') #null vs alternative hypothesis for sample1. Dont reject equal distribution against alternative hypothesis: greater two_samples = stats.ks_2samp(sample1, sample2) #sample1 vs sample2 print one_sample,two_samples #output: sample1 sample2 (D, pvalue) (D, pvalue)