File indexing completed on 2024-04-06 12:01:11
0001 #ifndef Statistics_AutocorrelationAnalyzer_h
0002 #define Statistics_AutocorrelationAnalyzer_h
0003
0004 #include "CLHEP/Matrix/Vector.h"
0005 #include "CLHEP/Matrix/SymMatrix.h"
0006 #include "CLHEP/Matrix/Matrix.h"
0007 #include <iosfwd>
0008
0009
0010
0011
0012
0013
0014
0015 class AutocorrelationAnalyzer {
0016 public:
0017 explicit AutocorrelationAnalyzer(int size);
0018
0019
0020 double mean(int i);
0021 double covariance(int i, int j);
0022 double correlation(int i, int j);
0023
0024 template <class T>
0025 void analyze(const T& t) {
0026 for (int ii = 0; ii < theSize; ii++) {
0027 theMeans[ii] += t[ii];
0028 for (int ij = ii; ij < theSize; ij++) {
0029 theCovariances[ii][ij] += t[ii] * t[ij];
0030 }
0031 }
0032 ++theNTotal;
0033 }
0034
0035 friend std::ostream& operator<<(std::ostream& os, AutocorrelationAnalyzer& aa);
0036
0037 private:
0038 void calculate();
0039
0040 int theSize;
0041 int theNTotal;
0042 CLHEP::HepVector theMeans;
0043 CLHEP::HepSymMatrix theCovariances;
0044 CLHEP::HepSymMatrix theCorrelations;
0045 bool calculated_;
0046 };
0047
0048 #endif