CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CommonTools/Statistics/interface/Accumulator.h

Go to the documentation of this file.
00001 #ifndef Statistics_Accumulator_h
00002 #define Statistics_Accumulator_h
00003 
00009 #include <iosfwd>
00010 #include<cmath>
00011 
00012 class Accumulator
00013 {
00014 public:
00015   Accumulator();
00016 
00017   void addEntry(double value, double weight=1.);
00018 
00019   double mean() const;
00020 
00021   double variance() const;
00022 
00023   double sigma() const {return std::sqrt(variance());}
00024 
00025   double weightedMean() const;
00026 
00027   unsigned long nEntries() const {return n_;}
00028 
00029 private:
00030   double sum_;
00031   double sumOfSquares_;
00032   double weightedSum_;
00033   double sumOfWeights_;
00034   unsigned long n_;
00035 };
00036 
00037 std::ostream & operator<<(std::ostream & os, const Accumulator & stat);
00038 
00039 #endif
00040