Ignore:
Timestamp:
Mar 19, 2007, 12:44:09 AM (15 years ago)
Author:
Peter
Message:

redesigned tTest fixes #212 and #156

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/tScore.h

    r779 r822  
    163163                 double* dof=0) const;
    164164
     165    /**
     166       Calcultate t-score from Averager like objects. Requirements for
     167       T1 and T2 are: double mean(), double n(), double sum_xx_centered()
     168       
     169       If \a dof is not a null pointer it is assigned to number of
     170       degrees of freedom.
     171    */
     172    template<typename T1, typename T2>
     173    double score(const T1& pos, const T2& neg, double* dof=0) const;
     174
    165175  private:
     176   
     177  };
    166178
    167     template<class T>
    168     double score(const T& pos, const T& neg, double* dof) const
    169     {
    170       double diff = pos.mean() - neg.mean();
    171       if (dof)
    172         *dof=pos.n()+neg.n()-2;
    173       double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
    174                   (pos.n()+neg.n()-2));
    175       double t=diff/sqrt(s2/pos.n()+s2/(neg.n()));
    176       if (t<0 && absolute_)
    177         return -t;
    178       return t;
    179     }
    180   };
     179  template<typename T1, typename T2>
     180  double tScore::score(const T1& pos, const T2& neg, double* dof) const
     181  {
     182    double diff = pos.mean() - neg.mean();
     183    if (dof)
     184      *dof=pos.n()+neg.n()-2;
     185    double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
     186                (pos.n()+neg.n()-2));
     187    double t=diff/sqrt(s2/pos.n()+s2/neg.n());
     188    if (t<0 && absolute_)
     189      return -t;
     190    return t;
     191  }
    181192
    182193}}} // of namespace statistics, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.