|
Gaudi Framework, version v23r2 |
| Home | Generated: Thu Jun 28 2012 |
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" | |
| static double | momentErr (const AIDA::IHistogram1D *histo, const unsigned int order) |
| evaluate the uncertanty for 'bin-by-bin'-moment | |
| static double | centralMoment (const AIDA::IHistogram1D *histo, const unsigned int order) |
| evaluate the 'bin-by-bin'-central moment (around the mean value) | |
| 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) | |
| static double | skewness (const AIDA::IHistogram1D *histo) |
| get the skewness for the histogram | |
| static double | skewnessErr (const AIDA::IHistogram1D *histo) |
| get the error in skewness for the histogram | |
| static double | kurtosis (const AIDA::IHistogram1D *histo) |
| get the kurtosis for the histogram | |
| static double | kurtosisErr (const AIDA::IHistogram1D *histo) |
| get the error in kurtosis for the histogram | |
| static double | mean (const AIDA::IHistogram1D *histo) |
| get the mean value for the histogram (just for completeness) | |
| static double | meanErr (const AIDA::IHistogram1D *histo) |
| get an error in the mean value | |
| static double | rms (const AIDA::IHistogram1D *histo) |
| get the rms value for the histogram (just for completeness) | |
| static double | rmsErr (const AIDA::IHistogram1D *histo) |
| get an error in the rms value | |
| static double | nEff (const AIDA::IHistogram1D *histo) |
| get the effective entries (just for completeness) | |
| static double | sumBinHeightErr (const AIDA::IHistogram1D *histo) |
| get an error in the sum bin height ("in-range integral") | |
| static double | sumAllBinHeightErr (const AIDA::IHistogram1D *histo) |
| get an error in the sum of all bin height ("integral") | |
| static double | overflowEntriesFrac (const AIDA::IHistogram1D *histo) |
| the fraction of overflow entries (useful for shape comparison) | |
| static double | underflowEntriesFrac (const AIDA::IHistogram1D *histo) |
| the fraction of underflow entries (useful for shape comparison) | |
| static double | overflowEntriesFracErr (const AIDA::IHistogram1D *histo) |
| error on fraction of overflow entries (useful for shape comparison) | |
| static double | underflowEntriesFracErr (const AIDA::IHistogram1D *histo) |
| the error on fraction of underflow entries (useful for shape comparison) | |
| static double | overflowIntegralFrac (const AIDA::IHistogram1D *histo) |
| the fraction of overflow intergal (useful for shape comparison) | |
| static double | underflowIntegralFrac (const AIDA::IHistogram1D *histo) |
| the fraction of underflow integral (useful for shape comparison) | |
| static double | overflowIntegralFracErr (const AIDA::IHistogram1D *histo) |
| the error on fraction of overflow intergal | |
| static double | underflowIntegralFracErr (const AIDA::IHistogram1D *histo) |
| the error on fraction of underflow integral | |
| static long | nEntries (const AIDA::IHistogram1D *histo, const int imax) |
| get number of entries in histogram up to the certain bin (not-included) | |
| 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) | |
| static double | nEntriesFrac (const AIDA::IHistogram1D *histo, const int imax) |
| get the fraction of entries in histogram up to the certain bin (not-included) | |
| 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) | |
| 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) | |
| 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) | |
The collection of trivial functions to access the statistical information for the histograms.
Definition at line 31 of file HistoStats.h.
| 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)
| histo | histogram |
| order | the moment parameter |
| value | central value |
Definition at line 119 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
if ( 0 == order ) { return 1.0 ; } // RETURN
if ( 1 == order ) { return 0.0 ; } // RETURN
if ( 2 == order )
{
const double sigma = histo->rms() ;
return sigma * sigma ; // RETURN
}
// delegate the actual evaluation to another method:
return moment ( histo , order , mean ( histo ) ) ;
}
| 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)
| histo | histogram |
| order | the moment parameter |
| value | central value |
Definition at line 144 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
const double n = nEff ( histo ) ;
if ( 0 >= n ) { return 0.0 ; } // RETURN
const double mu2 = centralMoment ( histo , 2 ) ; // mu(2)
const double muo = centralMoment ( histo , order ) ; // mu(o)
const double mu2o = centralMoment ( histo , 2 * order ) ; // mu(2o)
const double muom = centralMoment ( histo , order - 1 ) ; // mu(o-1)
const double muop = centralMoment ( histo , order + 1 ) ; // mu(o+1)
double result = mu2o ;
result -= 2.0 * order * muom * muop ;
result -= muo * muo ;
result += order * order * mu2 * muom * muom ;
result /= n ;
result = std::max ( 0.0 , result ) ;
return std:: sqrt ( result ) ; // RETURN
}
| double Gaudi::Utils::HistoStats::kurtosis | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the kurtosis for the histogram
Definition at line 192 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
const double mu4 = centralMoment ( histo , 4 ) ;
const double s4 = std::pow ( rms ( histo ) , 4 ) ;
return ( std::fabs(s4)>0 ? mu4/s4 - 3.0 : 0.0 );
}
| double Gaudi::Utils::HistoStats::kurtosisErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the error in kurtosis for the histogram
Definition at line 203 of file HistoStats.cpp.
| double Gaudi::Utils::HistoStats::mean | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the mean value for the histogram (just for completeness)
Definition at line 227 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; }
return histo -> mean() ;
}
| double Gaudi::Utils::HistoStats::meanErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get an error in the mean value
Definition at line 236 of file HistoStats.cpp.
| 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"
| histo | histogram |
| order | the moment parameter |
| value | central value |
Definition at line 49 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
if ( 0 == order ) { return 1.0 ; } // RETURN
if ( 1 == order ) { return mean( histo ) - value ; } // RETURN
if ( 2 == order )
{
const double _r = rms ( histo ) ;
const double _d = value - mean ( histo ) ;
return _r *_r + _d * _d ; // RETURN
}
const double n = nEff ( histo ) ;
if ( 0 >= n ) { return 0.0 ; } // RETURN
const int _order = (int) order ;
// get the exis
const AIDA::IAxis& axis = histo -> axis () ;
// number of bins
const int nBins = axis.bins() ;
double result = 0 ;
double weight = 0 ;
// loop over all bins
for ( int i = 0 ; i < nBins ; ++i )
{
const double lE = axis . binLowerEdge ( i ) ;
const double uE = axis . binUpperEdge ( i ) ;
//
const double yBin = histo -> binHeight ( i ) ; // bin weight
const double xBin = 0.5 * ( lE + uE ) ; // bin center
//
weight += yBin ;
result += yBin * std::pow ( xBin - value , _order ) ;
}
if ( 0 != weight ) { result /= weight ; }
return result ;
}
| double Gaudi::Utils::HistoStats::momentErr | ( | const AIDA::IHistogram1D * | histo, |
| const unsigned int | order | ||
| ) | [static] |
evaluate the uncertanty for 'bin-by-bin'-moment
| histo | histogram |
| order | the moment parameter |
| value | central value |
Definition at line 97 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
const double n = nEff ( histo ) ;
if ( 0 >= n ) { return 0.0 ; } // RETURN
const double a2o = moment ( histo , 2 * order ) ; // a(2o)
const double ao = moment ( histo , order ) ; // a(o)
double result = a2o - ao*ao ;
result /= n ;
result = std::max ( 0.0 , result ) ;
return std:: sqrt ( result ) ; // RETURN
}
| double Gaudi::Utils::HistoStats::nEff | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the effective entries (just for completeness)
Definition at line 218 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; }
return histo -> equivalentBinEntries () ;
}
| 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)
| histo | the pointer to the histogram |
| imin | the minimal bin number (included) |
| imax | the maximal bin number (not included) |
| number | of entries |
Definition at line 491 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_long_bad ; } // RETURN
if ( imin == imax ) { return 0 ; } // RETURN
if ( imax < imin ) { return nEntries ( histo , imax ,imin ) ; } // RETURN
//
long result = 0 ;
if ( 0 > imin )
{ result += histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ; }
// get the exis
const AIDA::IAxis& axis = histo -> axis () ;
// number of bins
const int nBins = axis.bins() ;
if ( nBins < imin ) { return 0 ; } // RETURN
// loop over all bins
for ( int i = 0 ; i < nBins ; ++i )
{ if ( imin <= i && i < imax ) { result += histo->binEntries ( i ) ; } }
//
if ( nBins < imax )
{ result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
//
return result ; // RETURN
}
| 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)
| histo | the pointer to the histogram |
| imax | the bin number (not included) |
| number | of entries |
Definition at line 461 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_long_bad ; } // RETURN
if ( 0 > imax ) { return 0 ; } // RETURN
long result = histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ;
// get the exis
const AIDA::IAxis& axis = histo -> axis () ;
// number of bins
const int nBins = axis.bins() ;
// loop over all bins
for ( int i = 0 ; i < nBins ; ++i )
{ if ( i < imax ) { result += histo->binEntries ( i ) ; } }
//
if ( nBins < imax )
{ result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
//
return result ;
}
| 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)
| histo | the pointer to the histogram |
| imin | the minimal bin number (included) |
| imax | the maximal bin number (not included) |
| fraction | of entries |
Definition at line 549 of file HistoStats.cpp.
| 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)
| histo | the pointer to the histogram |
| imax | the bin number (not included) |
| fraction | of entries |
Definition at line 526 of file HistoStats.cpp.
| 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)
| histo | the pointer to the histogram |
| imin | the minimal bin number (included) |
| imax | the maximal bin number (not included) |
| error | for the fraction of entries |
Definition at line 598 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double N = histo->allEntries () ;
if ( 0 >= N ) { return s_bad ; } // RETURN
const long n = nEntries ( histo , imin , imax ) ;
if ( 0 > n ) { return s_bad ; } // RETURN
if ( n > N ) { return s_bad ; } // RETURN
//
const double _n1 = std::max ( (double) n , 1.0 ) ;
const double _n2 = std::max ( ( N - n ) , 1.0 ) ;
//
return std::sqrt ( _n1 * _n2 / N ) / N ; // RETURN
}
| 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)
| histo | the pointer to the histogram |
| imax | the bin number (not included) |
| error | for the fraction of entries |
Definition at line 572 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double N = histo->allEntries () ;
if ( 0 >= N ) { return s_bad ; } // RETURN
const long n = nEntries ( histo , imax ) ;
if ( 0 > n ) { return s_bad ; } // RETURN
if ( n > N ) { return s_bad ; } // RETURN
//
const double _n1 = std::max ( (double) n , 1.0 ) ;
const double _n2 = std::max ( ( N - n ) , 1.0 ) ;
//
return std::sqrt ( _n1 * _n2 / N ) / N ; // RETURN
}
| double Gaudi::Utils::HistoStats::overflowEntriesFrac | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the fraction of overflow entries (useful for shape comparison)
Definition at line 309 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // REUTRN
const long overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN ) ;
if ( 0 == overflow ) { return 0 ; } // REUTRN
const long all = histo->allEntries() ;
if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
if ( 0 > all ) { return s_bad ; } // Lets be a bit paranoic, RETURN
//
double _tmp = (double) overflow ;
_tmp /= all ;
//
return _tmp ;
}
| double Gaudi::Utils::HistoStats::overflowEntriesFracErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
error on fraction of overflow entries (useful for shape comparison)
Definition at line 373 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN );
const double all = histo -> allEntries () ;
//
if ( 0 > overflow || 0 >= all || overflow > all ) { return s_bad ; }
//
const double n = std::max ( overflow , 1.0 ) ;
const double N = all ;
const double n1 = std::max ( N - n , 1.0 ) ;
//
return std::sqrt ( n * n1 / N ) / N ; // use the binomial formula
}
| double Gaudi::Utils::HistoStats::overflowIntegralFrac | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the fraction of overflow intergal (useful for shape comparison)
Definition at line 345 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // REUTRN
const double overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
if ( 0 == overflow ) { return 0 ; } // REUTRN
const double all = histo -> sumAllBinHeights() ;
if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
//
return overflow / all ;
}
| double Gaudi::Utils::HistoStats::overflowIntegralFracErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the error on fraction of overflow intergal
Definition at line 411 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double all = histo -> sumAllBinHeights () ;
if ( 0 == all ) { return s_bad ; } // RETURN
const double overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
const double oErr = histo -> binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
if ( 0 > oErr ) { return s_bad ; } // RETURN
const double aErr = sumAllBinHeightErr ( histo ) ;
if ( 0 > aErr ) { return s_bad ; } // RETURN
//
double error2 = oErr * oErr ;
error2 += aErr * aErr * overflow * overflow / all / all ;
error2 /= all * all ;
return std::sqrt ( error2 ) ;
}
| double Gaudi::Utils::HistoStats::rms | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the rms value for the histogram (just for completeness)
Definition at line 246 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; }
return histo -> rms () ;
}
| double Gaudi::Utils::HistoStats::rmsErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get an error in the rms value
Definition at line 255 of file HistoStats.cpp.
| double Gaudi::Utils::HistoStats::skewness | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the skewness for the histogram
Definition at line 167 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
const double mu3 = centralMoment ( histo , 3 ) ;
const double s3 = std::pow ( rms ( histo ) , 3 ) ;
return ( std::fabs(s3)>0 ? mu3/s3 : 0.0 );
}
| double Gaudi::Utils::HistoStats::skewnessErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get the error in skewness for the histogram
Definition at line 178 of file HistoStats.cpp.
| double Gaudi::Utils::HistoStats::sumAllBinHeightErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get an error in the sum of all bin height ("integral")
Definition at line 293 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; }
//
const double error = sumBinHeightErr( histo ) ;
if ( 0 > error ) { return s_bad ; }
const double err1 = histo->binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
const double err2 = histo->binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
//
return std::sqrt ( error * error + err1 * err1 + err2 * err2 ) ;
}
| double Gaudi::Utils::HistoStats::sumBinHeightErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
get an error in the sum bin height ("in-range integral")
Definition at line 270 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; }
//
double error2 = 0 ;
// get the exis
const AIDA::IAxis& axis = histo -> axis () ;
// number of bins
const int nBins = axis.bins() ;
// loop over all bins
for ( int i = 0 ; i < nBins ; ++i )
{
// get the error in each bin
const double berr = histo->binError ( i ) ;
// accumulate the errors:
error2 += berr * berr ;
}
return std::sqrt ( error2 ) ;
}
| double Gaudi::Utils::HistoStats::underflowEntriesFrac | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the fraction of underflow entries (useful for shape comparison)
Definition at line 327 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // REUTRN
const long underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN ) ;
if ( 0 == underflow ) { return 0 ; } // REUTRN
const long all = histo->allEntries() ;
if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
if ( 0 > all ) { return s_bad ; } // Lets be a bit paranoic, RETURN
//
double _tmp = (double) underflow ;
_tmp /= all ;
//
return _tmp ;
}
| double Gaudi::Utils::HistoStats::underflowEntriesFracErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the error on fraction of underflow entries (useful for shape comparison)
Definition at line 392 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN );
const double all = histo -> allEntries () ;
//
if ( 0 > underflow || 0 >= all || underflow > all ) { return s_bad ; }
//
const double n = std::max ( underflow , 1.0 ) ;
const double N = all ;
const double n1 = std::max ( N - n , 1.0 ) ;
//
return std::sqrt ( n * n1 / N ) / N ; // use the binomial formula
}
| double Gaudi::Utils::HistoStats::underflowIntegralFrac | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the fraction of underflow integral (useful for shape comparison)
Definition at line 359 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // REUTRN
const double underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
if ( 0 == underflow ) { return 0 ; } // REUTRN
const double all = histo -> sumAllBinHeights() ;
if ( 0 == all ) { return 0 ; } // "CONVENTION?" RETURN
//
return underflow / all ;
}
| double Gaudi::Utils::HistoStats::underflowIntegralFracErr | ( | const AIDA::IHistogram1D * | histo ) | [static] |
the error on fraction of underflow integral
Definition at line 433 of file HistoStats.cpp.
{
if ( 0 == histo ) { return s_bad ; } // RETURN
//
const double all = histo -> sumAllBinHeights () ;
if ( 0 == all ) { return s_bad ; } // RETURN
const double underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
const double oErr = histo -> binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
if ( 0 > oErr ) { return s_bad ; } // RETURN
const double aErr = sumAllBinHeightErr ( histo ) ;
if ( 0 > aErr ) { return s_bad ; } // RETURN
//
double error2 = oErr * oErr ;
error2 += aErr * aErr * underflow * underflow / all / all ;
error2 /= all * all ;
//
return std::sqrt ( error2 ) ;
}