-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat.h
More file actions
67 lines (53 loc) · 1.82 KB
/
stat.h
File metadata and controls
67 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*****************************************************************************
S T A T . H
Contains definition of the following two classes:
- Sstat: Modified and extended from class SampleStatistic of
GNU library.
*****************************************************************************/
#ifndef _STAT_H
#define _STAT_H
#include <math.h>
//----------------------------------------------------------------------------
// CLASS Sstat
//----------------------------------------------------------------------------
class Sstat {
protected:
int n;
double x;
double x2;
double last;
double minValue;
double maxValue;
public :
Sstat();
virtual ~Sstat();
virtual void reset();
virtual void operator+=(double);
int num_samples();
double last_sample();
double sum();
double mean();
double stddev();
double var();
double min();
double max();
double confidence(int p_percentage);
double confidence(double p_value);
double confpercerr(int p_percentage);
double confpercerr(double p_value);
int isconfsatisfied(double perc=1.0, double pconf=.95);
};
inline Sstat:: Sstat() {reset();}
inline Sstat::~Sstat() {}
inline int Sstat::num_samples() {return(n);}
inline double Sstat::last_sample() {return(last);}
inline double Sstat::min() {return(minValue);}
inline double Sstat::max() {return(maxValue);}
inline double Sstat::sum() {return(x);}
inline double Sstat::confidence(int p_percentage) {
return confidence(double(p_percentage)*0.01); }
inline double Sstat::confpercerr(int p_percentage) {
return confpercerr(double(p_percentage)*0.01); }
inline int Sstat::isconfsatisfied(double perc, double pconf) {
return (confpercerr(pconf) < perc); }
#endif /* _STAT_H */