CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
def enough_filled_bins
 
def make_absolute
 
- Public Member Functions inherited from utils_v2.StatisticalTest
def do_test
 
def get_N_bins
 
def is_empty
 

Static Public Attributes

string name = 'Chi2'
 
- Static Public Attributes inherited from utils_v2.StatisticalTest
 name = None
 

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().

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 
def enough_filled_bins
Definition: utils_v2.py:355
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().

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
def enough_filled_bins
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().

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)

Member Data Documentation

string utils_v2.Chi2Test.name = 'Chi2'
static

Definition at line 345 of file utils_v2.py.

Referenced by dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), config.CFG.__str__(), validation.Sample.digest(), VIDSelectorBase.VIDSelectorBase.initialize(), and Vispa.Views.PropertyView.Property.valueChanged().