Skip to content

Instantly share code, notes, and snippets.

@erikerlandson
Created September 9, 2014 21:22
Show Gist options
  • Save erikerlandson/b82e2c5aa96fdfb90484 to your computer and use it in GitHub Desktop.
Save erikerlandson/b82e2c5aa96fdfb90484 to your computer and use it in GitHub Desktop.
A python widget to do a Kolmogorov Smirnov test against two data sets
import sys
import argparse
from scipy import stats
argparser = argparse.ArgumentParser()
argparser.add_argument('data1', type=argparse.FileType('r'), metavar='<data-file-1>')
argparser.add_argument('data2', type=argparse.FileType('r'), metavar='<data-file-2>')
args = argparser.parse_args()
dv1 = args.data1.read().split()
dv2 = args.data2.read().split()
ksres = stats.ks_2samp(dv1, dv2)
sys.stdout.write("KS test results: stat=%s pval=%s\n" % ksres)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment