1 | // $Id: WilcoxonFoldChange.cc 1275 2008-04-11 06:10:12Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2005 Peter Johansson |
---|
5 | Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson |
---|
6 | Copyright (C) 2008 Peter Johansson |
---|
7 | |
---|
8 | This file is part of the yat library, http://trac.thep.lu.se/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 | |
---|
34 | namespace theplu { |
---|
35 | namespace yat { |
---|
36 | namespace 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::VectorBase& 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.begin(), distance.end())); |
---|
59 | return median(distance.begin(), distance.end()); |
---|
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::VectorBase& value, |
---|
74 | const utility::VectorBase& weight) const |
---|
75 | { |
---|
76 | std::cerr << " WilcoxonFoldChange::score not implemented" << std::endl; |
---|
77 | return 0; |
---|
78 | } |
---|
79 | |
---|
80 | }}} // of namespace statistics, yat, and theplu |
---|