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 345 of file utils_v2.py.

Member Function Documentation

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

Definition at line 365 of file utils_v2.py.

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

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

Definition at line 356 of file utils_v2.py.

Referenced by utils_v2.Chi2Test.do_test().

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

Definition at line 348 of file utils_v2.py.

Referenced by utils_v2.Chi2Test.do_test().

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

Member Data Documentation

utils_v2.Chi2Test.name
static