yat  0.13.2pre
tScore.h
1 #ifndef _theplu_yat_statistics_tscore_
2 #define _theplu_yat_statistics_tscore_
3 
4 // $Id: tScore.h 2119 2009-12-12 23:11:43Z peter $
5 
6 /*
7  Copyright (C) 2004, 2005 Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
9  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
10 
11  This file is part of the yat library, http://dev.thep.lu.se/yat
12 
13  The yat library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 3 of the
16  License, or (at your option) any later version.
17 
18  The yat library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with yat. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #include "Score.h"
28 
29 #include <cmath>
30 #include <gsl/gsl_cdf.h>
31 
32 namespace theplu {
33 namespace yat {
34 namespace utility {
35  class VectorBase;
36 }
37 namespace statistics {
38 
46  class tScore : public Score
47  {
48 
49  public:
53  tScore(bool absolute=true);
54 
55 
68  double score(const classifier::Target& target,
69  const utility::VectorBase& value) const;
70 
88  double score(const classifier::Target& target,
89  const utility::VectorBase& value, double* dof) const;
90 
110  double score(const classifier::Target& target,
112  double* dof=0) const;
113 
128  double score(const classifier::Target& target,
129  const classifier::DataLookupWeighted1D& value) const;
130 
144  double score(const classifier::Target& target,
145  const utility::VectorBase& value,
146  const utility::VectorBase& weight) const;
147 
167  double score(const classifier::Target& target,
168  const utility::VectorBase& value,
169  const utility::VectorBase& weight,
170  double* dof=0) const;
171 
179  template<typename T1, typename T2>
180  double score(const T1& pos, const T2& neg, double* dof=0) const;
181 
182  private:
183 
184  };
185 
186  template<typename T1, typename T2>
187  double tScore::score(const T1& pos, const T2& neg, double* dof) const
188  {
189  double diff = pos.mean() - neg.mean();
190  if (dof)
191  *dof=pos.n()+neg.n()-2;
192  double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
193  (pos.n()+neg.n()-2));
194  double t=diff/sqrt(s2/pos.n()+s2/neg.n());
195  if (t<0 && absolute_)
196  return -t;
197  return t;
198  }
199 
200 }}} // of namespace statistics, yat, and theplu
201 
202 #endif
double score(const classifier::Target &target, const utility::VectorBase &value) const
tScore(bool absolute=true)
Default Constructor.
Class for containing sample labels.
Definition: Target.h:47
bool absolute_
Definition: Score.h:130
This is the yat interface to GSL vector.
Definition: VectorBase.h:52
Interface Class for score classes.
Definition: Score.h:42
void absolute(bool absolute)
Function changing mode of Score.
Class for general weighted vector view.
Definition: DataLookupWeighted1D.h:43
Class for Fisher&#39;s t-test.
Definition: tScore.h:46

Generated on Wed Jan 4 2017 02:23:07 for yat by  doxygen 1.8.5