latest version v1.9 - last update 10 Apr 2010 |
The Student t-test compares the means of two normally distributed samples of sizes n1 and n2, assuming that their unknown variances are equal. More...
#include <ltiStudentDistribution.h>
Classes | |
class | parameters |
The parameters for the class studentDistribution. More... | |
Public Member Functions | |
studentDistribution () | |
studentDistribution (const parameters &par) | |
studentDistribution (const studentDistribution &other) | |
virtual | ~studentDistribution () |
virtual const char * | getTypeName () const |
bool | apply (const int n, const float &tValue, float &confidence) const |
float | bound (const int n) const |
bool | accept (const int n, const float &tValue) |
bool | acceptLUT (const int n, const float &tValue) |
bool | acceptCompute (const int n, const float &tValue) const |
studentDistribution & | copy (const studentDistribution &other) |
studentDistribution & | operator= (const studentDistribution &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
bool | generateLUT () |
Protected Member Functions | |
float | computeBound (const int n, const float &alpha) const |
float | distribution (const int n, const float &tValue) const |
Protected Attributes | |
float | alpha_ |
std::vector< float > | lut_ |
The Student t-test compares the means of two normally distributed samples of sizes n1 and n2, assuming that their unknown variances are equal.
If the test value is bigger than T(k,alpha), k=n1+n2-2, then the equality hypothesis is rejected at significance level alpha.
This class only computes T(k,alpha). Computing the test value is left to the application. For efficiency, e.g. if testing many times in a row with varying degrees of freedom the values T(k,alpha) may be precomputed for a constant significance level alpha and stored in a LUT.
lti::studentDistribution::studentDistribution | ( | ) |
Default constructor.
lti::studentDistribution::studentDistribution | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::studentDistribution::studentDistribution | ( | const studentDistribution & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::studentDistribution::~studentDistribution | ( | ) | [virtual] |
Destructor.
bool lti::studentDistribution::accept | ( | const int | n, | |
const float & | tValue | |||
) |
Tests if the hypothesis of equal means is accepted at the significance level given in the parameters.
Depending on the parameter settings this method uses the LUT or computes the result. If the LUT is requested but not initialized properly, it is done here.
n | degrees of freedom of the student distribution | |
tValue | t-value computed by your application |
bool lti::studentDistribution::acceptCompute | ( | const int | n, | |
const float & | tValue | |||
) | const |
Tests if the hypothesis of equal means is accepted at the significance level given in the parameters.
The significance for your t-value is computed and compared with the significance level supplied in the parameters.
n | degrees of freedom of the student distribution | |
tValue | t-value computed by your application |
bool lti::studentDistribution::acceptLUT | ( | const int | n, | |
const float & | tValue | |||
) | [inline] |
Tests if the hypothesis of equal means is accepted at the significance level given in the parameters.
The appropriate bound of Student's t-distribution is taken from a pre-computed LUT.
CAUTION: This method does not check if the LUT is initialized, nor does it check that the LUT has been computed for the current significance level. To initialize it please call generateLUT().
n | degrees of freedom of the student distribution | |
tValue | t-value computed by your application |
References _lti_debug, lut_, and lti::status::setStatusString().
bool lti::studentDistribution::apply | ( | const int | n, | |
const float & | tValue, | |||
float & | confidence | |||
) | const |
Computes Student's distribution probability function for a given degree of freedom and t-value, which code the similarity of the two sample means.
n | degrees of freedom of the student distribution | |
tValue | t-value computed by your aplication | |
confidence | the result, i.e. the probability that the two sample means are similar |
float lti::studentDistribution::bound | ( | const int | n | ) | const |
Compute the lowest t-value, for which the hypothesis is rejected.
n | degrees of freedom of the student distribution |
virtual functor* lti::studentDistribution::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::mathFunction.
float lti::studentDistribution::computeBound | ( | const int | n, | |
const float & | alpha | |||
) | const [protected] |
Compute the lowest t-value, for which the hypothesis is rejected.
n | degrees of freedom of the student distribution | |
alpha | confidence value |
studentDistribution& lti::studentDistribution::copy | ( | const studentDistribution & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::mathFunction.
float lti::studentDistribution::distribution | ( | const int | n, | |
const float & | tValue | |||
) | const [protected] |
Compute the Student distribution probability function for a given n (degrees of freedom) and t-value.
n | degrees of freedom of the student distribution | |
tValue | t-value computed by your application |
bool lti::studentDistribution::generateLUT | ( | ) |
Generates the LUT.
const parameters& lti::studentDistribution::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::mathFunction.
virtual const char* lti::studentDistribution::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("studentDistribution").
Reimplemented from lti::mathFunction.
studentDistribution& lti::studentDistribution::operator= | ( | const studentDistribution & | other | ) |
Alias for copy member.
other | the functor to be copied |
Reimplemented from lti::mathFunction.
float lti::studentDistribution::alpha_ [protected] |
Remember the significance level for which the LUT has been computed.
Normed to one-sided.
std::vector<float> lti::studentDistribution::lut_ [protected] |
The LUT.
Due to computational expensive of the used algorithm double does not make any sense here.
Referenced by acceptLUT().