yat  0.21pre
tScore.h
1 #ifndef _theplu_yat_statistics_tscore_
2 #define _theplu_yat_statistics_tscore_
3 
4 // $Id: tScore.h 4207 2022-08-26 04:36:28Z 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  Copyright (C) 2022 Peter Johansson
11 
12  This file is part of the yat library, http://dev.thep.lu.se/yat
13 
14  The yat library is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License as
16  published by the Free Software Foundation; either version 3 of the
17  License, or (at your option) any later version.
18 
19  The yat library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with yat. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #include "Score.h"
29 
30 #include <cmath>
31 #include <gsl/gsl_cdf.h>
32 
33 namespace theplu {
34 namespace yat {
35 namespace utility {
36  class VectorBase;
37 }
38 namespace statistics {
39 
47  class tScore : public Score
48  {
49 
50  public:
54  tScore(bool absolute=true);
55 
56 
69  double score(const classifier::Target& target,
70  const utility::VectorBase& value) const;
71 
89  double score(const classifier::Target& target,
90  const utility::VectorBase& value, double* dof) const;
91 
111  double score(const classifier::Target& target,
113  double* dof=0) const;
114 
129  double score(const classifier::Target& target,
130  const classifier::DataLookupWeighted1D& value) const;
131 
145  double score(const classifier::Target& target,
146  const utility::VectorBase& value,
147  const utility::VectorBase& weight) const;
148 
168  double score(const classifier::Target& target,
169  const utility::VectorBase& value,
170  const utility::VectorBase& weight,
171  double* dof=0) const;
172 
180  template<typename T1, typename T2>
181  double score(const T1& pos, const T2& neg, double* dof=0) const;
182 
183  private:
184 
185  };
186 
187  template<typename T1, typename T2>
188  double tScore::score(const T1& pos, const T2& neg, double* dof) const
189  {
190  double diff = pos.mean() - neg.mean();
191  if (dof)
192  *dof=pos.n()+neg.n()-2;
193  double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
194  (pos.n()+neg.n()-2));
195  double t=diff/sqrt(s2/pos.n()+s2/neg.n());
196  if (t<0 && absolute_)
197  return -t;
198  return t;
199  }
200 
201 }}} // of namespace statistics, yat, and theplu
202 
203 #endif
tScore(bool absolute=true)
Default Constructor.
Class for containing sample labels.
Definition: Target.h:47
The Department of Theoretical Physics namespace as we define it.
bool absolute_
Definition: Score.h:131
double score(const classifier::Target &target, const utility::VectorBase &value) const
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
Interface Class for score classes.
Definition: Score.h:43
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:47

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14