#include <G4StatDouble.hh>
Public Member Functions | |
G4StatDouble () | |
virtual | ~G4StatDouble () |
void | reset () |
void | fill (G4double x, G4double weight=1.) |
void | scale (G4double) |
G4double | mean () const |
G4double | rms () |
G4double | mean (G4double ext_sum_w) const |
G4double | rms (G4double ext_sum_w, G4int ext_n) |
G4int | n () const |
G4double | sum_w () const |
G4double | sum_w2 () const |
G4double | sum_wx () const |
G4double | sum_wx2 () const |
Protected Member Functions | |
G4double | rms (G4double sum_wx, G4double sum_wx2, G4double sum_w, G4int n) |
Protected Attributes | |
G4double | m_sum_wx |
G4double | m_sum_wx2 |
G4int | m_n |
G4double | m_sum_w |
G4double | m_sum_w2 |
G4double | m_scale |
Definition at line 46 of file G4StatDouble.hh.
G4StatDouble::G4StatDouble | ( | ) |
G4StatDouble::~G4StatDouble | ( | ) | [virtual] |
Definition at line 58 of file G4StatDouble.cc.
References G4cout, G4endl, m_n, m_sum_w, m_sum_w2, m_sum_wx, and m_sum_wx2.
00059 { 00060 m_sum_wx += value * weight; 00061 m_sum_wx2 += value * value * weight; 00062 m_n++; 00063 m_sum_w += weight; 00064 m_sum_w2 += weight * weight; 00065 00066 if (weight <= 0.) 00067 { 00068 G4cout << "[G4StatDouble::fill] WARNING: weight<=0. " 00069 << weight << G4endl; 00070 } 00071 }
Definition at line 88 of file G4StatDouble.cc.
References m_sum_w, and mean().
00089 { 00090 G4double factor = 0.; 00091 // factor to rescale the Mean for the requested number 00092 // of events (or sum of weights) ext_sum_w 00093 00094 if (ext_sum_w > 0) 00095 { 00096 factor = m_sum_w; 00097 factor /= ext_sum_w; 00098 } 00099 return mean() * factor; 00100 00101 }
G4double G4StatDouble::mean | ( | ) | const |
G4int G4StatDouble::n | ( | ) | const [inline] |
void G4StatDouble::reset | ( | ) |
G4double G4StatDouble::rms | ( | G4double | sum_wx, | |
G4double | sum_wx2, | |||
G4double | sum_w, | |||
G4int | n | |||
) | [protected] |
Definition at line 103 of file G4StatDouble.cc.
References m_scale.
00105 { 00106 G4double vrms; 00107 if (nn > 1) 00108 { 00109 G4double vmean = ssum_wx / ssum_w; 00110 G4double xn = nn; 00111 G4double tmp = 00112 // from GNU Scientific Library. This part is equivalent to N/(N-1) 00113 // when w_i = w 00114 // ((m_sum_w * m_sum_w) / (m_sum_w * m_sum_w - m_sum_w2)) 00115 00116 // from NIST "DATAPLOT Reference manual", Page 2-66 00117 // http://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weightsd.pdf 00118 // rewritten based on: SUM[w(x-m)^2]/SUM[w] = SUM[wx^2]/SUM[w] - m^2 00119 // and dividing it by sqrt[n] to go from rms of distribution to the 00120 // rms of the mean value 00121 00122 (1. / (xn - 1)) 00123 * ((ssum_wx2 / ssum_w) - (vmean * vmean)); 00124 00125 if (tmp < 0.) tmp=0.; // this avoids observed computation problem 00126 vrms = std::sqrt( tmp ); 00127 // G4cout << "[G4StatDoubleElement::rms] m_sum_wx: " << m_sum_wx 00128 // << " m_sum_wx2: " << m_sum_wx2 << " m_sum_w: " << m_sum_w 00129 // << " m_n: " << m_n << " tmp: " << tmp<< " rms: " << rms 00130 // << G4endl; 00131 // G4cout << "[G4StatDoubleElement::rms] (m_n / (m_n - 1)): " << (xn/(xn - 1)) 00132 // << " (m_sum_wx2 / m_sum_w): " << (m_sum_wx2 / m_sum_w) 00133 // << " (mean * mean): " << (mean * mean) 00134 // << " ((m_sum_wx2 / m_sum_w) - (mean * mean)): " 00135 // << ((m_sum_wx2 / m_sum_w) - (mean * mean)) 00136 // << G4endl; 00137 } 00138 else 00139 { 00140 vrms = -1.; 00141 } 00142 return vrms * m_scale; 00143 }
Definition at line 153 of file G4StatDouble.cc.
References m_sum_wx, m_sum_wx2, and rms().
00154 { 00155 // this method computes the RMS with sum_w and n coming from outside: 00156 // ext_sum_w and ext_n: 00157 // this means that the result is normalised to the external events 00158 // it is useful when, given a number ext_n of events with sum of the weights 00159 // ext_sum_w, only m_n (with sum of weights m_sum_w) are actually accumulated 00160 // in the internal summation (e.g. for a dose variable in a volume, because 00161 // only a few particles reach that volume) 00162 00163 return rms(m_sum_wx, m_sum_wx2, ext_sum_w, ext_n); 00164 }
G4double G4StatDouble::rms | ( | ) |
Definition at line 145 of file G4StatDouble.cc.
References m_n, m_sum_w, m_sum_wx, and m_sum_wx2.
Referenced by rms().
00146 { 00147 // this method computes the RMS with "all internal" parameters: 00148 // all the sums are the internal ones: m_sum_wx, m_sum_wx2, m_sum_w, m_n 00149 00150 return rms(m_sum_wx, m_sum_wx2, m_sum_w, m_n); 00151 }
void G4StatDouble::scale | ( | G4double | ) |
G4double G4StatDouble::sum_w | ( | ) | const [inline] |
G4double G4StatDouble::sum_w2 | ( | ) | const [inline] |
G4double G4StatDouble::sum_wx | ( | ) | const [inline] |
G4double G4StatDouble::sum_wx2 | ( | ) | const [inline] |
G4int G4StatDouble::m_n [protected] |
G4double G4StatDouble::m_scale [protected] |
G4double G4StatDouble::m_sum_w [protected] |
G4double G4StatDouble::m_sum_w2 [protected] |
G4double G4StatDouble::m_sum_wx [protected] |
G4double G4StatDouble::m_sum_wx2 [protected] |