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