yat  0.8.3pre
tScore.h
00001 #ifndef _theplu_yat_statistics_tscore_
00002 #define _theplu_yat_statistics_tscore_ 
00003 
00004 // $Id: tScore.h 2119 2009-12-12 23:11:43Z peter $
00005 
00006 /*
00007   Copyright (C) 2004, 2005 Peter Johansson
00008   Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
00009   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
00010 
00011   This file is part of the yat library, http://dev.thep.lu.se/yat
00012 
00013   The yat library is free software; you can redistribute it and/or
00014   modify it under the terms of the GNU General Public License as
00015   published by the Free Software Foundation; either version 3 of the
00016   License, or (at your option) any later version.
00017 
00018   The yat library is distributed in the hope that it will be useful,
00019   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00021   General Public License for more details.
00022 
00023   You should have received a copy of the GNU General Public License
00024   along with yat. If not, see <http://www.gnu.org/licenses/>.
00025 */
00026 
00027 #include "Score.h"
00028 
00029 #include <cmath>
00030 #include <gsl/gsl_cdf.h>
00031 
00032 namespace theplu {
00033 namespace yat {
00034 namespace utility {
00035   class VectorBase;
00036 }
00037 namespace statistics {  
00038 
00046   class tScore : public Score
00047   {
00048   
00049   public:
00053     tScore(bool absolute=true);
00054 
00055     
00068     double score(const classifier::Target& target, 
00069                  const utility::VectorBase& value) const; 
00070 
00088     double score(const classifier::Target& target, 
00089                  const utility::VectorBase& value, double* dof) const; 
00090 
00110     double score(const classifier::Target& target, 
00111                  const classifier::DataLookupWeighted1D& value,
00112                  double* dof=0) const; 
00113 
00128     double score(const classifier::Target& target, 
00129                  const classifier::DataLookupWeighted1D& value) const; 
00130 
00144     double score(const classifier::Target& target, 
00145                  const utility::VectorBase& value, 
00146                  const utility::VectorBase& weight) const; 
00147 
00167     double score(const classifier::Target& target, 
00168                  const utility::VectorBase& value, 
00169                  const utility::VectorBase& weight,
00170                  double* dof=0) const; 
00171 
00179     template<typename T1, typename T2> 
00180     double score(const T1& pos, const T2& neg, double* dof=0) const;
00181 
00182   private:
00183     
00184   };
00185 
00186   template<typename T1, typename T2> 
00187   double tScore::score(const T1& pos, const T2& neg, double* dof) const
00188   {
00189     double diff = pos.mean() - neg.mean();
00190     if (dof)
00191       *dof=pos.n()+neg.n()-2;
00192     double s2=( (pos.sum_xx_centered()+neg.sum_xx_centered())/
00193                 (pos.n()+neg.n()-2));
00194     double t=diff/sqrt(s2/pos.n()+s2/neg.n());
00195     if (t<0 && absolute_)
00196       return -t;
00197     return t;
00198   }
00199 
00200 }}} // of namespace statistics, yat, and theplu
00201 
00202 #endif

Generated on Thu Dec 20 2012 03:12:58 for yat by  doxygen 1.8.0-20120409