![]() |
|
|
Generated: 24 Nov 2008 |
#include <GaudiUtils/HistoStats.h>
Definition at line 27 of file 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) | |
| 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 42 of file HistoStats.cpp.
00045 { 00046 if ( 0 == histo ) { return s_bad ; } // RETURN 00047 if ( 0 == order ) { return 1.0 ; } // RETURN 00048 if ( 1 == order ) { return mean( histo ) - value ; } // RETURN 00049 if ( 2 == order ) 00050 { 00051 const double _r = rms ( histo ) ; 00052 const double _d = value - mean ( histo ) ; 00053 return _r *_r + _d * _d ; // RETURN 00054 } 00055 const double n = nEff ( histo ) ; 00056 if ( 0 >= n ) { return 0.0 ; } // RETURN 00057 00058 const int _order = (int) order ; 00059 00060 // get the exis 00061 const AIDA::IAxis& axis = histo -> axis () ; 00062 // number of bins 00063 const int nBins = axis.bins() ; 00064 double result = 0 ; 00065 double weight = 0 ; 00066 // loop over all bins 00067 for ( int i = 0 ; i < nBins ; ++i ) 00068 { 00069 const double lE = axis . binLowerEdge ( i ) ; 00070 const double uE = axis . binUpperEdge ( i ) ; 00071 // 00072 const double yBin = histo -> binHeight ( i ) ; // bin weight 00073 const double xBin = 0.5 * ( lE + uE ) ; // bin center 00074 // 00075 weight += yBin ; 00076 result += yBin * std::pow ( xBin - value , _order ) ; 00077 } 00078 if ( 0 != weight ) { result /= weight ; } 00079 return result ; 00080 }
| 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 90 of file HistoStats.cpp.
00092 { 00093 if ( 0 == histo ) { return s_bad ; } // RETURN 00094 const double n = nEff ( histo ) ; 00095 if ( 0 >= n ) { return 0.0 ; } // RETURN 00096 const double a2o = moment ( histo , 2 * order ) ; // a(2o) 00097 const double ao = moment ( histo , 2 * order ) ; // a(o) 00098 double result = a2o - ao*ao ; 00099 result /= n ; 00100 result = std::max ( 0.0 , result ) ; 00101 return std:: sqrt ( result ) ; // RETURN 00102 }
| 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 112 of file HistoStats.cpp.
00114 { 00115 if ( 0 == histo ) { return s_bad ; } // RETURN 00116 if ( 0 == order ) { return 1.0 ; } // RETURN 00117 if ( 1 == order ) { return 0.0 ; } // RETURN 00118 if ( 2 == order ) 00119 { 00120 const double sigma = histo->rms() ; 00121 return sigma * sigma ; // RETURN 00122 } 00123 // delegate the actual evaluation to another method: 00124 return moment ( histo , order , mean ( histo ) ) ; 00125 }
| 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 137 of file HistoStats.cpp.
00139 { 00140 if ( 0 == histo ) { return s_bad ; } // RETURN 00141 const double n = nEff ( histo ) ; 00142 if ( 0 >= n ) { return 0.0 ; } // RETURN 00143 const double mu2 = centralMoment ( histo , 2 ) ; // mu(2) 00144 const double muo = centralMoment ( histo , order ) ; // mu(o) 00145 const double mu2o = centralMoment ( histo , 2 * order ) ; // mu(2o) 00146 const double muom = centralMoment ( histo , order - 1 ) ; // mu(o-1) 00147 const double muop = centralMoment ( histo , order + 1 ) ; // mu(o+1) 00148 double result = mu2o ; 00149 result -= 2.0 * order * muom * muop ; 00150 result -= muo * muo ; 00151 result += order * order * mu2 * muom * muom ; 00152 result /= n ; 00153 result = std::max ( 0.0 , result ) ; 00154 return std:: sqrt ( result ) ; // RETURN 00155 }
| double Gaudi::Utils::HistoStats::skewness | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the skewness for the histogram
Definition at line 160 of file HistoStats.cpp.
00161 { 00162 if ( 0 == histo ) { return s_bad ; } // RETURN 00163 const double mu3 = centralMoment ( histo , 3 ) ; 00164 const double s3 = std::pow ( rms ( histo ) , 3 ) ; 00165 return ( std::fabs(s3)>0 ? mu3/s3 : 0.0 ); 00166 }
| double Gaudi::Utils::HistoStats::skewnessErr | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the error in skewness for the histogram
Definition at line 171 of file HistoStats.cpp.
00172 { 00173 if ( 0 == histo ) { return s_bad ; } // RETURN 00174 const double n = nEff ( histo ) ; 00175 if ( 2 > n ) { return 0.0 ; } // RETURN 00176 double result = 6 ; 00177 result *= ( n - 2 ) ; 00178 result /= ( n + 1 ) * ( n + 3 ) ; 00179 return std::sqrt ( result ) ; 00180 }
| double Gaudi::Utils::HistoStats::kurtosis | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the kurtosis for the histogram
Definition at line 185 of file HistoStats.cpp.
00186 { 00187 if ( 0 == histo ) { return s_bad ; } // RETURN 00188 const double mu4 = centralMoment ( histo , 4 ) ; 00189 const double s4 = std::pow ( rms ( histo ) , 4 ) ; 00190 return ( std::fabs(s4)>0 ? mu4/s4 - 3.0 : 0.0 ); 00191 }
| double Gaudi::Utils::HistoStats::kurtosisErr | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the error in kurtosis for the histogram
Definition at line 196 of file HistoStats.cpp.
00197 { 00198 if ( 0 == histo ) { return s_bad ; } // RETURN 00199 const double n = nEff ( histo ) ; 00200 if ( 3 > n ) { return 0.0 ; } // RETURN 00201 double result = 24 ; 00202 result *= ( n - 2 ) * ( n - 3 ) ; 00203 result /= ( n + 1 ) * ( n + 1 ) ; 00204 result /= ( n + 3 ) * ( n + 5 ) ; 00205 return std::sqrt ( result ) ; 00206 }
| double Gaudi::Utils::HistoStats::mean | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the mean value for the histogram (just for completeness)
Definition at line 220 of file HistoStats.cpp.
| double Gaudi::Utils::HistoStats::meanErr | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get an error in the mean value
Definition at line 229 of file HistoStats.cpp.
00230 { 00231 if ( 0 == histo ) { return s_bad ; } 00232 const double n = nEff ( histo ) ; 00233 return 0 >= n ? 0.0 : rms ( histo ) / std::sqrt ( n ) ; 00234 }
| double Gaudi::Utils::HistoStats::rms | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the rms value for the histogram (just for completeness)
Definition at line 239 of file HistoStats.cpp.
| double Gaudi::Utils::HistoStats::rmsErr | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get an error in the rms value
Definition at line 248 of file HistoStats.cpp.
00249 { 00250 if ( 0 == histo ) { return s_bad ; } 00251 const double n = nEff ( histo ) ; 00252 if ( 1 >= n ) { return 0.0 ; } 00253 double result = 2 + kurtosis ( histo ) ; 00254 result += 2.0 /( n - 1 ) ; 00255 result /= 4.0 * n ; 00256 result = std::max ( result , 0.0 ) ; 00257 return histo -> rms() * std::sqrt ( result ) ; 00258 }
| double Gaudi::Utils::HistoStats::nEff | ( | const AIDA::IHistogram1D * | histo | ) | [static] |
get the effective entries (just for completeness)
Definition at line 211 of file HistoStats.cpp.
00212 { 00213 if ( 0 == histo ) { return s_bad ; } 00214 return histo -> equivalentBinEntries () ; 00215 }