/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CommonTools/Statistics/interface/AutocorrelationAnalyzer.h
48 строк
1 KB
Cms Build
Clang-Format
03 июн 2019, 06:44
03 июн 2019, 06:44
6a63925
Код
Авторство
О чём код?
#ifndef Statistics_AutocorrelationAnalyzer_h #define Statistics_AutocorrelationAnalyzer_h #include "CLHEP/Matrix/Vector.h" #include "CLHEP/Matrix/SymMatrix.h" #include "CLHEP/Matrix/Matrix.h" #include <iosfwd> /** This class accepts objects which support the [] operator, * such as a digi or a vector, * and calculates the correlation matrix between the components * \Author Rick Wilkinson, Fedor Ratnikov */ class AutocorrelationAnalyzer { public: explicit AutocorrelationAnalyzer(int size); /// indexing starts from 0 double mean(int i); double covariance(int i, int j); double correlation(int i, int j); template <class T> void analyze(const T& t) { for (int ii = 0; ii < theSize; ii++) { theMeans[ii] += t[ii]; for (int ij = ii; ij < theSize; ij++) { theCovariances[ii][ij] += t[ii] * t[ij]; } } ++theNTotal; } friend std::ostream& operator<<(std::ostream& os, AutocorrelationAnalyzer& aa); private: void calculate(); int theSize; int theNTotal; CLHEP::HepVector theMeans; CLHEP::HepSymMatrix theCovariances; CLHEP::HepSymMatrix theCorrelations; bool calculated_; }; #endif