Changeset 149


Ignore:
Timestamp:
Sep 9, 2004, 3:35:13 PM (17 years ago)
Author:
Peter
Message:

modified score function

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Pearson.cc

    r139 r149  
    4242    else{
    4343      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 );
    4545      return p;
    4646    }
     
    6363    r_ = a.correlation();
    6464    weighted_=false;
     65    r_=abs(r_);
    6566    return r_;
    6667  }
     
    9596           sqrt( (x.mul_elements(w)*x)*(y.mul_elements(w)*y)) );
    9697    weighted_=true;
     98
     99    r_=abs(r_);
    97100    return r_;
    98101  }
     
    103106                        std::vector<size_t>());
    104107  {
    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   
    107110  }
    108111
  • trunk/src/Pearson.h

    r141 r149  
    1515//#include <vector>
    1616
     17
     18//Peter, should add a function to get the sign of the correlation
    1719namespace theplu {
    1820namespace cpptools { 
     
    3739   
    3840    ///
    39     /// \f$ \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i
     41    /// \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert }{\sqrt{\sum_i
    4042    /// (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}}\f$.
    41     /// @return Pearson correlation.
     43    /// @return absolute value of Pearson correlation.
    4244    ///
    4345    double score(const gslapi::vector&, const gslapi::vector&, 
     
    4547
    4648    ///
    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 }
    4850    /// {\sqrt{\sum_iw_i(x_i-\bar{x})^2\sum_iw_i(x_i-\bar{x})^2}}\f$,
    4951    /// where \f$m_x = \frac{\sum w_ix_i}{\sum w_i}\f$ and \f$m_x =
    5052    /// \frac{\sum w_ix_i}{\sum w_i}\f$. This expression is chosen to
    5153    /// 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.
    5356    ///
    5457    double score(const gslapi::vector& x, const gslapi::vector& y, 
     
    5760
    5861    ///
    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 }
    6063    /// {\sqrt{\sum_iw^x_iw^y_i(x_i-m_x)^2 ///
    6164    /// \sum_iw^x_iw^y_i(y_i-m_y)^2}}\f$, where \f$m_x = \frac{\sum
     
    6366    /// w_ix_i}{\sum w_i}\f$. This expression is chosen to get a
    6467    /// 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.
    6670    ///
    6771    double score(const gslapi::vector& x, const gslapi::vector& y, 
     
    7478    /// correlation is zero (and the data is Gaussian). Note that this
    7579    /// function can only be used together with the unweighted
    76     /// score. @return one-sided p-value
     80    /// score. @return two-sided p-value
    7781    ///
    7882    double p_value();
Note: See TracChangeset for help on using the changeset viewer.