CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes
utils_v2.Chi2Test Class Reference
Inheritance diagram for utils_v2.Chi2Test:
utils_v2.StatisticalTest

Public Member Functions

def do_test (self, h1, h2)
 
def enough_filled_bins (self, h, bin_count, more_than=3)
 
def make_absolute (self, h, bin_count)
 
- Public Member Functions inherited from utils_v2.StatisticalTest
def do_test (self, h1, h2)
 
def get_N_bins (self, h)
 
def is_empty (self, h)
 

Static Public Attributes

 name
 
- Static Public Attributes inherited from utils_v2.StatisticalTest
 name
 

Detailed Description

Definition at line 344 of file utils_v2.py.

Member Function Documentation

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

Definition at line 364 of file utils_v2.py.

References utils_v2.Chi2Test.enough_filled_bins(), utils_v2.StatisticalTest.get_N_bins(), and utils_v2.Chi2Test.make_absolute().

364  def do_test(self, h1, h2):
365  p_value = super(Chi2Test, self).do_test(h1, h2)
366  if p_value is not None:
367  return p_value
368 
369  bin_count = self.get_N_bins(h1)
370 
371  # Make histograms absolute.
372  self.make_absolute(h1, bin_count)
373  self.make_absolute(h2, bin_count)
374 
375  # Check if there is enough filled bins in bouth histograms.
376  if not self.enough_filled_bins(h1, bin_count) or\
377  not self.enough_filled_bins(h2, bin_count):
378  return 1
379 
380  if h1.InheritsFrom("TProfile") or (h1.GetEntries() != h1.GetSumOfWeights()):
381  return h1.Chi2Test(h2, 'WW')
382  return h1.Chi2Test(h2, 'UU')
383 
384 
def enough_filled_bins(self, h, bin_count, more_than=3)
Definition: utils_v2.py:355
def do_test(self, h1, h2)
Definition: utils_v2.py:364
def get_N_bins(self, h)
Definition: utils_v2.py:302
def make_absolute(self, h, bin_count)
Definition: utils_v2.py:347
def utils_v2.Chi2Test.enough_filled_bins (   self,
  h,
  bin_count,
  more_than = 3 
)

Definition at line 355 of file utils_v2.py.

Referenced by utils_v2.Chi2Test.do_test().

355  def enough_filled_bins(self, h, bin_count, more_than=3):
356  filled_bins = 0
357  for i in xrange(1, bin_count):
358  if h.GetBinContent(i) > 0:
359  filled_bins += 1
360  if filled_bins > more_than:
361  return True
362  return False
363 
def enough_filled_bins(self, h, bin_count, more_than=3)
Definition: utils_v2.py:355
def utils_v2.Chi2Test.make_absolute (   self,
  h,
  bin_count 
)

Definition at line 347 of file utils_v2.py.

Referenced by utils_v2.Chi2Test.do_test().

347  def make_absolute(self, h, bin_count):
348  for i in xrange(1, bin_count): # Why here is no +1?
349  content = h.GetBinContent(i)
350  if content < 0:
351  h.SetBinContent(i, -1 * content)
352  if h.GetBinError(i) == 0 and content != 0:
353  h.SetBinContent(i, 0)
354 
def make_absolute(self, h, bin_count)
Definition: utils_v2.py:347

Member Data Documentation

utils_v2.Chi2Test.name
static