00001 #ifndef _theplu_yat_statistics_tscore_
00002 #define _theplu_yat_statistics_tscore_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "Score.h"
00028
00029 #include <cmath>
00030 #include <gsl/gsl_cdf.h>
00031
00032 namespace theplu {
00033 namespace yat {
00034 namespace utility {
00035 class VectorBase;
00036 }
00037 namespace statistics {
00038
00046 class tScore : public Score
00047 {
00048
00049 public:
00053 tScore(bool absolute=true);
00054
00055
00068 double score(const classifier::Target& target,
00069 const utility::VectorBase& value) const;
00070
00088 double score(const classifier::Target& target,
00089 const utility::VectorBase& value, double* dof) const;
00090
00110 double score(const classifier::Target& target,
00111 const classifier::DataLookupWeighted1D& value,
00112 double* dof=0) const;
00113
00128 double score(const classifier::Target& target,
00129 const classifier::DataLookupWeighted1D& value) const;
00130
00144 double score(const classifier::Target& target,
00145 const utility::VectorBase& value,
00146 const utility::VectorBase& weight) const;
00147
00167 double score(const classifier::Target& target,
00168 const utility::VectorBase& value,
00169 const utility::VectorBase& weight,
00170 double* dof=0) const;
00171
00179 template<typename T1, typename T2>
00180 double score(const T1& pos, const T2& neg, double* dof=0) const;
00181
00182 private:
00183
00184 };
00185
00186 template<typename T1, typename T2>
00187 double tScore::score(const T1& pos, const T2& neg, double* dof) const
00188 {
00189 double diff = pos.mean() - neg.mean();
00190 if (dof)
00191 *dof=pos.n()+neg.n()-2;
00192 double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
00193 (pos.n()+neg.n()-2));
00194 double t=diff/sqrt(s2/pos.n()+s2/neg.n());
00195 if (t<0 && absolute_)
00196 return -t;
00197 return t;
00198 }
00199
00200 }}}
00201
00202 #endif