00001 #ifndef ORTHPOLY_HEADER
00002 #define ORTHPOLY_HEADER
00003
00004
00005
00011
00012
00013
00014
00015 #include "Vector.hh"
00016 #include "Rectmat.hh"
00017 #include "Symmat.hh"
00018 #include "Rangedimexc.hh"
00019 #include "Statexc.hh"
00020
00021
00022
00023 namespace RazorBack {
00024
00032 class Orthpoly_
00033 {
00034
00035 public:
00036
00037 enum Weighting_ { EQUAL, RELATIVE, POISSON };
00038
00039
00040 private:
00041
00042 Vecdbl_ Xmeas, W, Ymeas;
00043 size_t Nm, Nf;
00044 Smatdbl_ Poly;
00045 Rmatdbl_ Polyval;
00046 Vecdbl_ Orthcoeff, Varorth,
00047 Param, Sdev,
00048 Dres, Norm;
00049 Smatdbl_ Correl;
00050 size_t Degree, Maxdegree;
00051 double Sres;
00052 bool Makepolycoeff;
00053
00054
00055 public:
00056
00058 Orthpoly_():
00059 Nm(0), Nf(0), Poly(1), Maxdegree(1), Sres(0.0), Makepolycoeff(true)
00060 { }
00061
00070 int data(const Vecdbl_& Xm, const Vecdbl_& Ym,
00071 const Vecdbl_& Wgt);
00072 int data(const Vecdbl_& Xm, const Vecdbl_& Ym,
00073 Weighting_ Wtype=EQUAL);
00074
00081 double poly_fit(unsigned int Deg);
00082
00089 void make_polycoeff();
00090
00095 double good_fit() const
00096 {
00097 return (100.0*(1.0-Sres*(Nm-1)/Dres[0]));
00098 }
00099
00104 double f_test() const
00105 {
00106 if (!Degree) return 0.0;
00107 else if (Dres[Degree]<1e-7) return 1e30;
00108 else return (Dres[Degree-1]-Dres[Degree])/Dres[Degree]*Nf;
00109 }
00110
00116 const Vecdbl_& param() const { return Param; }
00117
00124 const Vecdbl_& sdev() const { return Sdev; }
00125
00132 const Smatdbl_& correl() const { return Correl; }
00133
00135 double approx(double X) const;
00136
00137
00138 protected:
00139
00140 void setup_weight(const Vecdbl_& Ymeas, Weighting_ Weighting);
00141 void make_orthcoeff(unsigned int Deg);
00142 void back_orthcoeff(unsigned int Deg);
00143
00144 static
00145 int check_dim(const Vecdbl_& Xm, const Vecdbl_& Ym,
00146 const Vecdbl_& Wgt);
00147 void reset();
00148 void resize_orth(unsigned int Maxdeg);
00149 void resize_param(unsigned int Maxdeg);
00150 void make_orthpoly(size_t Deg);
00151 };
00152
00153
00154 }
00155
00156
00157
00158 #endif // ORTHPOLY_HEADER