Ignore:
Timestamp:
Mar 5, 2007, 7:58:30 PM (15 years ago)
Author:
Peter
Message:

Refs #101

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/SAMScore.cc

    r776 r779  
    2222*/
    2323
    24 #include "SAM.h"
     24#include "SAMScore.h"
    2525#include "Averager.h"
    2626#include "AveragerWeighted.h"
     
    3535namespace statistics { 
    3636
    37   SAM::SAM(const double s0, bool b)
     37  SAMScore::SAMScore(const double s0, bool b)
    3838    : Score(b), s0_(s0)
    3939  {
    4040  }
    4141
    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
    4444  {
    45     weighted_=false;
    4645    statistics::Averager positive;
    4746    statistics::Averager negative;
     
    5251        negative.add(value(i));
    5352    }
    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);
    6354  }
    6455
    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
    6758  {
    68     weighted_=true;
    6959    statistics::AveragerWeighted positive;
    7060    statistics::AveragerWeighted negative;
     
    7565        negative.add(value.data(i),value.weight(i));
    7666    }
    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);
    8668  }
    8769
    8870
    8971
    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
    9375  {
    94     weighted_=true;
    9576    statistics::AveragerWeighted positive;
    9677    statistics::AveragerWeighted negative;
     
    10182        negative.add(value(i),weight(i));
    10283    }
    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);
    11285  }
    11386
Note: See TracChangeset for help on using the changeset viewer.