Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
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
() : 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
cuy.numerator
list numerator
Definition:
cuy.py:484
Accumulator::addEntry
void addEntry(double value, double weight=1.)
Definition:
Accumulator.cc:6
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:55
Accumulator::mean
double mean() const
Definition:
Accumulator.cc:14
Accumulator::weightedSum_
double weightedSum_
Definition:
Accumulator.h:31
operator<<
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition:
ALILine.cc:167
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
cuy.denominator
list denominator
Definition:
cuy.py:485
Accumulator::weightedMean
double weightedMean() const
Definition:
Accumulator.cc:22
edm_modernize_messagelogger.stat
stat
Definition:
edm_modernize_messagelogger.py:27
Accumulator.h
Accumulator::variance
double variance() const
Definition:
Accumulator.cc:16
histoStyle.weight
int weight
Definition:
histoStyle.py:51
Accumulator::sumOfSquares_
double sumOfSquares_
Definition:
Accumulator.h:30
Accumulator::sumOfWeights_
double sumOfWeights_
Definition:
Accumulator.h:32
Generated for CMSSW Reference Manual by
1.8.5