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

Platform-independent Cauchy (Lorentz) 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

 CauchyDistribution ()
 Default constructor. Creates standard Cauchy distribution (a=0, b=1).
 
 CauchyDistribution (RealType a, RealType b=RealType(1))
 Constructs a Cauchy distribution with specified parameters.
 
 CauchyDistribution (const param_type &param)
 Constructs from a parameter set.
 
void reset ()
 Resets the distribution state.
 
RealType a () const
 Gets the location parameter.
 
RealType b () const
 Gets the scale parameter.
 
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 CauchyDistribution &lhs, const CauchyDistribution &rhs)
 
bool operator!= (const CauchyDistribution &lhs, const CauchyDistribution &rhs)
 

Detailed Description

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

Platform-independent Cauchy (Lorentz) distribution.

Produces values according to the Cauchy distribution, which has heavy tails and undefined mean and variance. Useful for modeling phenomena with extreme outliers or when you need occasional very large values.

The Cauchy distribution is notable for having no defined moments - the mean, variance, and higher moments do not exist mathematically. This makes it useful for modeling phenomena where extreme values occur much more frequently than in a normal distribution, such as resonance phenomena in physics or certain financial models.

Template Parameters
RealTypeFloating point type (float or double)

Example usage:

PRNG rng(12345);
// Standard Cauchy (location=0, scale=1)
float value = standard(rng);
// Custom location and scale parameters
CauchyDistribution<float> custom(5.0f, 2.0f);
float shifted = custom(rng);
// Generate values with heavy tails for outlier modeling
CauchyDistribution<double> outliers(0.0, 1.0);
for (int i = 0; i < 100; ++i) {
double val = outliers(rng); // Expect occasional very large values
}
Platform-independent Cauchy (Lorentz) distribution.
Definition PRNGDistribution.hpp:923
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
Note
Heavy-tailed: extreme values occur much more frequently than in normal distribution.
Mean and variance are undefined (do not exist mathematically).
The median and mode both equal the location parameter a.
Warning
Sample mean does not converge to any value as sample size increases.

Member Typedef Documentation

◆ result_type

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

The type of values produced by the distribution.

Constructor & Destructor Documentation

◆ CauchyDistribution() [1/3]

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

Default constructor. Creates standard Cauchy distribution (a=0, b=1).

◆ CauchyDistribution() [2/3]

template<typename RealType = double>
Infinity::Engine::CauchyDistribution< RealType >::CauchyDistribution ( RealType  a,
RealType  b = RealType(1) 
)
inlineexplicit

Constructs a Cauchy distribution with specified parameters.

Parameters
aLocation parameter
bScale parameter

◆ CauchyDistribution() [3/3]

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

Constructs from a parameter set.

Parameters
paramThe distribution parameters

Member Function Documentation

◆ a()

template<typename RealType = double>
RealType Infinity::Engine::CauchyDistribution< RealType >::a ( ) const
inline

Gets the location parameter.

◆ b()

template<typename RealType = double>
RealType Infinity::Engine::CauchyDistribution< RealType >::b ( ) const
inline

Gets the scale parameter.

◆ max()

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

Gets the theoretical maximum value (positive infinity).

◆ min()

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

Gets the theoretical minimum value (negative infinity).

◆ operator()() [1/2]

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

Generates the next random value using stored parameters.

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

◆ operator()() [2/2]

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

Generates the next random value using provided parameters.

Uses the inverse CDF method: X = a + b * tan(π(U - 0.5)) where U ~ Uniform(0, 1) and X ~ Cauchy(a, b).

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 Cauchy(param.a(), param.b())

◆ param() [1/2]

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

Gets the current parameter set.

◆ param() [2/2]

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

Sets new parameters for the distribution.

◆ reset()

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

Resets the distribution state.

No-op for Cauchy distribution as it maintains no internal state.

Friends And Related Symbol Documentation

◆ operator!=

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

◆ operator==

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