herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
Statistic.h
1
// -*- C++ -*-
2
//
3
// Statistic.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4
// Copyright (C) 2002-2019 The Herwig Collaboration
5
//
6
// Herwig is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef HERWIG_Statistic_H
10
#define HERWIG_Statistic_H
11
#include <cmath>
12
13
//
14
// This is the declaration of the Statistic class.
15
//
16
17
namespace
Herwig
{
18
23
class
Statistic
{
24
25
public
:
26
30
Statistic
() :
_n
(0),
_xsum
(0.),
_x2sum
(0.),
31
_min
(-1e100),
_max
(1e100) {}
32
36
double
minimum
()
const
{
return
_min
; }
37
41
double
maximum
()
const
{
return
_max
; }
42
46
void
operator+=
(
double
input)
47
{
48
++
_n
;
49
_xsum
+= input;
50
_x2sum
+= input * input;
51
if
(
_min
> input ||
_n
== 1)
_min
= input;
52
if
(
_max
< input ||
_n
== 1)
_max
= input;
53
}
54
58
unsigned
int
numberOfPoints
()
const
{
return
_n
; }
59
63
double
mean
()
const
64
{
65
return
_n
> 0 ?
_xsum
/
_n
: 0.;
66
}
67
75
double
mean_stdDev
()
const
{
return
std::sqrt(
mean_var
()); }
76
84
double
mean_var
()
const
85
{
86
return
_n
> 1 ?
var
() /
_n
: 0.;
87
}
88
92
double
stdDev
()
const
{
return
std::sqrt(
var
()); }
93
97
double
var
()
const
98
{
99
return
_n
> 1 ? (
_x2sum
-
_xsum
*
_xsum
/
_n
) / (
_n
- 1 ) : 0.;
100
}
101
105
double
total
()
const
{
return
_xsum
; }
106
107
private
:
108
112
unsigned
int
_n
;
113
117
double
_xsum
;
118
122
double
_x2sum
;
123
127
double
_min
;
128
132
double
_max
;
133
};
134
135
}
136
137
#endif
/* HERWIG_Statistic_H */
Herwig::Statistic
The Statistic class is a simple class designed to store a variable for statistical analysis.
Definition:
Statistic.h:23
Herwig::Statistic::_max
double _max
The maximum value.
Definition:
Statistic.h:132
Herwig::Statistic::minimum
double minimum() const
The minimum value.
Definition:
Statistic.h:36
Herwig::Statistic::mean_stdDev
double mean_stdDev() const
Error on the mean estimate.
Definition:
Statistic.h:75
Herwig::Statistic::mean_var
double mean_var() const
Variance on the mean estimate.
Definition:
Statistic.h:84
Herwig::Statistic::_x2sum
double _x2sum
Sum of the squares of the values.
Definition:
Statistic.h:122
Herwig::Statistic::total
double total() const
Total entry.
Definition:
Statistic.h:105
Herwig::Statistic::_n
unsigned int _n
Number of entries.
Definition:
Statistic.h:112
Herwig::Statistic::maximum
double maximum() const
The maximum value.
Definition:
Statistic.h:41
Herwig::Statistic::_xsum
double _xsum
Sum of the values.
Definition:
Statistic.h:117
Herwig::Statistic::_min
double _min
The minimum value.
Definition:
Statistic.h:127
Herwig::Statistic::numberOfPoints
unsigned int numberOfPoints() const
Number of points.
Definition:
Statistic.h:58
Herwig::Statistic::mean
double mean() const
Mean.
Definition:
Statistic.h:63
Herwig::Statistic::operator+=
void operator+=(double input)
Operator to add another point.
Definition:
Statistic.h:46
Herwig::Statistic::stdDev
double stdDev() const
Standard Deviation.
Definition:
Statistic.h:92
Herwig::Statistic::Statistic
Statistic()
The default constructor.
Definition:
Statistic.h:30
Herwig::Statistic::var
double var() const
Variance.
Definition:
Statistic.h:97
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6