Main Page
Namespaces
Classes
Package Documentation
src
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
()
5
: sum_(0.),
6
sumOfSquares_(0.),
7
weightedSum_(0.),
8
sumOfWeights_(0.),
9
n_(0)
10
{
11
}
12
13
14
void
Accumulator::addEntry
(
double
value
,
double
weight
) {
15
sum_
+=
value
;
16
sumOfSquares_
+= (value*
value
);
17
weightedSum_
+= value*
weight
;
18
sumOfWeights_
+=
weight
;
19
++
n_
;
20
}
21
22
23
double
Accumulator::mean
()
const
{
24
return
sum_
/
n_
;
25
}
26
27
28
double
Accumulator::variance
()
const
{
29
double
numerator
=
sumOfSquares_
-
sum_
*
mean
();
30
unsigned
long
denominator
=
n_
-1;
31
return
numerator/
denominator
;
32
}
33
34
35
double
Accumulator::weightedMean
()
const
{
36
return
weightedSum_
/
sumOfWeights_
;
37
}
38
39
40
std::ostream&
operator<<
(std::ostream & os,
const
Accumulator
&
stat
) {
41
os <<
"entries: "
<< stat.
nEntries
();
42
if
(stat.
nEntries
() > 0) {
43
os <<
" Mean: "
<< stat.
mean
();
44
}
45
if
(stat.
nEntries
() > 1) {
46
os <<
" Sigma: "
<< stat.
sigma
();
47
}
48
return
os;
49
}
50
51
Accumulator::Accumulator
Accumulator()
Definition:
Accumulator.cc:4
stat
Accumulator::addEntry
void addEntry(double value, double weight=1.)
Definition:
Accumulator.cc:14
Accumulator::mean
double mean() const
Definition:
Accumulator.cc:23
Accumulator::weightedSum_
double weightedSum_
Definition:
Accumulator.h:32
weight
Definition:
weight.py:1
Accumulator::n_
unsigned long n_
Definition:
Accumulator.h:34
Accumulator
Definition:
Accumulator.h:12
Accumulator::nEntries
unsigned long nEntries() const
Definition:
Accumulator.h:27
Accumulator::sigma
double sigma() const
Definition:
Accumulator.h:23
Accumulator::sum_
double sum_
Definition:
Accumulator.h:30
pfDeepCMVADiscriminatorsJetTags_cfi.denominator
denominator
Definition:
pfDeepCMVADiscriminatorsJetTags_cfi.py:12
Accumulator::weightedMean
double weightedMean() const
Definition:
Accumulator.cc:35
value
Definition:
value.py:1
pfDeepCMVADiscriminatorsJetTags_cfi.numerator
numerator
Definition:
pfDeepCMVADiscriminatorsJetTags_cfi.py:8
relativeConstraints.value
value
Definition:
relativeConstraints.py:53
operator<<
std::ostream & operator<<(std::ostream &os, const Accumulator &stat)
Definition:
Accumulator.cc:40
Accumulator.h
Accumulator::variance
double variance() const
Definition:
Accumulator.cc:28
mps_merge.weight
weight
Definition:
mps_merge.py:88
Accumulator::sumOfSquares_
double sumOfSquares_
Definition:
Accumulator.h:31
Accumulator::sumOfWeights_
double sumOfWeights_
Definition:
Accumulator.h:33
Generated for CMSSW Reference Manual by
1.8.11