Gaudi::Utils::HistoStats Class Reference

The collection of trivial functions to access the statistical information for the histograms. More...

#include <GaudiUtils/HistoStats.h>

Static Public Member Functions

static double moment (const AIDA::IHistogram1D *histo, const unsigned int order, const double value=0)
 get the "bin-by-bin"-moment around the specified "value" More...
 
static double momentErr (const AIDA::IHistogram1D *histo, const unsigned int order)
 evaluate the uncertanty for 'bin-by-bin'-moment More...
 
static double centralMoment (const AIDA::IHistogram1D *histo, const unsigned int order)
 evaluate the 'bin-by-bin'-central moment (around the mean value) More...
 
static double centralMomentErr (const AIDA::IHistogram1D *histo, const unsigned int order)
 evaluate the uncertanty for 'bin-by-bin'-central moment (around the mean value) ( the uncertanty is calculated with O(1/n2) precision) More...
 
static double skewness (const AIDA::IHistogram1D *histo)
 get the skewness for the histogram More...
 
static double skewnessErr (const AIDA::IHistogram1D *histo)
 get the error in skewness for the histogram More...
 
static double kurtosis (const AIDA::IHistogram1D *histo)
 get the kurtosis for the histogram More...
 
static double kurtosisErr (const AIDA::IHistogram1D *histo)
 get the error in kurtosis for the histogram More...
 
static double mean (const AIDA::IHistogram1D *histo)
 get the mean value for the histogram (just for completeness) More...
 
static double meanErr (const AIDA::IHistogram1D *histo)
 get an error in the mean value More...
 
static double rms (const AIDA::IHistogram1D *histo)
 get the rms value for the histogram (just for completeness) More...
 
static double rmsErr (const AIDA::IHistogram1D *histo)
 get an error in the rms value More...
 
static double nEff (const AIDA::IHistogram1D *histo)
 get the effective entries (just for completeness) More...
 
static double sumBinHeightErr (const AIDA::IHistogram1D *histo)
 get an error in the sum bin height ("in-range integral") More...
 
static double sumAllBinHeightErr (const AIDA::IHistogram1D *histo)
 get an error in the sum of all bin height ("integral") More...
 
static double overflowEntriesFrac (const AIDA::IHistogram1D *histo)
 the fraction of overflow entries (useful for shape comparison) More...
 
static double underflowEntriesFrac (const AIDA::IHistogram1D *histo)
 the fraction of underflow entries (useful for shape comparison) More...
 
static double overflowEntriesFracErr (const AIDA::IHistogram1D *histo)
 error on fraction of overflow entries (useful for shape comparison) More...
 
static double underflowEntriesFracErr (const AIDA::IHistogram1D *histo)
 the error on fraction of underflow entries (useful for shape comparison) More...
 
static double overflowIntegralFrac (const AIDA::IHistogram1D *histo)
 the fraction of overflow intergal (useful for shape comparison) More...
 
static double underflowIntegralFrac (const AIDA::IHistogram1D *histo)
 the fraction of underflow integral (useful for shape comparison) More...
 
static double overflowIntegralFracErr (const AIDA::IHistogram1D *histo)
 the error on fraction of overflow intergal More...
 
static double underflowIntegralFracErr (const AIDA::IHistogram1D *histo)
 the error on fraction of underflow integral More...
 
static long nEntries (const AIDA::IHistogram1D *histo, const int imax)
 get number of entries in histogram up to the certain bin (not-included) More...
 
static long nEntries (const AIDA::IHistogram1D *histo, const int imin, const int imax)
 get number of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included) More...
 
static double nEntriesFrac (const AIDA::IHistogram1D *histo, const int imax)
 get the fraction of entries in histogram up to the certain bin (not-included) More...
 
static double nEntriesFrac (const AIDA::IHistogram1D *histo, const int imin, const int imax)
 get fraction of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included) More...
 
static double nEntriesFracErr (const AIDA::IHistogram1D *histo, const int imax)
 get the (binominal) error for the fraction of entries in histogram up to the certain bin (not-included) More...
 
static double nEntriesFracErr (const AIDA::IHistogram1D *histo, const int imin, const int imax)
 get the (binomial) error for the fraction of entries in histogram from the certain minimal bin up to the certain maximal bin (not-included) More...
 

Detailed Description

The collection of trivial functions to access the statistical information for the histograms.

Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-08-06

Definition at line 29 of file HistoStats.h.

Member Function Documentation

double Gaudi::Utils::HistoStats::centralMoment ( const AIDA::IHistogram1D *  histo,
const unsigned int  order 
)
static

evaluate the 'bin-by-bin'-central moment (around the mean value)

Parameters
histohistogram
orderthe moment parameter
valuecentral value
Returns
the evaluated central moment

Definition at line 113 of file HistoStats.cpp.

115 {
116  if ( !histo ) { return s_bad ; } // RETURN
117  if ( 0 == order ) { return 1.0 ; } // RETURN
118  if ( 1 == order ) { return 0.0 ; } // RETURN
119  if ( 2 == order )
120  {
121  return std::pow( histo->rms(), 2 ); // RETURN
122  }
123  // delegate the actual evaluation to another method:
124  return moment ( histo , order , mean ( histo ) ) ;
125 }
static double moment(const AIDA::IHistogram1D *histo, const unsigned int order, const double value=0)
get the "bin-by-bin"-moment around the specified "value"
Definition: HistoStats.cpp:48
T pow(T...args)
static double mean(const AIDA::IHistogram1D *histo)
get the mean value for the histogram (just for completeness)
Definition: HistoStats.cpp:215
double Gaudi::Utils::HistoStats::centralMomentErr ( const AIDA::IHistogram1D *  histo,
const unsigned int  order 
)
static

evaluate the uncertanty for 'bin-by-bin'-central moment (around the mean value) ( the uncertanty is calculated with O(1/n2) precision)

Parameters
histohistogram
orderthe moment parameter
valuecentral value
Returns
the evaluated uncertanty in the central moment

Definition at line 137 of file HistoStats.cpp.

139 {
140  if ( !histo ) { return s_bad ; } // RETURN
141  const auto n = nEff ( histo ) ;
142  if ( 0 >= n ) { return 0.0 ; } // RETURN
143  const auto mu2 = centralMoment ( histo , 2 ) ; // mu(2)
144  const auto muo = centralMoment ( histo , order ) ; // mu(o)
145  const auto mu2o = centralMoment ( histo , 2 * order ) ; // mu(2o)
146  const auto muom = centralMoment ( histo , order - 1 ) ; // mu(o-1)
147  const auto muop = centralMoment ( histo , order + 1 ) ; // mu(o+1)
148  const auto result = ( mu2o
149  - ( 2.0 * order * muom * muop )
150  - std::pow(muo,2)
151  + ( order * order * mu2 * muom * muom ) ) / n ;
152  return std::sqrt ( std::max ( 0.0 , result ) ) ; // RETURN
153 }
static double centralMoment(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the &#39;bin-by-bin&#39;-central moment (around the mean value)
Definition: HistoStats.cpp:113
T max(T...args)
T pow(T...args)
T sqrt(T...args)
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::kurtosis ( const AIDA::IHistogram1D *  histo)
static

get the kurtosis for the histogram

Definition at line 181 of file HistoStats.cpp.

182 {
183  if ( !histo ) { return s_bad ; } // RETURN
184  const auto mu4 = centralMoment ( histo , 4 ) ;
185  const auto s4 = std::pow ( rms ( histo ) , 4 ) ;
186  return ( std::fabs(s4)>0 ? mu4/s4 - 3.0 : 0.0 );
187 }
static double centralMoment(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the &#39;bin-by-bin&#39;-central moment (around the mean value)
Definition: HistoStats.cpp:113
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
T fabs(T...args)
T pow(T...args)
double Gaudi::Utils::HistoStats::kurtosisErr ( const AIDA::IHistogram1D *  histo)
static

get the error in kurtosis for the histogram

Definition at line 192 of file HistoStats.cpp.

193 {
194  if ( !histo ) { return s_bad ; } // RETURN
195  const auto n = nEff ( histo ) ;
196  if ( 3 > n ) { return 0.0 ; } // RETURN
197  auto result = 24.0 * n ;
198  result *= ( n - 2 ) * ( n - 3 ) ;
199  result /= ( n + 1 ) * ( n + 1 ) ;
200  result /= ( n + 3 ) * ( n + 5 ) ;
201  return std::sqrt ( result ) ;
202 }
T sqrt(T...args)
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::mean ( const AIDA::IHistogram1D *  histo)
static

get the mean value for the histogram (just for completeness)

Definition at line 215 of file HistoStats.cpp.

216 {
217  return ( histo ? histo -> mean() : s_bad );
218 }
static double mean(const AIDA::IHistogram1D *histo)
get the mean value for the histogram (just for completeness)
Definition: HistoStats.cpp:215
double Gaudi::Utils::HistoStats::meanErr ( const AIDA::IHistogram1D *  histo)
static

get an error in the mean value

Definition at line 223 of file HistoStats.cpp.

224 {
225  if ( !histo ) { return s_bad ; }
226  const auto n = nEff ( histo ) ;
227  return ( 0 >= n ? 0.0 : rms ( histo ) / std::sqrt ( n ) );
228 }
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
T sqrt(T...args)
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::moment ( const AIDA::IHistogram1D *  histo,
const unsigned int  order,
const double  value = 0 
)
static

get the "bin-by-bin"-moment around the specified "value"

Parameters
histohistogram
orderthe moment parameter
valuecentral value
Returns
the evaluated moment

Definition at line 48 of file HistoStats.cpp.

51 {
52  if ( !histo ) { return s_bad ; } // RETURN
53  if ( 0 == order ) { return 1.0 ; } // RETURN
54  if ( 1 == order ) { return mean( histo ) - value ; } // RETURN
55  if ( 2 == order )
56  {
57  const auto _r = rms ( histo ) ;
58  const auto _d = value - mean ( histo ) ;
59  return std::pow(_r,2) + std::pow(_d,2) ; // RETURN
60  }
61  const auto n = nEff ( histo ) ;
62  if ( 0 >= n ) { return 0.0 ; } // RETURN
63 
64  // get the exis
65  const auto & axis = histo -> axis () ;
66  // number of bins
67  const auto nBins = axis.bins() ;
68  double result{0}, weight{0};
69  // loop over all bins
70  for ( int i = 0 ; i < nBins ; ++i )
71  {
72  const auto lE = axis . binLowerEdge ( i ) ;
73  const auto uE = axis . binUpperEdge ( i ) ;
74  //
75  const auto yBin = histo -> binHeight ( i ) ; // bin weight
76  const double xBin = 0.5 * ( lE + uE ) ; // bin center
77  //
78  weight += yBin ;
79  result += yBin * std::pow ( xBin - value , order ) ;
80  }
81  if ( 0 != weight ) { result /= weight ; }
82  return result ;
83 }
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
T pow(T...args)
static double mean(const AIDA::IHistogram1D *histo)
get the mean value for the histogram (just for completeness)
Definition: HistoStats.cpp:215
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::momentErr ( const AIDA::IHistogram1D *  histo,
const unsigned int  order 
)
static

evaluate the uncertanty for 'bin-by-bin'-moment

Parameters
histohistogram
orderthe moment parameter
valuecentral value
Returns
the evaluated uncertanty in the moment

Definition at line 93 of file HistoStats.cpp.

95 {
96  if ( !histo ) { return s_bad ; } // RETURN
97  const auto n = nEff ( histo ) ;
98  if ( 0 >= n ) { return 0.0 ; } // RETURN
99  const auto a2o = moment ( histo , 2 * order ) ; // a(2o)
100  const auto ao = moment ( histo , order ) ; // a(o)
101  const auto result = std::max ( 0.0 , ( a2o - std::pow(ao,2) ) / n ) ;
102  return std::sqrt ( result ) ; // RETURN
103 }
static double moment(const AIDA::IHistogram1D *histo, const unsigned int order, const double value=0)
get the "bin-by-bin"-moment around the specified "value"
Definition: HistoStats.cpp:48
T max(T...args)
T pow(T...args)
T sqrt(T...args)
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::nEff ( const AIDA::IHistogram1D *  histo)
static

get the effective entries (just for completeness)

Definition at line 207 of file HistoStats.cpp.

208 {
209  return ( histo ? histo->equivalentBinEntries() : s_bad );
210 }
long Gaudi::Utils::HistoStats::nEntries ( const AIDA::IHistogram1D *  histo,
const int  imax 
)
static

get number of entries in histogram up to the certain bin (not-included)

Attention
underflow bin is included!
Parameters
histothe pointer to the histogram
imaxthe bin number (not included)
numberof entries

Definition at line 440 of file HistoStats.cpp.

442 {
443  if ( !histo ) { return s_long_bad ; } // RETURN
444  if ( 0 > imax ) { return 0 ; } // RETURN
445  long result = histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ;
446 
447  // get the exis
448  const auto& axis = histo -> axis () ;
449  // number of bins
450  const auto nBins = axis.bins() ;
451  // loop over all bins
452  for ( int i = 0 ; i < nBins ; ++i )
453  { if ( i < imax ) { result += histo->binEntries ( i ) ; } }
454  //
455  if ( nBins < imax )
456  { result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
457  //
458  return result ;
459 }
long Gaudi::Utils::HistoStats::nEntries ( const AIDA::IHistogram1D *  histo,
const int  imin,
const int  imax 
)
static

get number of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included)

Parameters
histothe pointer to the histogram
iminthe minimal bin number (included)
imaxthe maximal bin number (not included)
numberof entries

Definition at line 470 of file HistoStats.cpp.

473 {
474  if ( !histo ) { return s_long_bad ; } // RETURN
475  if ( imin == imax ) { return 0 ; } // RETURN
476  if ( imax < imin ) { return nEntries ( histo , imax ,imin ) ; } // RETURN
477  //
478  long result = 0 ;
479  if ( 0 > imin )
480  { result += histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ; }
481  // get the exis
482  const auto& axis = histo -> axis () ;
483  // number of bins
484  const auto nBins = axis.bins() ;
485  if ( nBins < imin ) { return 0 ; } // RETURN
486  // loop over all bins
487  for ( int i = 0 ; i < nBins ; ++i )
488  { if ( imin <= i && i < imax ) { result += histo->binEntries ( i ) ; } }
489  //
490  if ( nBins < imax )
491  { result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
492  //
493  return result ; // RETURN
494 }
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
Definition: HistoStats.cpp:440
double Gaudi::Utils::HistoStats::nEntriesFrac ( const AIDA::IHistogram1D *  histo,
const int  imax 
)
static

get the fraction of entries in histogram up to the certain bin (not-included)

Attention
underflow bin is included!
Parameters
histothe pointer to the histogram
imaxthe bin number (not included)
fractionof entries

Definition at line 505 of file HistoStats.cpp.

507 {
508  if ( !histo ) { return s_bad ; } // RETURN
509  //
510  const auto N = histo->allEntries () ;
511  if ( 0 >= N ) { return s_bad ; } // RETURN
512  const auto n = nEntries ( histo , imax ) ;
513  if ( 0 > n ) { return s_bad ; } // RETURN
514  if ( n > N ) { return s_bad ; } // RETURN
515  //
516  return (double)n / (double)N ; // REUTRN
517 }
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
Definition: HistoStats.cpp:440
int N
Definition: IOTest.py:90
double Gaudi::Utils::HistoStats::nEntriesFrac ( const AIDA::IHistogram1D *  histo,
const int  imin,
const int  imax 
)
static

get fraction of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included)

Parameters
histothe pointer to the histogram
iminthe minimal bin number (included)
imaxthe maximal bin number (not included)
fractionof entries

Definition at line 528 of file HistoStats.cpp.

531 {
532  if ( !histo ) { return s_bad ; } // RETURN
533  const auto N = histo->allEntries () ;
534  if ( 0 >= N ) { return s_bad ; } // RETURN
535  const auto n = nEntries ( histo , imin , imax ) ;
536  if ( 0 > n ) { return s_bad ; } // RETURN
537  if ( n > N ) { return s_bad ; } // RETURN
538  //
539  return (double)n / (double)N ; // REUTRN
540 }
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
Definition: HistoStats.cpp:440
int N
Definition: IOTest.py:90
double Gaudi::Utils::HistoStats::nEntriesFracErr ( const AIDA::IHistogram1D *  histo,
const int  imax 
)
static

get the (binominal) error for the fraction of entries in histogram up to the certain bin (not-included)

Attention
underflow bin is included!
Parameters
histothe pointer to the histogram
imaxthe bin number (not included)
errorfor the fraction of entries

Definition at line 551 of file HistoStats.cpp.

553 {
554  if ( !histo ) { return s_bad ; } // RETURN
555  //
556  const auto N = histo->allEntries () ;
557  if ( 0 >= N ) { return s_bad ; } // RETURN
558  const auto n = nEntries ( histo , imax ) ;
559  if ( 0 > n ) { return s_bad ; } // RETURN
560  if ( n > N ) { return s_bad ; } // RETURN
561  //
562  const double _n1 = std::max ( (double) n , 1.0 ) ;
563  const double _n2 = std::max ( (double) ( N - n ) , 1.0 ) ;
564  //
565  return std::sqrt ( _n1 * ( _n2 / N ) ) / N ; // RETURN
566 }
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
Definition: HistoStats.cpp:440
int N
Definition: IOTest.py:90
T max(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::nEntriesFracErr ( const AIDA::IHistogram1D *  histo,
const int  imin,
const int  imax 
)
static

get the (binomial) error for the fraction of entries in histogram from the certain minimal bin up to the certain maximal bin (not-included)

Parameters
histothe pointer to the histogram
iminthe minimal bin number (included)
imaxthe maximal bin number (not included)
errorfor the fraction of entries

Definition at line 577 of file HistoStats.cpp.

580 {
581  if ( !histo ) { return s_bad ; } // RETURN
582  //
583  const auto N = histo->allEntries () ;
584  if ( 0 >= N ) { return s_bad ; } // RETURN
585  const auto n = nEntries ( histo , imin , imax ) ;
586  if ( 0 > n ) { return s_bad ; } // RETURN
587  if ( n > N ) { return s_bad ; } // RETURN
588  //
589  const double _n1 = std::max ( (double) n , 1.0 ) ;
590  const double _n2 = std::max ( (double) ( N - n ) , 1.0 ) ;
591  //
592  return std::sqrt ( _n1 * ( _n2 / N ) ) / N ; // RETURN
593 }
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
Definition: HistoStats.cpp:440
int N
Definition: IOTest.py:90
T max(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::overflowEntriesFrac ( const AIDA::IHistogram1D *  histo)
static

the fraction of overflow entries (useful for shape comparison)

Definition at line 292 of file HistoStats.cpp.

293 {
294  if ( !histo ) { return s_bad ; } // REUTRN
295  const auto overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN ) ;
296  if ( 0 == overflow ) { return 0 ; } // REUTRN
297  const auto all = histo->allEntries() ;
298  if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
299  if ( 0 > all ) { return s_bad ; } // Lets be a bit paranoic, RETURN
300  //
301  return (double) overflow / (double) all;
302 }
double Gaudi::Utils::HistoStats::overflowEntriesFracErr ( const AIDA::IHistogram1D *  histo)
static

error on fraction of overflow entries (useful for shape comparison)

Definition at line 350 of file HistoStats.cpp.

351 {
352  if ( !histo ) { return s_bad ; } // RETURN
353  //
354  const auto overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN );
355  const auto all = histo -> allEntries () ;
356  //
357  if ( 0 > overflow || 0 >= all || overflow > all ) { return s_bad ; }
358  //
359  const double n = std::max ( (double)overflow , 1.0 ) ;
360  const double N = all ;
361  const double n1 = std::max ( N - n , 1.0 ) ;
362  //
363  return std::sqrt ( n * ( n1 / N ) ) / N ; // use the binomial formula
364 }
int N
Definition: IOTest.py:90
T max(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::overflowIntegralFrac ( const AIDA::IHistogram1D *  histo)
static

the fraction of overflow intergal (useful for shape comparison)

Definition at line 322 of file HistoStats.cpp.

323 {
324  if ( !histo ) { return s_bad ; } // REUTRN
325  const auto overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
326  if ( 0 == overflow ) { return 0 ; } // REUTRN
327  const auto all = histo -> sumAllBinHeights() ;
328  if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
329  //
330  return (double)overflow / (double)all ;
331 }
double Gaudi::Utils::HistoStats::overflowIntegralFracErr ( const AIDA::IHistogram1D *  histo)
static

the error on fraction of overflow intergal

Definition at line 388 of file HistoStats.cpp.

389 {
390  if ( !histo ) { return s_bad ; } // RETURN
391  //
392  const auto all = histo -> sumAllBinHeights () ;
393  if ( 0 == all ) { return s_bad ; } // RETURN
394  const auto overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
395  const auto oErr = histo -> binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
396  if ( 0 > oErr ) { return s_bad ; } // RETURN
397  const auto aErr = sumAllBinHeightErr ( histo ) ;
398  if ( 0 > aErr ) { return s_bad ; } // RETURN
399  //
400  double error2 = std::pow((double)oErr,2) ;
401  error2 += ( std::pow((double)aErr,2) *
402  std::pow((double)overflow,2) / std::pow((double)all,2) );
403  error2 /= std::pow((double)all,2) ;
404  //
405  return std::sqrt ( error2 ) ;
406 }
static double sumAllBinHeightErr(const AIDA::IHistogram1D *histo)
get an error in the sum of all bin height ("integral")
Definition: HistoStats.cpp:276
T pow(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::rms ( const AIDA::IHistogram1D *  histo)
static

get the rms value for the histogram (just for completeness)

Definition at line 233 of file HistoStats.cpp.

234 {
235  return ( histo ? histo -> rms () : s_bad );
236 }
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
double Gaudi::Utils::HistoStats::rmsErr ( const AIDA::IHistogram1D *  histo)
static

get an error in the rms value

Definition at line 241 of file HistoStats.cpp.

242 {
243  if ( !histo ) { return s_bad ; }
244  const auto n = nEff ( histo ) ;
245  if ( 1 >= n ) { return 0.0 ; }
246  auto result = 2.0 + kurtosis ( histo ) ;
247  result += 2.0 / ( n - 1 ) ;
248  result /= 4.0 * n ;
249  return histo -> rms() * std::sqrt ( std::max ( result , 0.0 ) ) ;
250 }
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
T max(T...args)
T sqrt(T...args)
static double kurtosis(const AIDA::IHistogram1D *histo)
get the kurtosis for the histogram
Definition: HistoStats.cpp:181
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::skewness ( const AIDA::IHistogram1D *  histo)
static

get the skewness for the histogram

Definition at line 158 of file HistoStats.cpp.

159 {
160  if ( !histo ) { return s_bad ; } // RETURN
161  const auto mu3 = centralMoment ( histo , 3 ) ;
162  const auto s3 = std::pow ( rms ( histo ) , 3 ) ;
163  return ( std::fabs(s3)>0 ? mu3/s3 : 0.0 );
164 }
static double centralMoment(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the &#39;bin-by-bin&#39;-central moment (around the mean value)
Definition: HistoStats.cpp:113
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
Definition: HistoStats.cpp:233
T fabs(T...args)
T pow(T...args)
double Gaudi::Utils::HistoStats::skewnessErr ( const AIDA::IHistogram1D *  histo)
static

get the error in skewness for the histogram

Definition at line 169 of file HistoStats.cpp.

170 {
171  if ( !histo ) { return s_bad ; } // RETURN
172  const auto n = nEff ( histo ) ;
173  if ( 2 > n ) { return 0.0 ; } // RETURN
174  const auto result = 6.0 * ( n - 2 ) / ( ( n + 1 ) * ( n + 3 ) );
175  return std::sqrt ( result ) ;
176 }
T sqrt(T...args)
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
Definition: HistoStats.cpp:207
double Gaudi::Utils::HistoStats::sumAllBinHeightErr ( const AIDA::IHistogram1D *  histo)
static

get an error in the sum of all bin height ("integral")

Definition at line 276 of file HistoStats.cpp.

277 {
278  if ( !histo ) { return s_bad ; }
279  //
280  const auto error = sumBinHeightErr( histo ) ;
281  if ( 0 > error ) { return s_bad ; }
283  const auto err1 = histo->binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
284  const auto err2 = histo->binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
285  //
286  return std::sqrt ( std::pow(error,2) + std::pow(err1,2) + std::pow(err2,2) ) ;
287 }
static double sumBinHeightErr(const AIDA::IHistogram1D *histo)
get an error in the sum bin height ("in-range integral")
Definition: HistoStats.cpp:255
T pow(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::sumBinHeightErr ( const AIDA::IHistogram1D *  histo)
static

get an error in the sum bin height ("in-range integral")

Definition at line 255 of file HistoStats.cpp.

256 {
257  if ( !histo ) { return s_bad ; }
258  //
259  double error2 = 0 ;
260  // get the exis
261  const auto & axis = histo -> axis () ;
262  // number of bins
263  const auto nBins = axis.bins() ;
264  // loop over all bins
265  for ( int i = 0 ; i < nBins ; ++i )
266  {
267  // accumulate the errors in each bin
268  error2 += std::pow( histo->binError(i), 2 ) ;
269  }
270  return std::sqrt ( error2 ) ;
271 }
T pow(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::underflowEntriesFrac ( const AIDA::IHistogram1D *  histo)
static

the fraction of underflow entries (useful for shape comparison)

Definition at line 307 of file HistoStats.cpp.

308 {
309  if ( !histo ) { return s_bad ; } // REUTRN
310  const auto underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN ) ;
311  if ( 0 == underflow ) { return 0 ; } // REUTRN
312  const auto all = histo->allEntries() ;
313  if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
314  if ( 0 > all ) { return s_bad ; } // Lets be a bit paranoic, RETURN
315  //
316  return (double) underflow / (double) all;
317 }
double Gaudi::Utils::HistoStats::underflowEntriesFracErr ( const AIDA::IHistogram1D *  histo)
static

the error on fraction of underflow entries (useful for shape comparison)

Definition at line 369 of file HistoStats.cpp.

370 {
371  if ( !histo ) { return s_bad ; } // RETURN
372  //
373  const auto underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN );
374  const auto all = histo -> allEntries () ;
375  //
376  if ( 0 > underflow || 0 >= all || underflow > all ) { return s_bad ; }
377  //
378  const double n = std::max ( (double)underflow , 1.0 ) ;
379  const double N = all ;
380  const double n1 = std::max ( N - n , 1.0 ) ;
381  //
382  return std::sqrt ( n * ( n1 / N ) ) / N ; // use the binomial formula
383 }
int N
Definition: IOTest.py:90
T max(T...args)
T sqrt(T...args)
double Gaudi::Utils::HistoStats::underflowIntegralFrac ( const AIDA::IHistogram1D *  histo)
static

the fraction of underflow integral (useful for shape comparison)

Definition at line 336 of file HistoStats.cpp.

337 {
338  if ( !histo ) { return s_bad ; } // REUTRN
339  const auto underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
340  if ( 0 == underflow ) { return 0 ; } // REUTRN
341  const auto all = histo -> sumAllBinHeights() ;
342  if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
343  //
344  return (double)underflow / (double)all ;
345 }
double Gaudi::Utils::HistoStats::underflowIntegralFracErr ( const AIDA::IHistogram1D *  histo)
static

the error on fraction of underflow integral

Definition at line 411 of file HistoStats.cpp.

412 {
413  if ( !histo ) { return s_bad ; } // RETURN
414  //
415  const auto all = histo -> sumAllBinHeights () ;
416  if ( 0 == all ) { return s_bad ; } // RETURN
417  const auto underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
418  const auto oErr = histo -> binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
419  if ( 0 > oErr ) { return s_bad ; } // RETURN
420  const auto aErr = sumAllBinHeightErr ( histo ) ;
421  if ( 0 > aErr ) { return s_bad ; } // RETURN
422  //
423  double error2 = std::pow((double)oErr,2) ;
424  error2 += ( std::pow((double)aErr,2) *
425  std::pow((double)underflow,2) / std::pow((double)all,2) );
426  error2 /= std::pow((double)all,2) ;
427  //
428  return std::sqrt ( error2 ) ;
429 }
static double sumAllBinHeightErr(const AIDA::IHistogram1D *histo)
get an error in the sum of all bin height ("integral")
Definition: HistoStats.cpp:276
T pow(T...args)
T sqrt(T...args)

The documentation for this class was generated from the following files: