Statistical comparison of two histograms (chi2, p-values)
Code: ""
Programming language: Python
DMelt Version 1. Last modified: 12/10/2015. License: Free
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.

from jhplot import H1D 
from java.util import Random

h1 = H1D("H1",20, -1, 1)
h2 = H1D("H2",20, -1, 1)
rand = Random()

# fill histograms sligly differently. Second distribution is narrower
for i in range(100):

#  compare histograms
d=h1.compareChi2(h2) # h1, h2 are H1D or H2D histograms defined above
print "chi2 / ndf =",d["chi2"]/d["ndf"]
print "p-value=",d["p-value"]

from hep.aida.util.comparison import *, h2.get(),'KS')
print"KolmogorovSmirnov  method=",r.quality() ,"/",r.nDof()