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

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

 LognormalDistribution ()
 Default constructor. Creates Lognormal(0, 1) distribution.
 
 LognormalDistribution (RealType m, RealType s=RealType(1))
 Constructs a lognormal distribution with specified parameters.
 
 LognormalDistribution (const param_type &param)
 Constructs from a parameter set.
 
void reset ()
 Resets the distribution state.
 
RealType m () const
 Gets the mean parameter of underlying normal distribution.
 
RealType s () const
 Gets the standard deviation parameter of underlying normal distribution.
 
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 &p)
 Generates the next random value using provided parameters.
 

Friends

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

Detailed Description

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

Platform-independent lognormal distribution.

Produces values according to a lognormal distribution, where the logarithm of the values follows a normal distribution. Useful for modeling multiplicative processes and values that are naturally positive and right-skewed.

If X ~ Lognormal(m, s), then log(X) ~ Normal(m, s). This makes the lognormal distribution ideal for modeling quantities that result from multiplicative random effects, such as particle sizes, income distributions, species abundance, or compound growth processes.

Template Parameters
RealTypeFloating point type (float or double)

Example usage:

PRNG rng(12345);
// Parameters: m (underlying normal mean), s (underlying normal stddev)
LognormalDistribution<float> sizes(2.0f, 0.5f);
// Generate particle sizes (always positive)
for (int i = 0; i < 100; ++i) {
float size = sizes(rng); // Returns positive value with right-skewed distribution
}
// Model compound growth with variability
LognormalDistribution<double> growth_factor(0.0, 0.2);
double multiplier = growth_factor(rng); // Median ~1.0, always positive
Platform-independent lognormal distribution.
Definition PRNGDistribution.hpp:744
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
Note
All generated values are strictly positive (> 0).
The distribution is right-skewed with a long tail toward larger values.
For Lognormal(m, s): median = exp(m), mode = exp(m - s²)

Member Typedef Documentation

◆ result_type

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

The type of values produced by the distribution.

Constructor & Destructor Documentation

◆ LognormalDistribution() [1/3]

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

Default constructor. Creates Lognormal(0, 1) distribution.

◆ LognormalDistribution() [2/3]

template<typename RealType = double>
Infinity::Engine::LognormalDistribution< RealType >::LognormalDistribution ( RealType  m,
RealType  s = RealType(1) 
)
inlineexplicit

Constructs a lognormal distribution with specified parameters.

Parameters
mMean of underlying normal distribution
sStandard deviation of underlying normal distribution

◆ LognormalDistribution() [3/3]

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

Constructs from a parameter set.

Parameters
paramThe distribution parameters

Member Function Documentation

◆ m()

template<typename RealType = double>
RealType Infinity::Engine::LognormalDistribution< RealType >::m ( ) const
inline

Gets the mean parameter of underlying normal distribution.

◆ max()

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

Gets the theoretical maximum value (positive infinity).

◆ min()

template<typename RealType = double>
result_type Infinity::Engine::LognormalDistribution< 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::LognormalDistribution< 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 lognormal distribution

◆ operator()() [2/2]

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

Generates the next random value using provided parameters.

Generates a value from the lognormal distribution by drawing from a normal distribution and exponentiating the result.

Template Parameters
GeneratorThe random number generator type (e.g., PRNG)
Parameters
gThe random number generator
pThe distribution parameters to use for this generation
Returns
A positive random value from Lognormal(p.m(), p.s())

◆ param() [1/2]

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

Gets the current parameter set.

◆ param() [2/2]

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

Sets new parameters for the distribution.

◆ reset()

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

Resets the distribution state.

Resets the underlying normal distribution, discarding any cached values.

◆ s()

template<typename RealType = double>
RealType Infinity::Engine::LognormalDistribution< RealType >::s ( ) const
inline

Gets the standard deviation parameter of underlying normal distribution.

Friends And Related Symbol Documentation

◆ operator!=

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

◆ operator==

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