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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.