-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstats.h
More file actions
31 lines (28 loc) · 725 Bytes
/
stats.h
File metadata and controls
31 lines (28 loc) · 725 Bytes
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
#ifndef STATS_H
#define STATS_H
#include "math.h"
#include <QTextStream>
class Stats
{
public:
Stats();
void clear();
void add(double x);
void add(Stats s);
int count() {return n;}
int mean() {return n > 0 ? sum / n : 0;}
double stDev() { return n > 1 ? sqrt(n * sum2 - sum * sum) / n : 0;}
double rms() { return sqrt(sum2 / n);}
double getMin() { return minimum;}
double getMax() { return maximum;}
double min(double a, double b) { if (a < b) return a; return b;}
double max(double a, double b) { if (a < b) return b; return a;}
void print(int x, int y);
private:
int n;
double sum;
double sum2;
double minimum;
double maximum;
};
#endif // STATS_H