Ignore:
Timestamp:
Sep 2, 2008, 8:24:20 PM (13 years ago)
Author:
Peter
Message:

fixes #20

File:
1 edited

Legend:

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

    r1437 r1471  
    2727#include "utility.h"
    2828#include "yat/classifier/Target.h"
     29#include "yat/utility/DataWeight.h"
    2930
    3031#include <cmath>
     
    6162
    6263
    63   double WilcoxonFoldChange::score
    64   (const classifier::Target& target,
    65    const classifier::DataLookupWeighted1D& value) const
    66   {
    67     std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
    68     return 0;
    69   }
    70 
    71 
    7264  double WilcoxonFoldChange::score(const classifier::Target& target,
    7365                                   const utility::VectorBase& value,
    7466                                   const utility::VectorBase& weight) const
    7567  {
    76     std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
     68    std::vector<utility::DataWeight> distance;
     69    //Peter, should reserve the vector to avoid reallocations   
     70    for (size_t i=0; i<target.size(); i++) {
     71      if (target.binary(i)) continue;
     72      for (size_t j=0; j<target.size(); j++) {
     73        if (!target.binary(j))
     74          distance.push_back(utility::DataWeight(value(i)-value(j),
     75                                                 weight(i)*weight(j)));
     76      }
     77    }
     78    if (absolute_)
     79      return fabs(median(distance.begin(), distance.end()));
     80    return median(distance.begin(), distance.end());
     81   
     82
    7783    return 0;
    7884  }
Note: See TracChangeset for help on using the changeset viewer.