Changeset 779 for trunk/yat/statistics/SAMScore.cc
 Timestamp:
 Mar 5, 2007, 7:58:30 PM (17 years ago)
 File:

 1 moved
Legend:
 Unmodified
 Added
 Removed

trunk/yat/statistics/SAMScore.cc
r776 r779 22 22 */ 23 23 24 #include "SAM .h"24 #include "SAMScore.h" 25 25 #include "Averager.h" 26 26 #include "AveragerWeighted.h" … … 35 35 namespace statistics { 36 36 37 SAM ::SAM(const double s0, bool b)37 SAMScore::SAMScore(const double s0, bool b) 38 38 : Score(b), s0_(s0) 39 39 { 40 40 } 41 41 42 double SAM ::score(const classifier::Target& target,43 const utility::vector& value)42 double SAMScore::score(const classifier::Target& target, 43 const utility::vector& value) const 44 44 { 45 weighted_=false;46 45 statistics::Averager positive; 47 46 statistics::Averager negative; … … 52 51 negative.add(value(i)); 53 52 } 54 if(positive.n()+negative.n()<=2) 55 return 0; 56 double diff = positive.mean()  negative.mean(); 57 double s2 = ( (1.0/positive.n()+1.0/negative.n()) * 58 (positive.sum_xx_centered()+negative.sum_xx_centered()) / 59 (positive.n()+negative.n()2) ); 60 if (diff<0 && absolute_) 61 return diff/(sqrt(s2)+s0_); 62 return diff/(sqrt(s2)+s0_); 53 return score(positive, negative); 63 54 } 64 55 65 double SAM ::score(const classifier::Target& target,66 const classifier::DataLookupWeighted1D& value)56 double SAMScore::score(const classifier::Target& target, 57 const classifier::DataLookupWeighted1D& value) const 67 58 { 68 weighted_=true;69 59 statistics::AveragerWeighted positive; 70 60 statistics::AveragerWeighted negative; … … 75 65 negative.add(value.data(i),value.weight(i)); 76 66 } 77 if(positive.n()+negative.n()<=2) 78 return 0; 79 double diff = positive.mean()  negative.mean(); 80 double s2 = ( (1.0/positive.n()+1.0/negative.n()) * 81 (positive.sum_xx_centered()+negative.sum_xx_centered()) / 82 (positive.n()+negative.n()2) ); 83 if (diff<0 && absolute_) 84 return diff/(sqrt(s2)+s0_); 85 return diff/(sqrt(s2)+s0_); 67 return score(positive, negative); 86 68 } 87 69 88 70 89 71 90 double SAM ::score(const classifier::Target& target,91 const utility::vector& value,92 const utility::vector& weight)72 double SAMScore::score(const classifier::Target& target, 73 const utility::vector& value, 74 const utility::vector& weight) const 93 75 { 94 weighted_=true;95 76 statistics::AveragerWeighted positive; 96 77 statistics::AveragerWeighted negative; … … 101 82 negative.add(value(i),weight(i)); 102 83 } 103 if(positive.n()+negative.n()<=2) 104 return 0; 105 double diff = positive.mean()  negative.mean(); 106 double s2 = ( (1.0/positive.n()+1.0/negative.n()) * 107 (positive.sum_xx_centered()+negative.sum_xx_centered()) / 108 (positive.n()+negative.n()2) ); 109 if (diff<0 && absolute_) 110 return diff/(sqrt(s2)+s0_); 111 return diff/(sqrt(s2)+s0_); 84 return score(positive, negative); 112 85 } 113 86
Note: See TracChangeset
for help on using the changeset viewer.