Jpp
18.6.0-rc.1
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JMath
JQuantile_t.hh
Go to the documentation of this file.
1
#ifndef __JMATH__JQUANTILE_T__
2
#define __JMATH__JQUANTILE_T__
3
4
#include "
JLang/JException.hh
"
5
6
/**
7
* \author mdejong
8
*/
9
namespace
JMATH {}
10
namespace
JPP {
using namespace
JMATH; }
11
12
namespace
JMATH {
13
14
using
JLANG::JDivisionByZero
;
15
16
/**
17
* Auxiliary data structure for average.
18
*
19
* The determination of the average should be independent of the order of the input values.
20
*/
21
struct
JQuantile_t
{
22
/**
23
* Default constructor.
24
*/
25
JQuantile_t
()
26
{
27
reset
();
28
}
29
30
31
/**
32
* Reset.
33
*/
34
void
reset
()
35
{
36
total
= 0.0;
37
count
= 0;
38
}
39
40
41
/**
42
* Put value.
43
*
44
* \param x value
45
*/
46
void
put
(
const
double
x
)
47
{
48
total
+=
x
;
49
count
+= 1;
50
}
51
52
53
/**
54
* Get mean value.
55
*
56
* \return mean value
57
*/
58
long
double
getMean
()
const
59
{
60
if
(
count
!= 0.0)
61
return
total
/
count
;
62
else
63
THROW
(
JDivisionByZero
,
"JQuantile_t::getMean()"
);
64
}
65
66
67
/**
68
* Get mean value.
69
*
70
* \param value default value
71
* \return mean value
72
*/
73
long
double
getMean
(
const
double
value)
const
74
{
75
if
(
count
!= 0.0)
76
return
getMean
();
77
else
78
return
value;
79
}
80
81
private
:
82
long
double
total
;
83
long
long
int
count
;
84
};
85
}
86
87
#endif
JException.hh
Exceptions.
JMATH::JQuantile_t::count
long long int count
Definition:
JQuantile_t.hh:83
JMATH::JQuantile_t::getMean
long double getMean() const
Get mean value.
Definition:
JQuantile_t.hh:58
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition:
JException.hh:712
JMATH::JQuantile_t::put
void put(const double x)
Put value.
Definition:
JQuantile_t.hh:46
JMATH::JQuantile_t::JQuantile_t
JQuantile_t()
Default constructor.
Definition:
JQuantile_t.hh:25
makedeclinationtable.x
tuple x
Definition:
makedeclinationtable.py:44
JMATH::JQuantile_t::getMean
long double getMean(const double value) const
Get mean value.
Definition:
JQuantile_t.hh:73
JLANG::JDivisionByZero
Exception for division by zero.
Definition:
JException.hh:286
JMATH::JQuantile_t::total
long double total
Definition:
JQuantile_t.hh:82
JMATH::JQuantile_t
Auxiliary data structure for average.
Definition:
JQuantile_t.hh:21
JMATH::JQuantile_t::reset
void reset()
Reset.
Definition:
JQuantile_t.hh:34
Generated by
1.8.5