Changeset 1471 for trunk


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

fixes #20

Location:
trunk/yat/statistics
Files:
2 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  }
  • trunk/yat/statistics/WilcoxonFoldChange.h

    r1437 r1471  
    6363 
    6464    ///
    65     /// @return difference of the weighted means of the two classes
    66     ///
    67     /// @param target defining the two groups (Target.binary() )
    68     /// @param value vector of the values (with weights)
    69     ///
    70     /// @note not implemented
    71     ///
    72     double score(const classifier::Target& target,
    73                  const classifier::DataLookupWeighted1D& value) const;
    74  
     65    /// @return weighted median of all pairwise differences
    7566    ///
    76     /// @return difference of the weighted means of the two classes
     67    /// For each pair a DataWeight is created with value = value(i) -
     68    /// value(j) and weight = weight(i)*weight(j) where sample i and
     69    /// sample j come from different groups.
    7770    ///
    7871    /// @param target defining the two groups
Note: See TracChangeset for help on using the changeset viewer.