Changeset 3147 in Sophya for trunk/SophyaLib/HiStats/histerr.cc
- Timestamp:
- Jan 18, 2007, 7:20:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/histerr.cc
r3136 r3147 18 18 HistoErr::HistoErr(void) 19 19 : xmin_(1.), xmax_(-1.), nx_(0), dx_(0.) 20 , m Correl(0)20 , mMean(0) 21 21 { 22 22 } … … 25 25 /*! Constructeur d'un histo */ 26 26 HistoErr::HistoErr(r_8 xmin,r_8 xmax,int_4 nx) 27 : m Correl(0)27 : mMean(0) 28 28 { 29 29 CreateOrResize(xmin,xmax,nx); … … 33 33 /*! Constructeur par copie */ 34 34 HistoErr::HistoErr(const HistoErr& H) 35 : m Correl(H.mCorrel)35 : mMean(H.mMean) 36 36 { 37 37 if(H.nx_<=0) return; … … 46 46 HistoErr::~HistoErr(void) 47 47 { 48 m Correl= 0;48 mMean = 0; 49 49 } 50 50 … … 60 60 dx_ = (xmax_-xmin_)/nx_; 61 61 } 62 m Correl= 0;62 mMean = 0; 63 63 } 64 64 … … 95 95 /********* Methode *********/ 96 96 /*! 97 Compute the correlation histogram.98 Each bin content is divided by the number of entries in th atbin.99 Each squared error is divided by the number of entries in th atbin.100 The number of entries by bin is NOT set to 1 (calling ToCorrel101 102 */ 103 void HistoErr::To Correl(void)97 Compute the mean histogram. 98 Each bin content is divided by the number of entries in the bin. 99 Each squared error is divided by the number of entries in the bin. 100 The number of entries by bin is NOT set to 1 101 (calling ToMean many time will change the histogram !) 102 */ 103 void HistoErr::ToMean(void) 104 104 { 105 105 if(nx_<1) return; 106 m Correl++;106 mMean++; 107 107 for(int_4 i=0;i<nx_;i++) { 108 108 if(ndata_(i)<1.) continue; … … 115 115 /********* Methode *********/ 116 116 /*! 117 Recompute back the original HistoErr before ToCorrelaction118 */ 119 void HistoErr::From Correl(void)117 Recompute back the original HistoErr after ToMean action 118 */ 119 void HistoErr::FromMean(void) 120 120 { 121 121 if(nx_<1) return; 122 m Correl--;122 mMean--; 123 123 for(int_4 i=0;i<nx_;i++) { 124 124 if(ndata_(i)<1.) continue; 125 125 data_(i) *= ndata_(i); 126 126 err2_(i) *= ndata_(i); 127 } 128 return; 129 } 130 131 /********* Methode *********/ 132 /*! 133 Compute the mean histogram and replace the "error table" by the variance. 134 This should be done if Add(x,w,w) has been used. 135 The "value table" is divided by the number of entries to get the mean 136 The "error table" is replace by the variance 137 The number of entries by bin is NOT set to 1 138 (calling ToMean many time will change the histogram !) 139 Mixing ToMean and ToVariance leads to unpredictable results 140 */ 141 void HistoErr::ToVariance(void) 142 { 143 if(nx_<1) return; 144 mMean++; 145 for(int_4 i=0;i<nx_;i++) { 146 if(ndata_(i)<1.) continue; 147 data_(i) /= ndata_(i); 148 err2_(i) = err2_(i)/ndata_(i) - data_(i)*data_(i); 149 } 150 return; 151 } 152 153 /********* Methode *********/ 154 /*! 155 Recompute back the original HistoErr after ToVariance action 156 Mixing FromMean and FromVariance leads to unpredictable results 157 */ 158 void HistoErr::FromVariance(void) 159 { 160 if(nx_<1) return; 161 mMean--; 162 for(int_4 i=0;i<nx_;i++) { 163 if(ndata_(i)<1.) continue; 164 err2_(i) = ndata_(i)*(err2_(i) + data_(i)*data_(i)); 165 data_(i) *= ndata_(i); 127 166 } 128 167 return; … … 148 187 ndata_(ii) += hfrom.ndata_(ii); 149 188 } 150 m Correl = hfrom.mCorrel;189 mMean = hfrom.mMean; 151 190 152 191 } … … 163 202 err2_ = h.err2_; 164 203 ndata_ = h.ndata_; 165 m Correl = h.mCorrel;204 mMean = h.mMean; 166 205 return *this; 167 206 } … … 187 226 void HistoErr::Show(ostream & os) const 188 227 { 189 os <<"HistoErr(n correl="<<mCorrel<<")"<<endl228 os <<"HistoErr(nmean="<<mMean<<")"<<endl 190 229 <<" nx="<<nx_<<" ["<<xmin_<<","<<xmax_<<"] dx="<<dx_<<endl; 191 230 } … … 207 246 is.GetStr(strg); 208 247 209 // Nombre d'appels a To Correl/FromCorrel210 is.Get(dobj->m Correl);248 // Nombre d'appels a ToMean/FromMean 249 is.Get(dobj->mMean); 211 250 212 251 // Lecture des parametres HistoErr … … 236 275 os.PutStr(strg); 237 276 238 // Nombre d'appels a To Correl/FromCorrel239 os.Put(dobj->m Correl);277 // Nombre d'appels a ToMean/FromMean 278 os.Put(dobj->mMean); 240 279 241 280 // Ecriture des parametres HistoErr
Note:
See TracChangeset
for help on using the changeset viewer.