CMS 3D CMS Logo

Public Member Functions | Static Public Attributes

utils_v2::Chi2Test Class Reference

Inheritance diagram for utils_v2::Chi2Test:
utils_v2::StatisticalTest

List of all members.

Public Member Functions

def do_test
def enough_filled_bins
def make_absolute

Static Public Attributes

string name = 'Chi2'

Detailed Description

Definition at line 344 of file utils_v2.py.


Member Function Documentation

def utils_v2::Chi2Test::do_test (   self,
  h1,
  h2 
)

Reimplemented from utils_v2::StatisticalTest.

Definition at line 364 of file utils_v2.py.

00365                              :
00366         p_value = super(Chi2Test, self).do_test(h1, h2)
00367         if p_value is not None:
00368             return p_value
00369 
00370         bin_count = self.get_N_bins(h1)
00371 
00372         # Make histograms absolute.
00373         self.make_absolute(h1, bin_count)
00374         self.make_absolute(h2, bin_count)
00375 
00376         # Check if there is enough filled bins in bouth histograms.
00377         if not self.enough_filled_bins(h1, bin_count) or\
00378            not self.enough_filled_bins(h2, bin_count):
00379             return 1
00380 
00381         if h1.InheritsFrom("TProfile") or (h1.GetEntries() != h1.GetSumOfWeights()):
00382             return h1.Chi2Test(h2, 'WW')
00383         return h1.Chi2Test(h2, 'UU')
00384 

def utils_v2::Chi2Test::enough_filled_bins (   self,
  h,
  bin_count,
  more_than = 3 
)

Definition at line 355 of file utils_v2.py.

00356                                                            :
00357         filled_bins = 0
00358         for i in xrange(1, bin_count):
00359             if h.GetBinContent(i) > 0:
00360                 filled_bins += 1
00361             if filled_bins > more_than:
00362                 return True
00363         return False

def utils_v2::Chi2Test::make_absolute (   self,
  h,
  bin_count 
)

Definition at line 347 of file utils_v2.py.

00348                                          :
00349         for i in xrange(1, bin_count): # Why here is no +1?
00350             content = h.GetBinContent(i)
00351             if content < 0:
00352                 h.SetBinContent(i, -1 * content)
00353             if h.GetBinError(i) == 0 and content != 0:
00354                 h.SetBinContent(i, 0)


Member Data Documentation

string utils_v2::Chi2Test::name = 'Chi2' [static]

Reimplemented from utils_v2::StatisticalTest.

Definition at line 345 of file utils_v2.py.