Changeset 742


Ignore:
Timestamp:
Jan 13, 2007, 10:14:05 PM (16 years ago)
Author:
Peter
Message:

added test that LinearWeighte? is equal to PolynomialWeighted?(1) fixes #166

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/regression_test.cc

    r741 r742  
    131131           << std::endl;
    132132    ok=false;
     133  }
     134
     135  // Comparing LinearWeighted and PolynomialWeighted(1)
     136  *error << "    comparing LinearWeighted and PolynomialWeighted(1)"
     137         << std::endl;
     138  linear_w.fit(x,y,w);
     139  regression::PolynomialWeighted polynomial_w(1);
     140  polynomial_w.fit(x,y,w);
     141  if ( fabs(linear_w.beta()-polynomial_w.fit_parameters()(1))>10e-7 ){
     142    *error << "error: beta and fit_parameters(1) not equal" << std::endl;
     143    *error << "       beta = " << linear_w.beta() << std::endl;
     144    *error << "       fit_parameters(1) = "
     145           << polynomial_w.fit_parameters()(1) << std::endl;
     146    ok = false;
     147  }
     148  if ( fabs(polynomial_w.fit_parameters()(0)-linear_w.alpha()+
     149            linear_w.beta()*1990)>0.0001){
     150    *error << "error: fit_parameters(0) = "
     151           << polynomial.fit_parameters()(0)<< std::endl;
     152    *error << "error: alpha-beta*m_x = "
     153           << linear.alpha()-linear.beta()*1990 << std::endl;
     154    ok = false;
     155  }
     156  if ( fabs(polynomial_w.s2()-linear_w.s2())>0.0001){
     157    *error << "error: chisq not same in linear and polynomial(1)"
     158           << std::endl;
     159    ok = false;
     160  }
     161  if ( fabs(polynomial_w.predict(1.0)-linear_w.predict(1.0))>0.0001){
     162    *error << "error: predict not same in linear and polynomial(1)"
     163           << std::endl;
     164    ok = false;
     165  }
     166  if ( fabs(polynomial_w.standard_error2(1985)-linear_w.standard_error2(1985))
     167       >0.0001){
     168    *error << "error: standard_error not same in linear and polynomial(1)"
     169           << "\n  polynomial: " << polynomial.standard_error2(1985)
     170           << "\n  linear: " << linear.standard_error2(1985)
     171           << std::endl;
     172    ok = false;
    133173  }
    134174
  • trunk/yat/regression/PolynomialWeighted.cc

    r741 r742  
    6767
    6868
    69   double PolynomialWeighted::s2(const double w=1.0) const
     69  double PolynomialWeighted::s2(const double w) const
    7070  {
    7171    return md_.s2(w);
  • trunk/yat/regression/PolynomialWeighted.h

    r741 r742  
    7777    /// @brief Mean Squared Error
    7878    ///
    79     double s2(const double) const;
     79    double s2(const double w=1) const;
    8080
    8181    ///
Note: See TracChangeset for help on using the changeset viewer.