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

Platform-independent exponential 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

 ExponentialDistribution ()
 Default constructor. Creates Exponential(1) distribution.
 
 ExponentialDistribution (RealType lambda)
 Constructs an exponential distribution with specified rate.
 
 ExponentialDistribution (const param_type &param)
 Constructs from a parameter set.
 
void reset ()
 Resets the distribution state.
 
RealType lambda () const
 Gets the rate 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 minimum value that can be generated (approaches 0).
 
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 ExponentialDistribution &lhs, const ExponentialDistribution &rhs)
 
bool operator!= (const ExponentialDistribution &lhs, const ExponentialDistribution &rhs)
 

Detailed Description

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

Platform-independent exponential distribution.

Produces positive values according to the exponential distribution with rate parameter lambda. Models time between events in a Poisson process, making it fundamental for modeling waiting times and lifetimes.

The exponential distribution is the continuous analog of the geometric distribution and is the only continuous distribution with the memoryless property: the probability of an event occurring in the next time interval is independent of how much time has already elapsed.

Template Parameters
RealTypeFloating point type (float or double)

Example usage:

PRNG rng(12345);
// Average time between events = 1/lambda = 1/0.5 = 2.0 units
ExponentialDistribution<float> arrival_times(0.5f);
float wait_time = arrival_times(rng);
// Generate event intervals for a Poisson process
ExponentialDistribution<double> intervals(1.5); // rate = 1.5 events per unit
double total_time = 0.0;
for (int i = 0; i < 10; ++i) {
double interval = intervals(rng);
total_time += interval;
}
// Model component failure times
ExponentialDistribution<float> failure_time(0.001f); // low failure rate
float time_to_failure = failure_time(rng);
Platform-independent exponential distribution.
Definition PRNGDistribution.hpp:1949
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
Note
All values are strictly positive.
Memoryless property: P(X > s+t | X > s) = P(X > t)
Mean = 1/lambda, Variance = 1/lambda²
Special case of Gamma(1, 1/lambda) distribution.

Member Typedef Documentation

◆ result_type

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

The type of values produced by the distribution.

Constructor & Destructor Documentation

◆ ExponentialDistribution() [1/3]

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

Default constructor. Creates Exponential(1) distribution.

◆ ExponentialDistribution() [2/3]

template<typename RealType = double>
Infinity::Engine::ExponentialDistribution< RealType >::ExponentialDistribution ( RealType  lambda)
inlineexplicit

Constructs an exponential distribution with specified rate.

Parameters
lambdaRate parameter

◆ ExponentialDistribution() [3/3]

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

Constructs from a parameter set.

Parameters
paramThe distribution parameters

Member Function Documentation

◆ lambda()

template<typename RealType = double>
RealType Infinity::Engine::ExponentialDistribution< RealType >::lambda ( ) const
inline

Gets the rate parameter.

◆ max()

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

Gets the theoretical maximum value (positive infinity).

◆ min()

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

Gets the minimum value that can be generated (approaches 0).

◆ operator()() [1/2]

template<typename RealType = double>
template<typename Generator >
result_type Infinity::Engine::ExponentialDistribution< 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 positive random value from the exponential distribution

◆ operator()() [2/2]

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

Generates the next random value using provided parameters.

Uses the inverse CDF method: X = -ln(1-U) / lambda where U ~ Uniform(0, 1) and X ~ Exponential(lambda).

The implementation avoids U = 0 or 1 to prevent numerical issues.

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 positive random value from Exponential(param.lambda())

◆ param() [1/2]

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

Gets the current parameter set.

◆ param() [2/2]

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

Sets new parameters for the distribution.

◆ reset()

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

Resets the distribution state.

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

Friends And Related Symbol Documentation

◆ operator!=

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

◆ operator==

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