Changeset 623 for trunk/c++_tools/statistics/tScore.cc
- Timestamp:
- Sep 5, 2006, 4:13:12 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/c++_tools/statistics/tScore.cc
r616 r623 1 1 // $Id$ 2 2 3 // System includes 3 #include "c++_tools/statistics/tScore.h" 4 #include "c++_tools/statistics/Averager.h" 5 #include "c++_tools/statistics/AveragerWeighted.h" 6 #include "c++_tools/classifier/DataLookupWeighted1D.h" 7 #include "c++_tools/classifier/Target.h" 8 4 9 #include <cassert> 5 10 #include <cmath> 6 11 7 // Thep C++ Tools8 #include <c++_tools/statistics/tScore.h>9 #include <c++_tools/statistics/Averager.h>10 #include <c++_tools/statistics/AveragerWeighted.h>11 #include <c++_tools/classifier/Target.h>12 12 13 13 namespace theplu { … … 41 41 return t_; 42 42 } 43 44 45 double tScore::score(const classifier::Target& target, 46 const classifier::DataLookupWeighted1D& value) 47 { 48 weighted_=true; 49 50 statistics::AveragerWeighted positive; 51 statistics::AveragerWeighted negative; 52 for(size_t i=0; i<target.size(); i++){ 53 if (target.binary(i)) 54 positive.add(value.data(i),value.weight(i)); 55 else 56 negative.add(value.data(i),value.weight(i)); 57 } 58 double diff = positive.mean() - negative.mean(); 59 dof_=positive.n()+negative.n()-2; 60 double s2=(positive.sum_xx_centered()+negative.sum_xx_centered())/dof_; 61 t_=diff/sqrt(s2/positive.n()+s2/(negative.n())); 62 if (t_<0 && absolute_) 63 t_=-t_; 64 65 if(positive.sum_w()==0 || negative.sum_w()==0) 66 t_=0; 67 return t_; 68 } 69 43 70 44 71 double tScore::score(const classifier::Target& target,
Note: See TracChangeset
for help on using the changeset viewer.