Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef LINEARREGRESSION_H
00027 #define LINEARREGRESSION_H
00028
00029 #include <vector>
00030
00031 #include "GpCoreToolsDLLExport.h"
00032
00033 namespace GpCoreTools {
00034
00035 class GPCORETOOLS_EXPORT LinearRegression
00036 {
00037 public:
00038 LinearRegression() {reset();}
00039
00040 void add(double x, double y);
00041 void reset();
00042
00043 bool calculate();
00044 float stddev() const;
00045 int badValue(double deviation) const;
00046 void remove(int i);
00047
00048
00049 unsigned int count() const {return _values.size();}
00050 double a() const {return _a;}
00051 double b() const {return _b;}
00052 double at(double x) const {return _a*(x-_x0)+_b;}
00053 private:
00054 double _sumX, _sumY, _sumXY, _sumX2, _x0;
00055 double _a, _b;
00056 std::vector<std::pair<double, double> > _values;
00057 };
00058
00059 }
00060
00061 #endif // LINEARREGRESSION_H