00001 #ifndef rrel_orthogonal_regression_h_ 00002 #define rrel_orthogonal_regression_h_ 00003 00004 //: 00005 // \file 00006 // \author Gehua Yang 00007 // \date October 2001 00008 // Class to maintain data and optimization model for orthogonal regression problems. 00009 00010 #include <rrel/rrel_estimation_problem.h> 00011 #include <vnl/vnl_matrix.h> 00012 00013 //: Maintain data and optimization model for orthogonal regression problems. 00014 // The orthogonal regression problem is to try to solve 00015 // \f[ 00016 // X p = 0 00017 // \f] 00018 // where \f$ X \f$ is a data matrix and \f$ p \f$ is a parameter 00019 // vector, under the constraint \f$ ||p||=1 \f$. 00020 // 00021 // Each sample is a vnl_vector. Denoting the length of the vector by 00022 // m, the length of parameter vector is also m. Since there is one 00023 // more constraint \f$ ||p||=1 \f$, the degrees of freedom in the 00024 // parameters is actually m-1. 00025 00026 class rrel_orthogonal_regression : public rrel_estimation_problem { 00027 public: 00028 00029 //: Constructor from a matrix. 00030 rrel_orthogonal_regression( const vnl_matrix<double>& pts ); 00031 00032 //: Constructor from a vector of points. 00033 rrel_orthogonal_regression( const vcl_vector<vnl_vector<double> >& pts ); 00034 00035 //: Destructor. 00036 virtual ~rrel_orthogonal_regression(); 00037 00038 //: Total number of samples 00039 unsigned int num_samples( ) const; 00040 00041 //: Generate a parameter estimate from a minimal sample set. 00042 bool fit_from_minimal_set( const vcl_vector<int>& point_indices, 00043 vnl_vector<double>& params ) const; 00044 00045 //: Compute signed fit residuals relative to the parameter estimate. 00046 void compute_residuals( const vnl_vector<double>& params, 00047 vcl_vector<double>& residuals ) const; 00048 00049 //: Weighted least squares parameter estimate. 00050 bool weighted_least_squares_fit( vnl_vector<double>& params, 00051 vnl_matrix<double>& cofact, 00052 const vcl_vector<double>* weights=0 ) const; 00053 00054 public: // testing / debugging utility 00055 //: \brief Print information as a test utility. 00056 void print_points() const; 00057 00058 protected: 00059 vnl_matrix<double> vars_; 00060 }; 00061 00062 #endif