source: trunk/c++_tools/statistics/WilcoxonFoldChange.cc @ 623

Last change on this file since 623 was 623, checked in by Peter, 15 years ago

fixes #112 and refs #123 added overloaded function score taking Target and DataLookupWeighted1D, which is needed for InputRanker?.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1// $Id: WilcoxonFoldChange.cc 623 2006-09-05 02:13:12Z peter $
2
3#include <c++_tools/statistics/WilcoxonFoldChange.h>
4#include <c++_tools/statistics/utility.h>
5#include <c++_tools/classifier/Target.h>
6
7#include <cmath>
8#include <vector>
9#include <iostream>
10
11namespace theplu {
12namespace statistics {
13
14
15  WilcoxonFoldChange::WilcoxonFoldChange(bool absolute)
16    : Score(absolute)
17  {
18  }
19
20
21
22  double WilcoxonFoldChange::score(const classifier::Target& target, 
23                                   const utility::vector& value)
24  {
25    std::vector<double> distance;
26    //Peter, should reserve the vector to avoid reallocations   
27    weighted_=false;
28    for (size_t i=0; i<target.size(); i++) {
29      if (target(i)!=1) continue;
30      for (size_t j=0; j<target.size(); j++) {
31        if (target(j)==1) continue;
32        distance.push_back(value(i)-value(j));
33      }
34    }
35    if (absolute_)
36      return fabs(median(distance));
37    return median(distance);
38  }
39
40
41  double WilcoxonFoldChange::score(const classifier::Target& target, 
42                                   const classifier::DataLookupWeighted1D& value)
43  {
44    std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
45    return 0;
46  }
47
48
49  double WilcoxonFoldChange::score(const classifier::Target& target, 
50                                   const utility::vector& value,
51                                   const utility::vector& weight)
52  {
53    std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
54    return 0;
55  }
56
57} // of namespace statistics
58} // of namespace theplu
Note: See TracBrowser for help on using the repository browser.