Changeset 385


Ignore:
Timestamp:
Aug 13, 2005, 11:24:18 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Continued fixing of regression stuff.

Location:
trunk
Files:
2 added
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/TODO

    r348 r385  
    66
    77see also todo.html
     8
     9implement 'make doc+stat+publish' properly.
  • trunk/lib/statistics/Linear.cc

    r383 r385  
    44
    55#include <c++_tools/statistics/AveragerPair.h>
    6 #include <c++_tools/statistics/Regression.h>
    76#include <c++_tools/gslapi/vector.h>
    87
  • trunk/lib/statistics/Linear.h

    r383 r385  
    2727      : OneDimensional(), alpha_(0), alpha_var_(0), beta_(0), beta_var_(0),
    2828        m_x_(0), s2_(0) {}
    29 
    30     ///
    31     /// Copy Constructor. (not implemented)
    32     ///
    33     Linear(const Linear&);
    3429
    3530    ///
     
    110105
    111106  private:
     107    ///
     108    /// Copy Constructor. (not implemented)
     109    ///
     110    Linear(const Linear&);
     111
    112112    double alpha_;
    113113    double alpha_var_;
  • trunk/lib/statistics/Polynomial.cc

    r383 r385  
    1111
    1212
    13   Polynomial::Polynomial(gslapi::matrix& data, size_t power)
    14     : chisquare_(0), covariance_(gslapi::matrix(power+1,power+1)),
    15       fit_parameters_(gslapi::vector(power+1)),
    16       target_(gslapi::vector(data.rows())),
    17       X_(gslapi::matrix(data.rows(),power+1))
     13  Polynomial::~Polynomial(void)
    1814  {
    19     work_=gsl_multifit_linear_alloc(data.rows(),power+1);
    20     for (size_t i=0; i<data.rows(); ++i) {
    21       target_[i]=data(i,1);
    22       for (u_int j=0; j<=power; j++)
    23         X_(i,j)=pow(data(i,0),j);
    24     }
     15    if (work_)
     16      gsl_multifit_linear_free(work_);
    2517  }
    2618
    2719
    2820
    29   Polynomial::~Polynomial(void)
     21  void Polynomial::fit(const gslapi::vector& x, const gslapi::vector& y)
    3022  {
    31     gsl_multifit_linear_free(work_);
     23    if (work_)
     24      gsl_multifit_linear_free(work_);
     25    work_=gsl_multifit_linear_alloc(x.size(),fit_parameters_.size());
     26    X_=gslapi::matrix(x.size(),fit_parameters_.size());
     27    for (size_t i=0; i<x.size(); ++i)
     28      for (u_int j=0; j<fit_parameters_.size(); j++)
     29        X_(i,j)=pow(x(i),j);
     30    gsl_multifit_linear(X_.gsl_matrix_pointer(),y.gsl_vector_pointer(),
     31                        fit_parameters_.TEMP_gsl_vector_pointer(),
     32                        covariance_.gsl_matrix_pointer(),&chisquare_,work_);
    3233  }
    3334
  • trunk/lib/statistics/Polynomial.h

    r383 r385  
    2626    ///
    2727    ///
    28     Polynomial(gslapi::matrix&,size_t);
     28    inline Polynomial(size_t power)
     29      : OneDimensional(), chisquare_(0),
     30        covariance_(gslapi::matrix(power+1,power+1)),
     31        fit_parameters_(gslapi::vector(power+1)), work_(NULL) {}
    2932
    3033    ///
     
    3639    ///
    3740    ///
    38     int fit(void)
    39       { return gsl_multifit_linear(X_.gsl_matrix_pointer(),
    40                                    target_.TEMP_gsl_vector_pointer(),
    41                                    fit_parameters_.TEMP_gsl_vector_pointer(),
    42                                    covariance_.gsl_matrix_pointer(),
    43                                    &chisquare_,work_); }
     41    void fit(const gslapi::vector& x, const gslapi::vector& y);
    4442
    4543    ///
     
    4846    gslapi::vector fit_parameters(void) { return fit_parameters_; }
    4947
     48    inline void fit(const gslapi::vector& x, const gslapi::vector& y,
     49                    const gslapi::vector& w) { assert(0); }
     50
     51    inline void predict(const double x, double& y, double& y_err,
     52                         const double w=1) { assert(0); }
     53
     54    inline std::ostream& print(std::ostream& s) const
     55      { assert(0); return s; }
     56
     57    inline std::ostream& print_header(std::ostream& s) const
     58      { assert(0); return s; }
     59
    5060
    5161  private:
     
    5363    gslapi::matrix covariance_;
    5464    gslapi::vector fit_parameters_;
    55     gslapi::vector target_;
    5665    gsl_multifit_linear_workspace* work_;
    5766    gslapi::matrix X_;    // matrix of predictor variables in GSL language
  • trunk/test/Makefile.am

    r384 r385  
    55TESTS = alignment_test averagerpair_test consensus_inputranker_test \
    66  crossvalidation_test inputranker_test kernel_test matrix_test \
    7   nni_test pca_test regression_linear_test \
    8   regression_local_test regression_naive_test rnd_test roc_test \
     7  nni_test pca_test regression_test rnd_test roc_test \
    98  statistics_test stl_utility_test svd_test svm_test vector_test
    109
     
    2625nni_test_SOURCES = nni_test.cc
    2726pca_test_SOURCES = pca_test.cc
    28 regression_linear_test_SOURCES = regression_linear_test.cc
    29 regression_local_test_SOURCES = regression_local_test.cc
    30 regression_naive_test_SOURCES = regression_naive_test.cc
     27regression_test_SOURCES = regression_test.cc
    3128rnd_test_SOURCES = rnd_test.cc
    3229roc_test_SOURCES = roc_test.cc
Note: See TracChangeset for help on using the changeset viewer.