Honeycomb  0.1
Component-Model Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
honey::StudentT_< Real > Class Template Reference

Generate a random variate from a Student's t-distribution. More...

#include <StudentT.h>

Inheritance diagram for honey::StudentT_< Real >:
Inheritance graph
[legend]
Collaboration diagram for honey::StudentT_< Real >:
Collaboration graph
[legend]

Classes

struct  PooledStats
 
struct  Stats
 

Public Types

typedef Random::DistStats DistStats
 
typedef Vec< 2, RealVec2
 

Public Member Functions

 StudentT_ (optional< RandomGen & > gen, Real n)
 
 StudentT_ (Real n)
 
virtual Real next () const
 Get next randomly distributed variate. Requires a random generator (see ctor or setGen()) More...
 
virtual Real pdf (Real x) const
 Probability Density Function. More...
 
virtual Real cdf (Real x) const
 Cumulative Distribution Function. More...
 
virtual Real cdfComp (Real x) const
 Complement of the CDF. More...
 
virtual Real cdfInv (Real P) const
 Inverse of the CDF. More...
 
virtual Real mean () const
 Calc mean. More...
 
virtual Real variance () const
 Calc variance. More...
 
- Public Member Functions inherited from honey::RandomDist< Real >
 RandomDist (optional< RandomGen & > gen=optnull)
 Construct with a random generator to use for next() More...
 
virtual ~RandomDist ()
 
Real stdDev () const
 Calc standard deviation. More...
 
void setGen (RandomGen &gen)
 Set random generator to use for next() More...
 
RandomGengetGen () const
 Get random generator. More...
 

Static Public Member Functions

template<class Range >
static bool test (const Range &samples, optional< Stats & > stats=optnull, Real mu=0, Real alpha=0.05, int tail=0)
 One-sample t-test: Test the null hypothesis that the samples are from a normally distributed population with mean mu and unknown standard deviation. More...
 
template<class Range , class Range2 >
static std::enable_if< mt::isRange< Range2 >::value, bool >::type test (const Range &samples1, const Range2 &samples2, optional< PooledStats & > stats=optnull, Real mu=0, Real alpha=0.05, int tail=0)
 Two-sample t-test: Test the null hypothesis that the difference between two sample distributions is a normally distributed population with mean mu and unknown standard deviation. More...
 

Public Attributes

Real n
 

Additional Inherited Members

- Protected Types inherited from honey::RandomDist< Real >
typedef Numeral< Real >::Real_ Real_
 
typedef Real_::DoubleType Double_
 
typedef Double_::Real Double
 
typedef Alge_< RealAlge
 
typedef Alge_< DoubleAlge_d
 
typedef Uniform_< DoubleUniform
 
- Protected Member Functions inherited from honey::RandomDist< Real >
Real cdfInvFind (Real P, Real min, Real max, bool discrete=false) const
 Generic binary search algorithm to find Cdf. More...
 

Detailed Description

template<class Real>
class honey::StudentT_< Real >

Generate a random variate from a Student's t-distribution.

The t-dist can be used to account for uncertainty when estimating a quantity (such as the mean) from a small sample of a normally distributed population. The estimation of the quantity produces additive errors that the t-dist can account for.

The shape of the curve is wider than a normal curve, allowing samples to fall further from the mean. As the degrees of freedom increase, the t-distribution approaches the normal distribution.

Probability density function:

$\displaystyle p(x,n) = \frac{\Gamma \paren*{ \frac{n+1}{2}} } {\sqrt{n\pi} \; \Gamma \paren*{ \frac{n}{2} }} \paren*{1 + \frac{x^2}{n}}^{\!\! -\frac{n+1}{2}} $

Parameters
nNumber of degrees of freedom. Range > 0
Return values
xRandom variate. Range [-inf,inf]

Member Typedef Documentation

template<class Real >
typedef Random::DistStats honey::StudentT_< Real >::DistStats
template<class Real >
typedef Vec<2,Real> honey::StudentT_< Real >::Vec2

Constructor & Destructor Documentation

template<class Real >
honey::StudentT_< Real >::StudentT_ ( optional< RandomGen & >  gen,
Real  n 
)
inline
template<class Real >
honey::StudentT_< Real >::StudentT_ ( Real  n)
inline

Member Function Documentation

template<class Real >
Real honey::StudentT_< Real >::cdf ( Real  x) const
virtual

Cumulative Distribution Function.

The integral of the PDF from -inf to x.

Parameters
xvalue, range depends on distribution.
Return values
Pa probability in range [0,1] that a random variate will be <= x.

Reimplemented from honey::RandomDist< Real >.

template<class Real >
Real honey::StudentT_< Real >::cdfComp ( Real  x) const
virtual

Complement of the CDF.

The integral of the PDF from x to inf.

Parameters
xvalue, range depends on distribution.
Return values
Qa probability in range [0,1] that a random variate will be > x.

Reimplemented from honey::RandomDist< Real >.

template<class Real >
Real honey::StudentT_< Real >::cdfInv ( Real  P) const
virtual

Inverse of the CDF.

Parameters
Pcumulative probability
Return values
xA value that has probability P of being >= a random variate X. Also, x satisfies: cdf(x) = P.

Reimplemented from honey::RandomDist< Real >.

template<class Real >
virtual Real honey::StudentT_< Real >::mean ( ) const
inlinevirtual

Calc mean.

Reimplemented from honey::RandomDist< Real >.

template<class Real >
Real honey::StudentT_< Real >::next ( ) const
virtual

Get next randomly distributed variate. Requires a random generator (see ctor or setGen())

Reimplemented from honey::RandomDist< Real >.

template<class Real >
Real honey::StudentT_< Real >::pdf ( Real  x) const
virtual

Probability Density Function.

The PDF integrates to 1 over the entire range of possible values of x.

Parameters
xvalue, range depends on distribution.
Return values
pa relative likelihood in range [0,inf] that a random variate X will equal x.

Reimplemented from honey::RandomDist< Real >.

template<class Real >
template<class Range >
static bool honey::StudentT_< Real >::test ( const Range &  samples,
optional< Stats & >  stats = optnull,
Real  mu = 0,
Real  alpha = 0.05,
int  tail = 0 
)
inlinestatic

One-sample t-test: Test the null hypothesis that the samples are from a normally distributed population with mean mu and unknown standard deviation.

Parameters
samplesSample set to test
statsStatistics about the test may be optionally retrieved
muThe mean to test
alphaThe test is performed at the (100*alpha)% significance level, default is 5%
tail0 = two-tailed test (true if mean is not mu) 1 = upper tail test (true if mean is > mu) -1 = lower tail test (true if mean is < mu)
Returns
Returns true if the null hypothesis is rejected and thus the mean is not mu. If the result is true at 5% significance then there is at most a 1 in 20 chance that the null hypothesis was incorrectly rejected.
template<class Real >
template<class Range , class Range2 >
static std::enable_if<mt::isRange<Range2>::value, bool>::type honey::StudentT_< Real >::test ( const Range &  samples1,
const Range2 &  samples2,
optional< PooledStats & >  stats = optnull,
Real  mu = 0,
Real  alpha = 0.05,
int  tail = 0 
)
inlinestatic

Two-sample t-test: Test the null hypothesis that the difference between two sample distributions is a normally distributed population with mean mu and unknown standard deviation.

This test assumes that both sample distributions have the same variance.

Parameters
samples1First sample set to test
samples2Second sample set to test
statsStatistics about the test may be optionally retrieved
muThe mean to test
alphaThe test is performed at the (100*alpha)% significance level, default is 5%
tail0 = two-tailed test (true if mean (1-2) is not mu) 1 = upper tail test (true if mean (1-2) > mu) -1 = lower tail test (true if mean (1-2) < mu)
Returns
Returns true if the null hypothesis is rejected and thus the mean (1-2) is not mu. If the result is true at 5% significance then there is at most a 1 in 20 chance that the null hypothesis was incorrectly rejected.
template<class Real >
virtual Real honey::StudentT_< Real >::variance ( ) const
inlinevirtual

Calc variance.

Reimplemented from honey::RandomDist< Real >.

Member Data Documentation

template<class Real >
Real honey::StudentT_< Real >::n

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