Changeset 741 for trunk/yat/regression


Ignore:
Timestamp:
Jan 13, 2007, 3:41:40 PM (15 years ago)
Author:
Peter
Message:

fixes #161 and #164

Location:
trunk/yat/regression
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/regression/MultiDimensionalWeighted.cc

    r740 r741  
    4343      gsl_multifit_linear_free(work_);
    4444  }
     45
     46
     47  double MultiDimensionalWeighted::chisq() const
     48  {
     49    return chisquare_;
     50  }
     51
    4552
    4653  void MultiDimensionalWeighted::fit(const utility::matrix& x,
  • trunk/yat/regression/MultiDimensionalWeighted.h

    r740 r741  
    5252
    5353    ///
     54    /// @return sum of squared residuals
     55    ///
     56    double chisq(void) const;
     57
     58    ///
    5459    /// @see gsl_multifit_wlinear
    5560    ///
  • trunk/yat/regression/Polynomial.cc

    r729 r741  
    4949  void Polynomial::fit(const utility::vector& x, const utility::vector& y)
    5050  {
     51    ap_.add_values(x,y);
    5152    utility::matrix X=utility::matrix(x.size(),power_+1,1);
    5253    for (size_t i=0; i<X.rows(); ++i)
  • trunk/yat/regression/PolynomialWeighted.cc

    r740 r741  
    4747    assert(x.size()==y.size());
    4848    assert(y.size()==w.size());
     49    ap_.reset();
     50    // AveragerPairWeighted requires 2 weights but works only on the
     51    // product wx*wy, so we can send in w and a dummie to get what we
     52    // want.
     53    ap_.add_values(x,y,utility::vector(x.size(),1),w);
    4954    utility::matrix X=utility::matrix(x.size(),power_+1,1);
    5055    for (size_t i=0; i<X.rows(); ++i)
     
    5257        X(i,j)=X(i,j-1)*x(i);
    5358    md_.fit(X,y,w);
     59    chisq_=md_.chisq();
    5460  }
    5561
     
    7480  }
    7581
    76   double PolynomialWeighted::prediction_error2(const double x,
    77                                                const double w) const
    78   {
    79     utility::vector vec(power_+1,1);
    80     for (size_t i=1; i<=power_; ++i)
    81       vec(i) = vec(i-1)*x;
    82     return md_.prediction_error2(vec, w);
    83   }
    84 
    8582  double PolynomialWeighted::standard_error2(const double x) const
    8683  {
  • trunk/yat/regression/PolynomialWeighted.h

    r740 r741  
    8585
    8686    ///
    87     /// @return expected prediction error for a new data point in @a x
    88     /// with weight @a w
    89     ///
    90     double prediction_error2(const double x, const double w=1) const;
    91 
    92     ///
    9387    /// @return error of model value in @a x
    9488    ///
Note: See TracChangeset for help on using the changeset viewer.