Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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
cuy.numerator
list numerator
Definition:
cuy.py:483
Accumulator::addEntry
void addEntry(double value, double weight=1.)
Definition:
Accumulator.cc:14
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:54
Accumulator::mean
double mean() const
Definition:
Accumulator.cc:23
puppiForMET_cff.weight
tuple weight
Definition:
puppiForMET_cff.py:35
Accumulator::weightedSum_
double weightedSum_
Definition:
Accumulator.h:32
operator<<
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition:
ALILine.cc:187
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
cuy.denominator
list denominator
Definition:
cuy.py:484
Accumulator::weightedMean
double weightedMean() const
Definition:
Accumulator.cc:35
Accumulator.h
Accumulator::variance
double variance() const
Definition:
Accumulator.cc:28
Accumulator::sumOfSquares_
double sumOfSquares_
Definition:
Accumulator.h:31
Accumulator::sumOfWeights_
double sumOfWeights_
Definition:
Accumulator.h:33
Generated for CMSSW Reference Manual by
1.8.5