1 | // $Id: ROC.h 77 2004-05-04 10:05:34Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_cpptools_roc_ |
---|
4 | #define _theplu_cpptools_roc_ |
---|
5 | |
---|
6 | // C++ tools include |
---|
7 | ///////////////////// |
---|
8 | #include "vector.h" |
---|
9 | |
---|
10 | #include <gsl/gsl_cdf.h> |
---|
11 | |
---|
12 | // Standard C++ includes |
---|
13 | //////////////////////// |
---|
14 | #include <utility> |
---|
15 | #include <vector> |
---|
16 | |
---|
17 | namespace theplu { |
---|
18 | namespace cpptools { |
---|
19 | /// |
---|
20 | /// Class for ROC (Reciever Operating Characteristic). |
---|
21 | /// |
---|
22 | class ROC |
---|
23 | { |
---|
24 | |
---|
25 | public: |
---|
26 | /// |
---|
27 | /// Constructor taking a value vector and a target vector (+1 or -1). |
---|
28 | /// |
---|
29 | ROC(const gslapi::vector&, const gslapi::vector&); |
---|
30 | |
---|
31 | /// Equivalent to the Mann-Whitney score, but normalized to be |
---|
32 | /// between zero and one. @return the area under the ROC curve |
---|
33 | /// |
---|
34 | double ROC::area(void); |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | /// |
---|
39 | ///Calculates the p-value, i.e. the probability of observing an area |
---|
40 | ///equally or larger if the null hypothesis is true. If P is near zero, |
---|
41 | ///this casts doubt on this hypothesis. The null hypothesis is that the |
---|
42 | ///values from the 2 classes are generated from 2 identical |
---|
43 | ///distributions. The alternative is that the median of the first |
---|
44 | ///distribution is shifted from the median of the second distribution by a |
---|
45 | ///non-zero amount. If the smallest group size is larger than minimum_size |
---|
46 | ///(default = 10), then P is calculated using a normal approximation. |
---|
47 | /// @return the one-sided p-value |
---|
48 | /// |
---|
49 | double ROC::get_p(const double); |
---|
50 | |
---|
51 | /// |
---|
52 | /// Changes minimum_size , i.e. the threshold when a normal |
---|
53 | /// approximation is used for the p-value calculation. |
---|
54 | /// |
---|
55 | inline void minimum_size(const u_int minimum_size) {minimum_size_ = minimum_size; } |
---|
56 | |
---|
57 | private: |
---|
58 | std::vector<std::pair<int, double> > value_; |
---|
59 | double nof_pos_; |
---|
60 | u_int minimum_size_; |
---|
61 | /// |
---|
62 | /// |
---|
63 | /// Implemented as in MatLab 12.1 |
---|
64 | /// @return the p-value |
---|
65 | /// |
---|
66 | double ROC::get_p_approx(const double); |
---|
67 | |
---|
68 | /// |
---|
69 | /// @return the p-value |
---|
70 | /// |
---|
71 | double ROC::get_p_exact(const double, const double, |
---|
72 | const double); |
---|
73 | |
---|
74 | }; |
---|
75 | |
---|
76 | }} // of namespace cpptools and namespace theplu |
---|
77 | |
---|
78 | #endif |
---|
79 | |
---|