![]() |
![]() |
00001 #ifndef Statistics_AutocorrelationAnalyzer_h 00002 #define Statistics_AutocorrelationAnalyzer_h 00003 00004 #include "CLHEP/Matrix/Vector.h" 00005 #include "CLHEP/Matrix/SymMatrix.h" 00006 #include "CLHEP/Matrix/Matrix.h" 00007 #include <iosfwd> 00008 00015 class AutocorrelationAnalyzer 00016 { 00017 public: 00018 explicit AutocorrelationAnalyzer(int size); 00019 00021 double mean(int i); 00022 double covariance(int i, int j); 00023 double correlation(int i, int j); 00024 00025 template<class T> 00026 void analyze(const T & t) 00027 { 00028 for (int ii = 0; ii < theSize; ii++) { 00029 theMeans[ii] += t[ii]; 00030 for (int ij = ii; ij < theSize; ij++) { 00031 theCovariances[ii][ij] += t[ii] * t[ij]; 00032 } 00033 } 00034 ++theNTotal; 00035 } 00036 00037 friend std::ostream & operator<<(std::ostream & os, AutocorrelationAnalyzer & aa); 00038 00039 private: 00040 void calculate(); 00041 00042 int theSize; 00043 int theNTotal; 00044 CLHEP::HepVector theMeans; 00045 CLHEP::HepSymMatrix theCovariances; 00046 CLHEP::HepSymMatrix theCorrelations; 00047 bool calculated_; 00048 }; 00049 00050 #endif 00051