Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Engine::DiscreteDistribution< IntType >::param_type Struct Reference

Parameter set for the distribution. More...

#include <PRNGDistribution.hpp>

Public Types

using distribution_type = DiscreteDistribution< IntType >
 

Public Member Functions

 param_type ()
 Default constructor. Creates uniform distribution over {0}.
 
template<typename InputIterator >
 param_type (InputIterator first, InputIterator last)
 Constructs from iterator range of weights.
 
 param_type (std::initializer_list< double > wl)
 Constructs from initializer list of weights.
 
template<typename UnaryOperation >
 param_type (size_t count, double xmin, double xmax, UnaryOperation fw)
 Constructs from function evaluated at intervals.
 
std::vector< double > probabilities () const
 Returns the probability vector.
 

Public Attributes

std::vector< double > m_prob
 Individual probabilities.
 
std::vector< double > m_cp
 Cumulative probabilities for efficient sampling.
 

Friends

class DiscreteDistribution< IntType >
 
bool operator== (const param_type &lhs, const param_type &rhs)
 
bool operator!= (const param_type &lhs, const param_type &rhs)
 

Detailed Description

template<typename IntType = int>
struct Infinity::Engine::DiscreteDistribution< IntType >::param_type

Parameter set for the distribution.

Stores the probability mass function as both raw probabilities and cumulative probabilities for efficient sampling.

Member Typedef Documentation

◆ distribution_type

template<typename IntType = int>
using Infinity::Engine::DiscreteDistribution< IntType >::param_type::distribution_type = DiscreteDistribution<IntType>

Constructor & Destructor Documentation

◆ param_type() [1/4]

template<typename IntType = int>
Infinity::Engine::DiscreteDistribution< IntType >::param_type::param_type ( )
inline

Default constructor. Creates uniform distribution over {0}.

◆ param_type() [2/4]

template<typename IntType = int>
template<typename InputIterator >
Infinity::Engine::DiscreteDistribution< IntType >::param_type::param_type ( InputIterator  first,
InputIterator  last 
)
inline

Constructs from iterator range of weights.

Weights will be normalized to probabilities automatically.

Template Parameters
InputIteratorIterator type for weights
Parameters
firstIterator to first weight
lastIterator past last weight

◆ param_type() [3/4]

template<typename IntType = int>
Infinity::Engine::DiscreteDistribution< IntType >::param_type::param_type ( std::initializer_list< double >  wl)
inline

Constructs from initializer list of weights.

Weights will be normalized to probabilities automatically.

Parameters
wlInitializer list of weights

◆ param_type() [4/4]

template<typename IntType = int>
template<typename UnaryOperation >
Infinity::Engine::DiscreteDistribution< IntType >::param_type::param_type ( size_t  count,
double  xmin,
double  xmax,
UnaryOperation  fw 
)
inline

Constructs from function evaluated at intervals.

Evaluates the weight function at the midpoint of each interval [xmin + i*delta, xmin + (i+1)*delta) for i = 0..count-1.

Template Parameters
UnaryOperationFunction type: double -> double
Parameters
countNumber of discrete outcomes
xminMinimum x value for function evaluation
xmaxMaximum x value for function evaluation
fwFunction to evaluate at interval midpoints

Member Function Documentation

◆ probabilities()

template<typename IntType = int>
std::vector< double > Infinity::Engine::DiscreteDistribution< IntType >::param_type::probabilities ( ) const
inline

Returns the probability vector.

Returns
Vector of probabilities for each outcome

Friends And Related Symbol Documentation

◆ DiscreteDistribution< IntType >

template<typename IntType = int>
friend class DiscreteDistribution< IntType >
friend

◆ operator!=

template<typename IntType = int>
bool operator!= ( const param_type lhs,
const param_type rhs 
)
friend

◆ operator==

template<typename IntType = int>
bool operator== ( const param_type lhs,
const param_type rhs 
)
friend

Member Data Documentation

◆ m_cp

template<typename IntType = int>
std::vector<double> Infinity::Engine::DiscreteDistribution< IntType >::param_type::m_cp

Cumulative probabilities for efficient sampling.

◆ m_prob

template<typename IntType = int>
std::vector<double> Infinity::Engine::DiscreteDistribution< IntType >::param_type::m_prob

Individual probabilities.