Changeset 532
- Timestamp:
- Mar 2, 2006, 6:44:48 PM (17 years ago)
- Location:
- trunk/lib/statistics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/statistics/SNR.h
r529 r532 16 16 17 17 /// 18 /// Class for score based on signal-to-noise ratio (SNR). Also 19 /// sometimes referred to as Golub score. The score is the ratio 20 /// between difference in mean and the sum of standard deviations 21 /// for two groups. \f$ \frac{ \frac{1}{n_x}\sum x_i - 22 /// \frac{1}{n_y}\sum y_i }{ \sigma_x + \sigma_y} \f$ where \f$ 23 /// \sigma \f$ is standard deviation. 24 /// 18 /// @brief Class for score based on signal-to-noise ratio (SNR). 19 /// 20 /// Also 21 /// sometimes referred to as Golub score. The score is the ratio 22 /// between difference in mean and the sum of standard deviations 23 /// for two groups. \f$ \frac{ \frac{1}{n_x}\sum x_i - 24 /// \frac{1}{n_y}\sum y_i }{ \sigma_x + \sigma_y} \f$ where \f$ 25 /// \sigma \f$ is standard deviation. 26 /// 25 27 class SNR : public Score 26 28 { -
trunk/lib/statistics/Score.h
r529 r532 42 42 /// be used when two-tailed test is wanted. 43 43 /// 44 /// @return statistica.45 ///46 /// @param target vector of targets (most often +1 -1)47 /// @param value vector of the values48 ///49 44 virtual double 50 45 score(const classifier::Target& target, … … 74 69 /// is wanted. 75 70 /// 76 /// @return statistica (weighted version)77 ///78 /// @param target is +1 or -179 /// @param value vector of the values80 /// @param weight vector of accompanied weight to the values81 ///82 71 virtual double 83 72 score(const classifier::Target& target, … … 91 80 /// calculated. Absolute mode should be used when two-tailed test 92 81 /// is wanted. 93 ///94 /// @return statistica (weighted version)95 ///96 /// @param target is +1 or -197 /// @param value vector of the values98 /// @param weight vector of accompanied weight to the values99 82 /// 100 83 inline double -
trunk/lib/statistics/tScore.cc
r529 r532 25 25 statistics::Averager positive; 26 26 statistics::Averager negative; 27 dof_=target.size()-2;28 27 for(size_t i=0; i<target.size(); i++){ 29 28 if (target.binary(i)) … … 33 32 } 34 33 double diff = positive.mean() - negative.mean(); 35 double s2=(positive.sum_xx_centered()+negative.sum_xx_centered())/ 36 (positive.n()+negative.n()-2); 34 dof_=positive.n()+negative.n()-2; 35 double s2=(positive.sum_xx_centered()+negative.sum_xx_centered())/dof_; 36 37 37 t_=diff/sqrt(s2*(1.0/positive.n()+1.0/negative.n())); 38 38 if (t_<0 && absolute_) … … 57 57 } 58 58 double diff = positive.mean() - negative.mean(); 59 double s2=(positive.sum_xx_centered()+negative.sum_xx_centered())/ 60 (positive.n()+negative.n()-2); 61 t_=diff/sqrt(s2*(1.0/positive.sum_w()+1.0/negative.sum_w())); 59 dof_=positive.sum_w()*positive.sum_w()/positive.sum_ww() + 60 negative.sum_w()*negative.sum_w()/negative.sum_ww(); 61 double s2=(positive.sum_xx_centered()+negative.sum_xx_centered())/dof_; 62 t_=diff/sqrt(s2*(1.0/(positive.sum_w()*positive.sum_w()/positive.sum_ww())+ 63 1.0/(negative.sum_w()*negative.sum_w()/negative.sum_ww()))); 62 64 if (t_<0 && absolute_) 63 65 t_=-t_; 64 66 65 if(positive.n()==0 || negative.n()==0 || 66 positive.sum_w()==0 || positive.sum_w()==0) 67 if(positive.sum_w()==0 || negative.sum_w()==0) 67 68 t_=0; 68 dof_=target.size()-2;69 70 69 return t_; 71 70 } -
trunk/lib/statistics/tScore.h
r529 r532 43 43 /// Weighted version of t-Score @return t-score if absolute=true 44 44 /// absolute value of t-score is returned. 45 /// @todo Peter: This is probably46 /// not implemented as it should be!45 /// 46 /// @todo document 47 47 /// 48 48 double score(const classifier::Target& target, … … 63 63 private: 64 64 double t_; 65 intdof_;65 double dof_; 66 66 67 67 };
Note: See TracChangeset
for help on using the changeset viewer.