source: trunk/yat/statistics/WilcoxonFoldChange.cc @ 831

Last change on this file since 831 was 831, checked in by Peter, 14 years ago

Refs #185.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1// $Id: WilcoxonFoldChange.cc 831 2007-03-27 13:22:09Z peter $
2
3/*
4  Copyright (C) 2005 Peter Johansson
5  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2007 Peter Johansson
7
8  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
9
10  The yat library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 2 of the
13  License, or (at your option) any later version.
14
15  The yat library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23  02111-1307, USA.
24*/
25
26#include "WilcoxonFoldChange.h"
27#include "utility.h"
28#include "yat/classifier/Target.h"
29
30#include <cmath>
31#include <vector>
32#include <iostream>
33
34namespace theplu {
35namespace yat {
36namespace statistics {
37
38
39  WilcoxonFoldChange::WilcoxonFoldChange(bool absolute)
40    : Score(absolute)
41  {
42  }
43
44
45  double WilcoxonFoldChange::score(const classifier::Target& target, 
46                                   const utility::vector& value) const
47  {
48    std::vector<double> distance;
49    //Peter, should reserve the vector to avoid reallocations   
50    for (size_t i=0; i<target.size(); i++) {
51      if (target(i)!=1) continue;
52      for (size_t j=0; j<target.size(); j++) {
53        if (target(j)==1) continue;
54        distance.push_back(value(i)-value(j));
55      }
56    }
57    if (absolute_)
58      return fabs(median(distance));
59    return median(distance);
60  }
61
62
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
72  double WilcoxonFoldChange::score(const classifier::Target& target, 
73                                   const utility::vector& value,
74                                   const utility::vector& weight) const
75  {
76    std::cerr << " WilcoxonFoldChange::score  not implemented" << std::endl;
77    return 0;
78  }
79
80}}} // of namespace statistics, yat, and theplu
Note: See TracBrowser for help on using the repository browser.