00001 #ifndef PARAMEST_HEADER
00002 #define PARAMEST_HEADER
00003
00004
00005
00011
00012
00013
00014
00015 #include <stdlib.h>
00016 #include <float.h>
00017 #include <math.h>
00018
00019 #ifdef _STANDARD_C_PLUS_PLUS
00020 #include <iostream>
00021 #include <iomanip>
00022 using namespace std;
00023 #else
00024 #include <iostream.h>
00025 #include <iomanip.h>
00026 #endif
00027
00028
00029
00030 #include "Vector.hh"
00031 #include "Rectmat.hh"
00032 #include "Symmat.hh"
00033
00034
00035
00036 namespace RazorBack {
00037
00039 class Paramest_
00040 {
00041
00042 public:
00043
00045 typedef enum {EQUAL, RELATIVE, USER} Weighting_;
00046
00047
00048 protected:
00049
00050 size_t Nm, Np, Nf;
00051 Smatdbl_ Xtx;
00052 Vecdbl_ Xty;
00053 Vecdbl_ Norm;
00054 Weighting_ Weighting;
00055 Vecdbl_ P, Sdev;
00056 Smatdbl_ Correl;
00057
00058
00059 public:
00060
00062 Paramest_():
00063 Nm(0), Np(0), Nf(0), Weighting(EQUAL) {}
00064
00069 Paramest_(size_t NM, size_t NP):
00070 Nm(NM), Np(NP), Weighting(EQUAL)
00071 { resize(); }
00072
00074 void weight(Weighting_ W) { Weighting=W; }
00075
00077 const Vecdbl_& param() const { return P; }
00078
00080 const Vecdbl_& sdev() const { return Sdev; }
00081
00083 const Smatdbl_& correl() const { return Correl; }
00084
00090 float tcrit_95() const;
00091
00092
00093 protected:
00094
00095 void resize()
00096 {
00097 Xtx.size(Np); Xty.dim(Np); Norm.dim(Np);
00098 P.dim(Np); Sdev.dim(Np); Correl.size(Np);
00099 }
00100 double normalise();
00101 double solve(Vecdbl_& Sol, double Lambda0, double Lambdafact);
00102 static bool posdef_inv(Smatdbl_& A);
00103 void sdev_correl(double Q);
00104 };
00105
00106
00107 }
00108
00109
00110
00111 #endif // PARAMEST_HEADER