Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Engine::StudentTDistribution< RealType > Class Template Reference

Platform-independent Student's t-distribution. More...

#include <PRNGDistribution.hpp>

Classes

struct  param_type
 Parameter set for the distribution. More...
 

Public Types

using result_type = RealType
 The type of values produced by the distribution.
 

Public Member Functions

 StudentTDistribution ()
 Default constructor. Creates t(1) distribution (Cauchy).
 
 StudentTDistribution (RealType n)
 Constructs a t-distribution with specified degrees of freedom.
 
 StudentTDistribution (const param_type &param)
 Constructs from a parameter set.
 
void reset ()
 Resets the distribution state.
 
RealType n () const
 Gets the degrees of freedom.
 
param_type param () const
 Gets the current parameter set.
 
void param (const param_type &param)
 Sets new parameters for the distribution.
 
result_type min () const
 Gets the theoretical minimum value (negative infinity).
 
result_type max () const
 Gets the theoretical maximum value (positive infinity).
 
template<typename Generator >
result_type operator() (Generator &g)
 Generates the next random value using stored parameters.
 
template<typename Generator >
result_type operator() (Generator &g, const param_type &param)
 Generates the next random value using provided parameters.
 

Friends

bool operator== (const StudentTDistribution &lhs, const StudentTDistribution &rhs)
 
bool operator!= (const StudentTDistribution &lhs, const StudentTDistribution &rhs)
 

Detailed Description

template<typename RealType = double>
class Infinity::Engine::StudentTDistribution< RealType >

Platform-independent Student's t-distribution.

Produces values according to Student's t-distribution with n degrees of freedom. Similar to the normal distribution but with heavier tails, approaching normal as n increases. Essential for statistical inference with small sample sizes.

The t-distribution arises when estimating the mean of a normally distributed population with unknown variance from small samples. It's widely used in confidence intervals and hypothesis tests when the sample size is small.

Template Parameters
RealTypeFloating point type (float or double)

Example usage:

PRNG rng(12345);
// t-distribution with 10 degrees of freedom
float value = t_dist(rng);
// Small sample confidence interval simulation
StudentTDistribution<double> small_sample(5.0);
for (int i = 0; i < 1000; ++i) {
double t_value = small_sample(rng);
}
// Compare to normal for large n
StudentTDistribution<float> nearly_normal(100.0f);
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
Platform-independent Student's t-distribution.
Definition PRNGDistribution.hpp:1742
Note
Symmetric around zero with heavier tails than normal distribution.
As n approaches infinity, converges to standard normal N(0,1).
Mean = 0 for n > 1; undefined for n ≤ 1.
Variance = n/(n-2) for n > 2; infinite for 1 < n ≤ 2; undefined for n ≤ 1.
For n = 1, reduces to Cauchy distribution.

Member Typedef Documentation

◆ result_type

template<typename RealType = double>
using Infinity::Engine::StudentTDistribution< RealType >::result_type = RealType

The type of values produced by the distribution.

Constructor & Destructor Documentation

◆ StudentTDistribution() [1/3]

template<typename RealType = double>
Infinity::Engine::StudentTDistribution< RealType >::StudentTDistribution ( )
inline

Default constructor. Creates t(1) distribution (Cauchy).

◆ StudentTDistribution() [2/3]

template<typename RealType = double>
Infinity::Engine::StudentTDistribution< RealType >::StudentTDistribution ( RealType  n)
inlineexplicit

Constructs a t-distribution with specified degrees of freedom.

Parameters
nDegrees of freedom

◆ StudentTDistribution() [3/3]

template<typename RealType = double>
Infinity::Engine::StudentTDistribution< RealType >::StudentTDistribution ( const param_type param)
inlineexplicit

Constructs from a parameter set.

Parameters
paramThe distribution parameters

Member Function Documentation

◆ max()

template<typename RealType = double>
result_type Infinity::Engine::StudentTDistribution< RealType >::max ( ) const
inline

Gets the theoretical maximum value (positive infinity).

◆ min()

template<typename RealType = double>
result_type Infinity::Engine::StudentTDistribution< RealType >::min ( ) const
inline

Gets the theoretical minimum value (negative infinity).

◆ n()

template<typename RealType = double>
RealType Infinity::Engine::StudentTDistribution< RealType >::n ( ) const
inline

Gets the degrees of freedom.

◆ operator()() [1/2]

template<typename RealType = double>
template<typename Generator >
result_type Infinity::Engine::StudentTDistribution< RealType >::operator() ( Generator &  g)
inline

Generates the next random value using stored parameters.

Uses the relationship: If Z ~ N(0,1) and V ~ ChiSquared(n), then T = Z / sqrt(V/n) ~ t(n)

Template Parameters
GeneratorThe random number generator type (e.g., PRNG)
Parameters
gThe random number generator
Returns
A random value from the t-distribution

◆ operator()() [2/2]

template<typename RealType = double>
template<typename Generator >
result_type Infinity::Engine::StudentTDistribution< RealType >::operator() ( Generator &  g,
const param_type param 
)
inline

Generates the next random value using provided parameters.

Template Parameters
GeneratorThe random number generator type (e.g., PRNG)
Parameters
gThe random number generator
paramThe distribution parameters to use for this generation
Returns
A random value from t(param.n())

◆ param() [1/2]

template<typename RealType = double>
param_type Infinity::Engine::StudentTDistribution< RealType >::param ( ) const
inline

Gets the current parameter set.

◆ param() [2/2]

template<typename RealType = double>
void Infinity::Engine::StudentTDistribution< RealType >::param ( const param_type param)
inline

Sets new parameters for the distribution.

Recreates the underlying gamma distribution with the new degrees of freedom.

Parameters
paramThe new distribution parameters

◆ reset()

template<typename RealType = double>
void Infinity::Engine::StudentTDistribution< RealType >::reset ( )
inline

Resets the distribution state.

Resets both the normal and gamma distributions.

Friends And Related Symbol Documentation

◆ operator!=

template<typename RealType = double>
bool operator!= ( const StudentTDistribution< RealType > &  lhs,
const StudentTDistribution< RealType > &  rhs 
)
friend

◆ operator==

template<typename RealType = double>
bool operator== ( const StudentTDistribution< RealType > &  lhs,
const StudentTDistribution< RealType > &  rhs 
)
friend