00001
00020 #ifndef LMEDSQ_H
00021 #define LMEDSQ_H
00022
00023 #include "points.h"
00024 #include "varable.h"
00025 #include "grphics.h"
00026 #include "notdll.h"
00027
00033 class LMS
00034 {
00035 public:
00036 LMS(
00037 INT32 size);
00038 ~LMS ();
00039 void clear();
00040 void add(
00041 FCOORD sample);
00042 void fit(
00043 float &m,
00044 float &c);
00045 void constrained_fit(
00046 float fixed_m,
00047 float &out_c);
00048 void fit_quadratic(
00049 float outlier_threshold,
00050 double &a,
00051 float &b,
00052 float &c);
00053 void plot(
00054 WINDOW win,
00055 COLOUR colour);
00056 float error() {
00057 return fitted ? line_error : -1;
00058 }
00059
00060 private:
00061
00062 void pick_line(
00063 float &m,
00064 float &c);
00065 void pick_quadratic(
00066 double &a,
00067 float &b,
00068 float &c);
00069 void compute_errors(
00070 float m,
00071 float c);
00072
00073 float compute_quadratic_errors(float outlier_threshold,
00074 double a,
00075 float m,
00076 float c);
00077
00078 BOOL8 fitted;
00079 INT32 samplesize;
00080 INT32 samplecount;
00081 FCOORD *samples;
00082 float *errors;
00083 double a;
00084 float m;
00085 float c;
00086 float line_error;
00087 };
00088
00095 extern INT_VAR_H (lms_line_trials, 12, "Number of linew fits to do");
00098 #endif