source: trunk/c++_tools/statistics/tScore.h @ 597

Last change on this file since 597 was 597, checked in by Markus Ringnér, 15 years ago

Fixed comments so they pass without some of the complaits from doxygen. Have not looked at the actual contents of comments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1// $Id: tScore.h 597 2006-08-28 13:03:54Z markus $
2
3#ifndef _theplu_statistics_t_score_
4#define _theplu_statistics_t_score_
5
6// C++ tools include
7/////////////////////
8#include <c++_tools/statistics/Score.h>
9#include <c++_tools/gslapi/vector.h>
10
11#include <gsl/gsl_cdf.h>
12
13
14namespace theplu {
15namespace statistics { 
16
17  ///
18  /// Class for Fisher's t-test.
19  ///   
20  /// See <a href="http://en.wikipedia.org/wiki/Student's_t-test">
21  /// http://en.wikipedia.org/wiki/Student's_t-test</a> for more
22  /// details on the t-test.
23  ///
24  class tScore : public Score
25  {
26 
27  public:
28    ///
29    /// Default Constructor.
30    ///
31    tScore(bool absolute=true);
32
33    ///
34    /// Calculates the value of t-score, i.e. the ratio between
35    /// difference in mean and standard deviation of this
36    /// difference. \f$ t = \frac{ m_x - m_y }
37    /// {\frac{s^2}{n_x}+\frac{s^2}{n_y}} \f$ where \f$ m \f$ is the
38    /// mean, \f$ n \f$ is the number of data points and \f$ s^2 =
39    /// \frac{ \sum_i (x_i-m_x)^2 + \sum_i (y_i-m_y)^2 }{ n_x + n_y -
40    /// 2 } \f$
41    ///
42    /// @return t-score if absolute=true absolute value of t-score
43    /// is returned
44    ///
45    double score(const classifier::Target& target, 
46                 const gslapi::vector& value); 
47
48    ///
49    /// Calculates the weighted t-score, i.e. the ratio between
50    /// difference in mean and standard deviation of this
51    /// difference. \f$ t = \frac{ m_x - m_y }{
52    /// \frac{s2}{n_x}+\frac{s2}{n_y}} \f$ where \f$ m \f$ is the
53    /// weighted mean, n is the weighted version of number of data
54    /// points and \f$ s2 \f$ is an estimation of the variance \f$ s^2
55    /// = \frac{ \sum_i w_i(x_i-m_x)^2 + \sum_i w_i(y_i-m_y)^2 }{ n_x
56    /// + n_y - 2 } \f$. See AveragerWeighted for details.
57    ///
58    /// @return t-score if absolute=true absolute value of t-score
59    /// is returned
60    ///
61    double score(const classifier::Target& target, 
62                 const gslapi::vector& value, 
63                 const gslapi::vector& weight); 
64
65    ///
66    /// Calculates the p-value, i.e. the probability of observing a
67    /// t-score equally or larger if the null hypothesis is true. If P
68    /// is near zero, this casts doubt on this hypothesis. The null
69    /// hypothesis is that the means of the two distributions are
70    /// equal. Assumtions for this test is that the two distributions
71    /// are normal distributions with equal variance. The latter
72    /// assumtion is dropped in Welch's t-test.
73    ///
74    /// @return the one-sided p-value( if absolute=true is used
75    /// the two-sided p-value)
76    ///
77    double p_value() const;
78
79         
80         
81  private:
82    double t_;
83    double dof_;
84       
85  };
86
87}} // of namespace statistics and namespace theplu
88
89#endif
90
Note: See TracBrowser for help on using the repository browser.