Changeset 149
- Timestamp:
- Sep 9, 2004, 3:35:13 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Pearson.cc
r139 r149 42 42 else{ 43 43 t = sqrt(nof_samples_ - 2)*abs(r_) /sqrt(1-r_*r_); 44 p = gsl_cdf_tdist_Q (t, nof_samples_ -2 );44 p = 2*gsl_cdf_tdist_Q (t, nof_samples_ -2 ); 45 45 return p; 46 46 } … … 63 63 r_ = a.correlation(); 64 64 weighted_=false; 65 r_=abs(r_); 65 66 return r_; 66 67 } … … 95 96 sqrt( (x.mul_elements(w)*x)*(y.mul_elements(w)*y)) ); 96 97 weighted_=true; 98 99 r_=abs(r_); 97 100 return r_; 98 101 } … … 103 106 std::vector<size_t>()); 104 107 { 105 r _= score(vec1, vec2, w1.mul_elements(w2),train_set);106 return r_;108 return = score(vec1, vec2, w1.mul_elements(w2),train_set); 109 107 110 } 108 111 -
trunk/src/Pearson.h
r141 r149 15 15 //#include <vector> 16 16 17 18 //Peter, should add a function to get the sign of the correlation 17 19 namespace theplu { 18 20 namespace cpptools { … … 37 39 38 40 /// 39 /// \f$ \frac{\ sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i41 /// \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert }{\sqrt{\sum_i 40 42 /// (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}}\f$. 41 /// @return Pearson correlation.43 /// @return absolute value of Pearson correlation. 42 44 /// 43 45 double score(const gslapi::vector&, const gslapi::vector&, … … 45 47 46 48 /// 47 /// \f$ \frac{\ sum_iw_i(x_i-\bar{x})(y_i-\bar{y})}49 /// \f$ \frac{\vert \sum_iw_i(x_i-\bar{x})(y_i-\bar{y})\vert } 48 50 /// {\sqrt{\sum_iw_i(x_i-\bar{x})^2\sum_iw_i(x_i-\bar{x})^2}}\f$, 49 51 /// where \f$m_x = \frac{\sum w_ix_i}{\sum w_i}\f$ and \f$m_x = 50 52 /// \frac{\sum w_ix_i}{\sum w_i}\f$. This expression is chosen to 51 53 /// get a correlation equal to unity when \a x and \a y are 52 /// equal. @return Weighted version of Pearson correlation. 54 /// equal. @return absolute value of weighted version of Pearson 55 /// correlation. 53 56 /// 54 57 double score(const gslapi::vector& x, const gslapi::vector& y, … … 57 60 58 61 /// 59 /// \f$ \frac{\ sum_iw^x_iw^y_i(x_i-m_x)(y_i-m_y)}62 /// \f$ \frac{\vert \sum_iw^x_iw^y_i(x_i-m_x)(y_i-m_y)\vert } 60 63 /// {\sqrt{\sum_iw^x_iw^y_i(x_i-m_x)^2 /// 61 64 /// \sum_iw^x_iw^y_i(y_i-m_y)^2}}\f$, where \f$m_x = \frac{\sum … … 63 66 /// w_ix_i}{\sum w_i}\f$. This expression is chosen to get a 64 67 /// correlation equal to unity when \a x and \a y are 65 /// equal. @return Weighted version of Pearson correlation. 68 /// equal. @return absolute value of weighted version of Pearson 69 /// correlation. 66 70 /// 67 71 double score(const gslapi::vector& x, const gslapi::vector& y, … … 74 78 /// correlation is zero (and the data is Gaussian). Note that this 75 79 /// function can only be used together with the unweighted 76 /// score. @return one-sided p-value80 /// score. @return two-sided p-value 77 81 /// 78 82 double p_value();
Note: See TracChangeset
for help on using the changeset viewer.