yat  0.14.5pre
Public Member Functions | Protected Attributes | List of all members
theplu::yat::statistics::tScore Class Reference

Class for Fisher's t-test. More...

#include <yat/statistics/tScore.h>

Inheritance diagram for theplu::yat::statistics::tScore:
theplu::yat::statistics::Score

Public Member Functions

 tScore (bool absolute=true)
 Default Constructor.
 
double score (const classifier::Target &target, const utility::VectorBase &value) const
 
double score (const classifier::Target &target, const utility::VectorBase &value, double *dof) const
 
double score (const classifier::Target &target, const classifier::DataLookupWeighted1D &value, double *dof=0) const
 
double score (const classifier::Target &target, const classifier::DataLookupWeighted1D &value) const
 
double score (const classifier::Target &target, const utility::VectorBase &value, const utility::VectorBase &weight) const
 
double score (const classifier::Target &target, const utility::VectorBase &value, const utility::VectorBase &weight, double *dof=0) const
 
template<typename T1 , typename T2 >
double score (const T1 &pos, const T2 &neg, double *dof=0) const
 
void absolute (bool absolute)
 Function changing mode of Score.
 
virtual double score (const classifier::Target &target, const classifier::DataLookup1D &value) const
 
double score (const classifier::Target &target, const classifier::DataLookup1D &value, const classifier::DataLookup1D &weight) const
 

Protected Attributes

bool absolute_
 

Detailed Description

Class for Fisher's t-test.

See http://en.wikipedia.org/wiki/Student's_t-test for more details on the t-test.

Member Function Documentation

double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const utility::VectorBase value 
) const
virtual

Calculates the value of t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y } {s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} $ where $ m $ is the mean, $ n $ is the number of data points and $ s^2 = \frac{ \sum_i (x_i-m_x)^2 + \sum_i (y_i-m_y)^2 }{ n_x + n_y - 2 } $

Returns
t-score. If absolute=true absolute value of t-score is returned

Implements theplu::yat::statistics::Score.

virtual double theplu::yat::statistics::Score::score ( const classifier::Target target,
const classifier::DataLookup1D value 
) const
virtualinherited

Function calculating the score. In absolute mode, also the score using negated class labels is calculated, and the largest of the two scores are calculated.

value is copied to a utility::vector and that operator is called. If speed is important this operator should be implemented in inherited class to avoid copying.

Returns
score
double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const utility::VectorBase value,
double *  dof 
) const

Calculates the value of t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y } {s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} $ where $ m $ is the mean, $ n $ is the number of data points and $ s^2 = \frac{ \sum_i (x_i-m_x)^2 + \sum_i (y_i-m_y)^2 }{ n_x + n_y - 2 } $

Parameters
targetTarget defining the two groups
valueVector with data points on which calculation is based
dofdouble pointer in which approximation of degrees of freedom is returned: pos.n()+neg.n()-2. See AveragerWeighted.
Returns
t-score. If absolute=true absolute value of t-score is returned
double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const classifier::DataLookupWeighted1D value,
double *  dof = 0 
) const

Calculates the weighted t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y }{ s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} $ where $ m $ is the weighted mean, n is the weighted version of number of data points $ \frac{\left(\sum w_i\right)^2}{\sum w_i^2} $, and $ s^2 $ is an estimation of the variance $ s^2 = \frac{ \sum_i w_i(x_i-m_x)^2 + \sum_i w_i(y_i-m_y)^2 }{ n_x + n_y - 2 } $. See AveragerWeighted for details.

Parameters
targetTarget defining the two groups
valueVector with values/weights on which calculation is based
dofdouble pointer in which approximation of degrees of freedom is returned: pos.n()+neg.n()-2. See AveragerWeighted.
Returns
t-score. If absolute=true absolute value of t-score is returned
double theplu::yat::statistics::Score::score ( const classifier::Target target,
const classifier::DataLookup1D value,
const classifier::DataLookup1D weight 
) const
inherited

Function calculating the weighted version of score. In absolute mode, also the score using negated class labels is calculated, and the largest of the two scores are calculated. Absolute mode should be used when two-tailed test is wanted.

value and weight are copied to utility::vector and the corresponding operator is called. If speed is important this operator should be implemented in inherited class to avoid copying.

double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const classifier::DataLookupWeighted1D value 
) const
virtual

Calculates the weighted t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y }{ s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} $ where $ m $ is the weighted mean, n is the weighted version of number of data points $ \frac{\left(\sum w_i\right)^2}{\sum w_i^2} $, and $ s^2 $ is an estimation of the variance $ s^2 = \frac{ \sum_i w_i(x_i-m_x)^2 + \sum_i w_i(y_i-m_y)^2 }{ n_x + n_y - 2 } $. See AveragerWeighted for details.

Returns
t-score. If absolute=true absolute value of t-score is returned

Reimplemented from theplu::yat::statistics::Score.

double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const utility::VectorBase value,
const utility::VectorBase weight 
) const
virtual

Calculates the weighted t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y }{ \frac{s2}{n_x}+\frac{s2}{n_y}} $ where $ m $ is the weighted mean, n is the weighted version of number of data points and $ s2 $ is an estimation of the variance $ s^2 = \frac{ \sum_i w_i(x_i-m_x)^2 + \sum_i w_i(y_i-m_y)^2 }{ n_x + n_y - 2 } $. See AveragerWeighted for details.

Returns
t-score if absolute=true absolute value of t-score is returned

Implements theplu::yat::statistics::Score.

double theplu::yat::statistics::tScore::score ( const classifier::Target target,
const utility::VectorBase value,
const utility::VectorBase weight,
double *  dof = 0 
) const

Calculates the weighted t-score, i.e. the ratio between difference in mean and standard deviation of this difference. $ t = \frac{ m_x - m_y }{ \frac{s2}{n_x}+\frac{s2}{n_y}} $ where $ m $ is the weighted mean, n is the weighted version of number of data points and $ s2 $ is an estimation of the variance $ s^2 = \frac{ \sum_i w_i(x_i-m_x)^2 + \sum_i w_i(y_i-m_y)^2 }{ n_x + n_y - 2 } $. See AveragerWeighted for details.

Parameters
targetTarget defining the two groups
valueVector with data values on which calculation is based
weightVector with weight associated to value
dofdouble pointer in which approximation of degrees of freedom is returned: pos.n()+neg.n()-2. See AveragerWeighted.
Returns
t-score if absolute=true absolute value of t-score is returned
template<typename T1 , typename T2 >
double theplu::yat::statistics::tScore::score ( const T1 &  pos,
const T2 &  neg,
double *  dof = 0 
) const

Calcultate t-score from Averager like objects. Requirements for T1 and T2 are: double mean(), double n(), double sum_xx_centered()

If dof is not a null pointer it is assigned to number of degrees of freedom.

Member Data Documentation

bool theplu::yat::statistics::Score::absolute_
protectedinherited

true if method is absolute, which means if score is below expected value (by chance) E, score returns E-score+E instead.


The documentation for this class was generated from the following file:

Generated on Tue Sep 26 2017 02:33:30 for yat by  doxygen 1.8.5