Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Orthpoly.hh

Go to the documentation of this file.
00001 #ifndef ORTHPOLY_HEADER
00002 #define ORTHPOLY_HEADER
00003 
00004 // ==== HEADER Orthpoly.hh ====
00005 
00011 // 19-Sep-2001, Andras Aszodi
00012 
00013 // ---- MODULE HEADERS ----
00014 
00015 #include "Vector.hh"    // vector class
00016 #include "Rectmat.hh"   // general MxN matrix class
00017 #include "Symmat.hh"    // symmetric matrix class
00018 #include "Rangedimexc.hh"
00019 #include "Statexc.hh"
00020 
00021 // ==== CLASSES ====
00022 
00023 namespace RazorBack {
00024 
00032 class Orthpoly_
00033 {
00034     // symbolic consts
00035     public:
00036             
00037     enum Weighting_ { EQUAL, RELATIVE, POISSON };
00038     
00039     // data
00040     private:
00041             
00042     Vecdbl_ Xmeas, W, Ymeas;   // indep. data points, weights, dep. vars
00043     size_t Nm, Nf;          // no. of data points, degrees of freedom
00044     Smatdbl_ Poly;   // [i][j]: j-th coeff of i-th orthogonal polynomial
00045     Rmatdbl_ Polyval;   // [i][j]: value of [i]-th orthpoly at Xmeas[j]
00046     Vecdbl_ Orthcoeff, Varorth, // fitted orthogonal polynomial coeffs & vars
00047             Param, Sdev, // "usual" polynomial coeffs & variances
00048             Dres, Norm;         // weighted residuals, squared polynomial norms
00049     Smatdbl_ Correl;    // Polycoeff's correlation matrix
00050     size_t Degree, Maxdegree;   // degree of approximation (maximal so far)
00051     double Sres;    // residual deviation
00052     bool Makepolycoeff;     // true if Polycoeff is to be remade
00053     
00054     // methods
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     // hidden methods
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 // END OF CLASS Orthpoly_
00153 
00154 } // RazorBack
00155 
00156 // ==== END OF HEADER Orthpoly.hh ====
00157 
00158 #endif          // ORTHPOLY_HEADER

Generated at Wed Aug 21 09:33:12 2002 for The Razorback C++ Library: Statistics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001