Changeset 532


Ignore:
Timestamp:
Mar 2, 2006, 6:44:48 PM (16 years ago)
Author:
Peter
Message:

modified implementation of Parson weighted - now in line with other weighted statistics.

Location:
trunk/lib/statistics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/statistics/SNR.h

    r529 r532  
    1616
    1717  ///
    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  ///   
    2527  class SNR : public Score
    2628  {
  • trunk/lib/statistics/Score.h

    r529 r532  
    4242    /// be used when two-tailed test is wanted.
    4343    ///
    44     /// @return statistica.
    45     ///
    46     /// @param target vector of targets (most often +1 -1)
    47     /// @param value vector of the values
    48     ///
    4944    virtual double
    5045    score(const classifier::Target& target,
     
    7469    /// is wanted.
    7570    ///
    76     /// @return statistica (weighted version)
    77     ///
    78     /// @param target is +1 or -1
    79     /// @param value vector of the values
    80     /// @param weight vector of accompanied weight to the values
    81     ///
    8271    virtual double
    8372    score(const classifier::Target& target,
     
    9180    /// calculated. Absolute mode should be used when two-tailed test
    9281    /// is wanted.
    93     ///
    94     /// @return statistica (weighted version)
    95     ///
    96     /// @param target is +1 or -1
    97     /// @param value vector of the values
    98     /// @param weight vector of accompanied weight to the values
    9982    ///
    10083    inline double
  • trunk/lib/statistics/tScore.cc

    r529 r532  
    2525    statistics::Averager positive;
    2626    statistics::Averager negative;
    27     dof_=target.size()-2;
    2827    for(size_t i=0; i<target.size(); i++){
    2928      if (target.binary(i))
     
    3332    }
    3433    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
    3737    t_=diff/sqrt(s2*(1.0/positive.n()+1.0/negative.n()));
    3838    if (t_<0 && absolute_)
     
    5757    }
    5858    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())));
    6264    if (t_<0 && absolute_)
    6365      t_=-t_;
    6466
    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)
    6768      t_=0;
    68     dof_=target.size()-2;
    69      
    7069    return t_;
    7170  }
  • trunk/lib/statistics/tScore.h

    r529 r532  
    4343    /// Weighted version of t-Score @return t-score if absolute=true
    4444    /// absolute value of t-score is returned.
    45     /// @todo Peter: This is probably
    46     /// not implemented as it should be!
     45    ///
     46    /// @todo document
    4747    ///
    4848    double score(const classifier::Target& target,
     
    6363  private:
    6464    double t_;
    65     int dof_;
     65    double dof_;
    6666       
    6767  };
Note: See TracChangeset for help on using the changeset viewer.