source: trunk/lib/statistics/WilcoxonFoldChange.cc @ 465

Last change on this file since 465 was 465, checked in by Peter, 17 years ago

implemented score for WilcoxonFoldChange?

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