Changeset 697 for trunk/yat/regression


Ignore:
Timestamp:
Oct 25, 2006, 12:33:29 PM (15 years ago)
Author:
Peter
Message:

added features to Regression::OneDimensional? and moved thing not being class specific to base class.

Location:
trunk/yat/regression
Files:
7 edited

Legend:

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

    r682 r697  
    5555  }
    5656
    57   double Linear::prediction_error(const double x) const
    58   {
    59     return sqrt( alpha_var_+beta_var_*(x-m_x_)*(x-m_x_)+msd_ );
    60   }
    6157
    6258  double Linear::standard_error(const double x) const
  • trunk/yat/regression/Linear.h

    r682 r697  
    9292
    9393    ///
    94     /// @return expected prediction error for a new data point in @a x
    95     ///
    96     double prediction_error(const double x) const;
    97 
    98     ///
    9994    /// @return error of model value in @a x
    10095    ///
  • trunk/yat/regression/Naive.cc

    r682 r697  
    4747  }
    4848 
    49   double Naive::prediction_error(const double x) const
    50   {
    51     return sqrt(msd_*(1.0+1.0/ap_.n()));
    52   }
    5349
    5450  double Naive::standard_error(const double x) const
  • trunk/yat/regression/Naive.h

    r682 r697  
    7474    double predict(const double x) const;
    7575 
    76     ///
    77     /// The expected deviation from the line for a new data point. The
    78     /// error has two components: the variance of point and error in
    79     /// estimation of the mean.
    80     ///
    81     double prediction_error(const double x) const;
    82 
    8376    ///
    8477    /// @return standard error
  • trunk/yat/regression/OneDimensional.h

    r696 r697  
    3939  /// Abstract Base Class for One Dimensional fitting.   
    4040  ///
    41   /// @todo document
     41  /// @see OneDimensionalWeighted.
    4242  ///
    4343  class OneDimensional
     
    6767       fitting the regression model.
    6868
    69        @return data values mean squeared deviation from the model
     69       @return data values mean squared deviation from the model
    7070    */
    7171    inline double msd(void) const { return msd_; }
     
    8989       @return expected prediction error for a new data point in @a x
    9090    */
    91     virtual double prediction_error(const double x) const=0;
     91    double prediction_error(const double x) const
     92    { return sqrt(msd()+pow(standard_error(x),2)); }
    9293
    9394    ///
     
    106107    std::ostream& print(std::ostream& os,const double min,
    107108                        double max, const u_int n) const;
     109
     110    /**
     111       r-squared is defined as \f$ \frac{Var(Y|x)}{Var(Y)} \f$ or the
     112       fraction of the variance explained by the regression model.
     113    */
     114    inline double r_squared(void) const { return msd()/variance_; }
    108115
    109116    /**
     
    125132    ///
    126133    double msd_;
     134
     135    ///
     136    /// variance of y
     137    ///
     138    double variance_;
    127139  };
    128140
  • trunk/yat/regression/Polynomial.cc

    r682 r697  
    4747  }
    4848
    49   double Polynomial::prediction_error(const double x) const
    50   {
    51     utility::vector vec(power_+1,1);
    52     for (size_t i=1; i<=power_; ++i)
    53       vec(i) = vec(i-1)*x;
    54     return md_.prediction_error(vec);
    55   }
    5649
    5750  double Polynomial::standard_error(const double x) const
  • trunk/yat/regression/Polynomial.h

    r682 r697  
    7272
    7373    ///
    74     /// @return expected prediction error for a new data point in @a x
    75     ///
    76     double prediction_error(const double x) const;
    77 
    78     ///
    7974    /// @return error of model value in @a x
    8075    ///
Note: See TracChangeset for help on using the changeset viewer.