CMS 3D CMS Logo

Accumulator.h
Go to the documentation of this file.
1 #ifndef Statistics_Accumulator_h
2 #define Statistics_Accumulator_h
3 
9 #include <iosfwd>
10 #include <cmath>
11 
12 class Accumulator {
13 public:
14  Accumulator();
15 
16  void addEntry(double value, double weight = 1.);
17 
18  double mean() const;
19 
20  double variance() const;
21 
22  double sigma() const { return std::sqrt(variance()); }
23 
24  double weightedMean() const;
25 
26  unsigned long nEntries() const { return n_; }
27 
28 private:
29  double sum_;
30  double sumOfSquares_;
31  double weightedSum_;
32  double sumOfWeights_;
33  unsigned long n_;
34 };
35 
36 std::ostream& operator<<(std::ostream& os, const Accumulator& stat);
37 
38 #endif
unsigned long nEntries() const
Definition: Accumulator.h:26
void addEntry(double value, double weight=1.)
Definition: Accumulator.cc:6
double weightedSum_
Definition: Accumulator.h:31
Definition: weight.py:1
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
std::ostream & operator<<(std::ostream &os, const Accumulator &stat)
Definition: Accumulator.cc:24
T sqrt(T t)
Definition: SSEVec.h:19
double sigma() const
Definition: Accumulator.h:22
Definition: value.py:1
double mean() const
Definition: Accumulator.cc:14
double weightedMean() const
Definition: Accumulator.cc:22
double variance() const
Definition: Accumulator.cc:16
double sumOfSquares_
Definition: Accumulator.h:30
double sumOfWeights_
Definition: Accumulator.h:32