herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
f
g
h
i
l
m
o
p
r
s
t
u
w
z
Variables
Typedefs
a
b
c
d
h
i
j
k
l
m
o
p
s
t
v
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
c
d
e
h
i
m
o
p
r
s
t
u
v
w
x
Enumerations
Enumerator
Related Functions
b
c
d
e
f
g
h
k
m
o
p
s
t
Files
File List
File Members
All
Functions
Variables
Macros
Utilities
tests
utilitiesTestsStatistic.h
1
// -*- C++ -*-
2
//
3
// utilitiesTestStatistic.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4
// Copyright (C) 2002-2019 The Herwig Collaboration, 2015 Marco A. Harrendorf
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_Utilities_Test_Statistic_H
10
#define HERWIG_Utilities_Test_Statistic_H
11
12
#include <boost/test/unit_test.hpp>
13
14
#include "Herwig/Utilities/Statistic.h"
15
16
/*
17
* Fixture which defines the common variables for testing Statistic class
18
*/
19
struct
FixStatistic1
{
20
FixStatistic1
() : statisticDefault(), statisticTest()
21
{BOOST_TEST_MESSAGE(
"setup fixture for utilitiesStatisticTest"
); }
22
23
~FixStatistic1
() { BOOST_TEST_MESSAGE(
"teardown fixture for utilitiesStatisticTest"
); }
24
25
Herwig::Statistic
statisticDefault;
26
Herwig::Statistic
statisticTest;
27
};
28
29
/*
30
* Start of boost unit tests for Statistic.h
31
*
32
*/
33
BOOST_FIXTURE_TEST_SUITE(utilitiesStatisticTest,
FixStatistic1
)
34
35
/*
36
* Boost unit tests
37
*
38
*/
39
BOOST_AUTO_TEST_CASE(defaultConstructor)
40
{
41
BOOST_CHECK_EQUAL(statisticDefault.numberOfPoints(),
static_cast<
unsigned
int
>
(0));
42
BOOST_CHECK_EQUAL(statisticDefault.total(), 0.);
43
BOOST_CHECK_EQUAL(statisticDefault.mean(), 0.);
44
BOOST_CHECK_EQUAL(statisticDefault.minimum(), -1e100);
45
BOOST_CHECK_EQUAL(statisticDefault.maximum(), 1e100);
46
BOOST_CHECK_EQUAL(statisticDefault.var(), 0);
47
BOOST_CHECK_EQUAL(statisticDefault.mean_var(), 0);
48
}
49
50
BOOST_AUTO_TEST_CASE(operations)
51
{
52
statisticTest += 2;
53
BOOST_CHECK_EQUAL(statisticTest.minimum(), 2);
54
BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
55
56
statisticTest += -2;
57
BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(),
static_cast<
unsigned
int
>
(2));
58
BOOST_CHECK_EQUAL(statisticTest.total(), 0.);
59
BOOST_CHECK_EQUAL(statisticTest.mean(), 0.);
60
BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
61
BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
62
BOOST_CHECK_EQUAL(statisticTest.var(), 8);
63
BOOST_CHECK_EQUAL(statisticTest.stdDev(),
sqrt
(8));
64
BOOST_CHECK_EQUAL(statisticTest.mean_var(), 4);
65
BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), 2);
66
67
statisticTest += 2;
68
BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(),
static_cast<
unsigned
int
>
(3));
69
BOOST_CHECK_EQUAL(statisticTest.total(), 2.);
70
BOOST_CHECK_EQUAL(statisticTest.mean(), 2./3.);
71
BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
72
BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
73
BOOST_CHECK_EQUAL(statisticTest.var(), 16./3.);
74
BOOST_CHECK_EQUAL(statisticTest.stdDev(),
sqrt
(16./3.));
75
BOOST_CHECK_EQUAL(statisticTest.mean_var(), 16./9.);
76
BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(),
sqrt
(16./9.));
77
78
statisticTest += 4.5;
79
BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
80
BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
81
82
statisticTest += -3.5;
83
BOOST_CHECK_EQUAL(statisticTest.minimum(), -3.5);
84
BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
85
}
86
87
BOOST_AUTO_TEST_SUITE_END()
88
89
#endif
/* HERWIG_Utilities_Test_Statistic_H */
Herwig::Statistic
The Statistic class is a simple class designed to store a variable for statistical analysis.
Definition:
Statistic.h:23
sqrt
double sqrt(int x)
FixStatistic1
Definition:
utilitiesTestsStatistic.h:19
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6