Main Page
Namespaces
Classes
Package Documentation
CommonTools
Statistics
src
Accumulator.cc
Go to the documentation of this file.
1
#include "
CommonTools/Statistics/interface/Accumulator.h
"
2
#include <ostream>
3
4
Accumulator::Accumulator
() : sum_(0.), sumOfSquares_(0.), weightedSum_(0.), sumOfWeights_(0.), n_(0) {}
5
6
void
Accumulator::addEntry
(
double
value
,
double
weight
) {
7
sum_
+=
value
;
8
sumOfSquares_
+= (value *
value
);
9
weightedSum_
+= value *
weight
;
10
sumOfWeights_
+=
weight
;
11
++
n_
;
12
}
13
14
double
Accumulator::mean
()
const
{
return
sum_
/
n_
; }
15
16
double
Accumulator::variance
()
const
{
17
double
numerator
=
sumOfSquares_
-
sum_
*
mean
();
18
unsigned
long
denominator
=
n_
- 1;
19
return
numerator /
denominator
;
20
}
21
22
double
Accumulator::weightedMean
()
const
{
return
weightedSum_
/
sumOfWeights_
; }
23
24
std::ostream&
operator<<
(std::ostream& os,
const
Accumulator
&
stat
) {
25
os <<
"entries: "
<< stat.
nEntries
();
26
if
(stat.
nEntries
() > 0) {
27
os <<
" Mean: "
<< stat.
mean
();
28
}
29
if
(stat.
nEntries
() > 1) {
30
os <<
" Sigma: "
<< stat.
sigma
();
31
}
32
return
os;
33
}
Accumulator::Accumulator
Accumulator()
Definition:
Accumulator.cc:4
stat
Accumulator::addEntry
void addEntry(double value, double weight=1.)
Definition:
Accumulator.cc:6
Accumulator::mean
double mean() const
Definition:
Accumulator.cc:14
Accumulator::weightedSum_
double weightedSum_
Definition:
Accumulator.h:31
weight
Definition:
weight.py:1
Accumulator::n_
unsigned long n_
Definition:
Accumulator.h:33
Accumulator
Definition:
Accumulator.h:12
Accumulator::nEntries
unsigned long nEntries() const
Definition:
Accumulator.h:26
Accumulator::sigma
double sigma() const
Definition:
Accumulator.h:22
Accumulator::sum_
double sum_
Definition:
Accumulator.h:29
Accumulator::weightedMean
double weightedMean() const
Definition:
Accumulator.cc:22
value
Definition:
value.py:1
relativeConstraints.value
value
Definition:
relativeConstraints.py:53
HLTTauDQMOffline_cfi.denominator
denominator
Definition:
HLTTauDQMOffline_cfi.py:175
operator<<
std::ostream & operator<<(std::ostream &os, const Accumulator &stat)
Definition:
Accumulator.cc:24
Accumulator.h
Accumulator::variance
double variance() const
Definition:
Accumulator.cc:16
mps_merge.weight
weight
Definition:
mps_merge.py:88
Accumulator::sumOfSquares_
double sumOfSquares_
Definition:
Accumulator.h:30
HLTTauDQMOffline_cfi.numerator
numerator
Definition:
HLTTauDQMOffline_cfi.py:174
Accumulator::sumOfWeights_
double sumOfWeights_
Definition:
Accumulator.h:32
Generated for CMSSW Reference Manual by
1.8.11