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

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

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

Detailed Description

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

Platform-independent Weibull distribution.

Produces positive values according to the Weibull distribution with shape parameter a and scale parameter b. Generalizes the exponential distribution and is widely used in reliability analysis and lifetime modeling.

The shape parameter determines the failure rate behavior:

  • a < 1: Decreasing failure rate (infant mortality, early failures)
  • a = 1: Constant failure rate (exponential distribution, random failures)
  • a > 1: Increasing failure rate (wear-out failures, aging)

This makes the Weibull distribution extremely versatile for modeling component lifetimes across different failure modes.

Template Parameters
RealTypeFloating point type (float or double)

Example usage:

PRNG rng(12345);
// Shape=2, Scale=1 (Rayleigh distribution - wind speed modeling)
WeibullDistribution<float> wind_speed(2.0f, 1.0f);
float speed = wind_speed(rng);
// Component lifetime modeling (wear-out failures)
WeibullDistribution<float> lifetime(1.5f, 1000.0f);
float hours_to_failure = lifetime(rng);
// Infant mortality (decreasing failure rate)
WeibullDistribution<double> early_failure(0.8, 100.0);
double time_to_defect = early_failure(rng);
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
Platform-independent Weibull distribution.
Definition PRNGDistribution.hpp:2124
Note
All values are strictly positive.
When a = 2, b = sqrt(2), becomes Rayleigh distribution.
When a = 1, reduces to exponential distribution with rate 1/b.
Mean = b * Γ(1 + 1/a), where Γ is the gamma function.

Member Typedef Documentation

◆ result_type

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

The type of values produced by the distribution.

Constructor & Destructor Documentation

◆ WeibullDistribution() [1/3]

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

Default constructor. Creates Weibull(1, 1) distribution.

◆ WeibullDistribution() [2/3]

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

Constructs a Weibull distribution with specified parameters.

Parameters
aShape parameter
bScale parameter

◆ WeibullDistribution() [3/3]

template<typename RealType = double>
Infinity::Engine::WeibullDistribution< RealType >::WeibullDistribution ( 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::WeibullDistribution< RealType >::a ( ) const
inline

Gets the shape parameter.

◆ b()

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

Gets the scale parameter.

◆ max()

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

Gets the theoretical maximum value (positive infinity).

◆ min()

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

◆ operator()() [2/2]

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

Generates the next random value using provided parameters.

Uses the transformation: If E ~ Exponential(1), then X = b * E^(1/a) ~ Weibull(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 positive random value from Weibull(param.a(), param.b())

◆ param() [1/2]

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

Gets the current parameter set.

◆ param() [2/2]

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

Sets new parameters for the distribution.

◆ reset()

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

Resets the distribution state.

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

Friends And Related Symbol Documentation

◆ operator!=

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

◆ operator==

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