1 | // $Id: tScore.h 112 2004-07-07 10:23:44Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_cpptools_t_score_ |
---|
4 | #define _theplu_cpptools_t_score_ |
---|
5 | |
---|
6 | // C++ tools include |
---|
7 | ///////////////////// |
---|
8 | #include "Score.h" |
---|
9 | #include "vector.h" |
---|
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 Fisher's t-test. |
---|
21 | /// |
---|
22 | |
---|
23 | class tScore : public Score |
---|
24 | { |
---|
25 | |
---|
26 | public: |
---|
27 | /// |
---|
28 | /// Default Constructor. |
---|
29 | /// |
---|
30 | tScore(); |
---|
31 | |
---|
32 | /// |
---|
33 | /// Constructor taking a value vector and a target vector (+1 or -1). |
---|
34 | /// |
---|
35 | tScore(const gslapi::vector&, const gslapi::vector&, |
---|
36 | const std::vector<size_t>& = std::vector<size_t>()); |
---|
37 | |
---|
38 | /// |
---|
39 | /// Destructor |
---|
40 | /// |
---|
41 | virtual ~tScore(void) {}; |
---|
42 | |
---|
43 | |
---|
44 | /// |
---|
45 | /// Calculates the t-score, i.e. the ratio between difference in |
---|
46 | /// mean and standard deviation of this difference. |
---|
47 | /// @return \f$ \frac{\frac{1}{n_x}\sum x_i - \frac{1}{n_y}\sum y_i} |
---|
48 | /// {\frac{\sum x_i^2 + \sum y_i^2}{n_x-1+n_y-1}} \f$ |
---|
49 | /// |
---|
50 | double score(); |
---|
51 | |
---|
52 | /// |
---|
53 | /// Calculates the t-score, i.e. the ratio between difference in |
---|
54 | /// mean and standard deviation of this difference. |
---|
55 | /// @return \f$ \frac{\frac{1}{n_x}\sum x_i - \frac{1}{n_y}\sum y_i} |
---|
56 | /// {\frac{\sum x_i^2 + \sum y_i^2}{n_x-1+n_y-1}} \f$ |
---|
57 | /// |
---|
58 | double score(const gslapi::vector&, const gslapi::vector&, |
---|
59 | const std::vector<size_t>& = std::vector<size_t>()); |
---|
60 | |
---|
61 | /// |
---|
62 | ///Calculates the p-value, i.e. the probability of observing a t-score |
---|
63 | ///equally or larger if the null hypothesis is true. If P is near zero, |
---|
64 | ///this casts doubt on this hypothesis. The null hypothesis is ... |
---|
65 | /// @return the one-sided p-value |
---|
66 | /// |
---|
67 | double p_value(); |
---|
68 | |
---|
69 | private: |
---|
70 | gslapi::vector value_; |
---|
71 | gslapi::vector target_; |
---|
72 | std::vector<size_t> train_set_; |
---|
73 | |
---|
74 | }; |
---|
75 | |
---|
76 | }} // of namespace cpptools and namespace theplu |
---|
77 | |
---|
78 | #endif |
---|
79 | |
---|