Changeset 1006
- Timestamp:
- Jan 24, 2008, 7:08:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/statistics/PearsonCorrelation.h
r1000 r1006 37 37 class VectorAbstract; 38 38 } 39 namespace statistics { 39 namespace statistics { 40 40 41 /// 42 /// @brief Class for calculating Pearson correlation. 43 /// 44 41 /// 42 /// @brief Class for calculating Pearson correlation. 43 /// 45 44 class PearsonCorrelation 46 { 47 public: 48 /// 49 /// @brief The default constructor. 50 /// 51 PearsonCorrelation(void); 52 53 /// 54 /// @brief The destructor. 55 /// 56 virtual ~PearsonCorrelation(void); 57 58 59 /// 60 /// \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert 61 /// }{\sqrt{\sum_i (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}} \f$. 62 /// @return Pearson correlation, if absolute=true absolute value 63 /// of Pearson is used. 45 { 46 public: 64 47 /// 48 /// @brief The default constructor. 49 /// 50 PearsonCorrelation(void); 51 52 /// 53 /// @brief The destructor. 54 /// 55 virtual ~PearsonCorrelation(void); 56 57 58 /** 59 \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert 60 }{\sqrt{\sum_i (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}} \f$. 61 @return Pearson correlation, if absolute=true absolute value 62 of Pearson is used. 63 */ 65 64 double score(const classifier::Target& target, 66 65 const utility::vector& value); 67 68 /// 69 ///\f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert }70 ///{\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}}71 ///\f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$72 ///m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is73 ///chosen to get a correlation equal to unity when \a x and \a y74 ///are equal. @return absolute value of weighted version of75 ///Pearson correlation.76 ///66 67 /** 68 \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } 69 {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} 70 \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$ 71 m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is 72 chosen to get a correlation equal to unity when \a x and \a y 73 are equal. @return absolute value of weighted version of 74 Pearson correlation. 75 */ 77 76 double score(const classifier::Target& target, 78 77 const classifier::DataLookupWeighted1D& value); 79 80 /// 81 ///\f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert }82 ///{\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}}83 ///\f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$84 ///m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is85 ///chosen to get a correlation equal to unity when \a x and \a y86 ///are equal. @return absolute value of weighted version of87 ///Pearson correlation.88 ///78 79 /** 80 \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } 81 {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} 82 \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$ 83 m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is 84 chosen to get a correlation equal to unity when \a x and \a y 85 are equal. @return absolute value of weighted version of 86 Pearson correlation. 87 */ 89 88 double score(const classifier::Target& target, 90 89 const utility::vector& value, 91 90 const utility::vector& weight); 92 93 / //94 ///The p-value is the probability of getting a correlation as95 ///large (or larger) as the observed value by random chance, when the true96 ///correlation is zero (and the data is Gaussian).97 ///98 ///@Note This function can only be used together with the99 ///unweighted score.100 ///101 ///@return one-sided p-value102 ///103 104 105 91 92 /** 93 The p-value is the probability of getting a correlation as 94 large (or larger) as the observed value by random chance, when the true 95 correlation is zero (and the data is Gaussian). 96 97 @Note This function can only be used together with the 98 unweighted score. 99 100 @return one-sided p-value 101 */ 102 double p_value_one_sided() const; 103 104 private: 106 105 double r_; 107 106 int nof_samples_; 108 109 // void centralize(utility::vector&, const utility::vector&); 107 110 108 }; 111 109 112 110 }}} // of namespace statistics, yat, and theplu 113 111
Note: See TracChangeset
for help on using the changeset viewer.