CBOE Emulator  1.0
Functions
Maths::Probability Namespace Reference

Functions for dealing with probability. More...

Functions

std::mt19937 generator (getpid())
 the global generator for the probability module.
 
template<typename T >
void seed (T value)
 Set the seed for the random number generator. More...
 
template<typename T >
uniform_int (T min, T max)
 Sample a number from an integer-valued uniform distribution. More...
 
template<typename T >
uniform_real (T min, T max)
 Sample a number from a real-valued uniform distribution. More...
 
template<typename T >
normal (T mean, T stddev)
 Sample a number from a normal distribution. More...
 
template<typename T >
lognormal (T mean, T stddev)
 Sample a number from a log-normal distribution. More...
 
template<typename T >
power_law (T constant, T exponent)
 Sample a number sample from a power law distribution. More...
 
bool boolean ()
 Return the result of a coin toss. More...
 
template<typename T >
bool boolean (T P)
 Return true with given probability. More...
 

Detailed Description

Functions for dealing with probability.

Function Documentation

◆ boolean() [1/2]

bool Maths::Probability::boolean ( )
inline

Return the result of a coin toss.

Returns
\(y \sim \mathcal{U}\{0, 1\}\)

◆ boolean() [2/2]

template<typename T >
bool Maths::Probability::boolean ( P)
inline

Return true with given probability.

Template Parameters
Tthe class of the probability value
Parameters
Pthe probability of sampling true, \(p_{true}\)
Returns
true with \(P(\texttt{true} = p_{true})\) and false with \(P(\texttt{false} = 1 - p_{true})\)

◆ lognormal()

template<typename T >
T Maths::Probability::lognormal ( mean,
stddev 
)
inline

Sample a number from a log-normal distribution.

Template Parameters
Tthe class of the number to sample
Parameters
meanthe mean value \(\mu\) of the distribution
stddevthe standard deviation \(\sigma\) of the distribution
Returns
\(y \sim e^{\mu + \sigma \mathcal{U}(0, 1)}\)

◆ normal()

template<typename T >
T Maths::Probability::normal ( mean,
stddev 
)
inline

Sample a number from a normal distribution.

Template Parameters
Tthe class of the number to sample
Parameters
meanthe mean value \(\mu\) of the distribution
stddevthe standard deviation \(\sigma\) of the distribution
Returns
\(y \sim \mathcal{N}(\mu, \sigma)\)

◆ power_law()

template<typename T >
T Maths::Probability::power_law ( constant,
exponent 
)
inline

Sample a number sample from a power law distribution.

Template Parameters
Tthe class of the number to sample
Parameters
constantthe constant value \(k\) of the distribution
exponentthe exponent \(\alpha\)
Returns
\(y \sim k \cdot \mathcal{U}(0, 1)^{\alpha}\)

◆ seed()

template<typename T >
void Maths::Probability::seed ( value)
inline

Set the seed for the random number generator.

Template Parameters
Tthe class of the seed value
Parameters
valuethe seed for the random number generators

◆ uniform_int()

template<typename T >
T Maths::Probability::uniform_int ( min,
max 
)
inline

Sample a number from an integer-valued uniform distribution.

Template Parameters
Tthe class of the number to sample
Parameters
minthe inclusive minimal value \(v_{min}\) to sample
maxthe inclusive maximal value \(v_{max}\) to sample
Returns
\(y \sim \mathcal{U}\{v_{min}, v_{max}\}\)

◆ uniform_real()

template<typename T >
T Maths::Probability::uniform_real ( min,
max 
)
inline

Sample a number from a real-valued uniform distribution.

Template Parameters
Tthe class of the number to sample
Parameters
minthe inclusive minimal value \(v_{min}\) to sample
maxthe inclusive maximal value \(v_{max}\) to sample
Returns
\(y \sim \mathcal{U}(v_{min}, v_{max})\)