shark::DiscreteUniform< RngType > Class Template Reference

Implements the discrete uniform distribution. More...

#include <shark/Rng/DiscreteUniform.h>

+ Inheritance diagram for shark::DiscreteUniform< RngType >:

Public Member Functions

 DiscreteUniform (RngType &rng, std::size_t low_=0, std::size_t high_=std::numeric_limits< std::size_t >::max())
 C'tor, initializes the interval the random numbers are sampled from and associates the distribution with the supplied RNG. More...
 
Base::result_type operator() (std::size_t low_, std::size_t high_)
 Reinitializes the distribution for the supplied bounds and samples a new random number. Default values are omitted to distinguish the operator from the default one. More...
 
std::size_t low () const
 Returns the lower bound of the interval. More...
 
std::size_t high () const
 Adjusts the upper bound of the interval. More...
 
void setRange (std::size_t low_, std::size_t high_)
 Adjusts the range of the interval. More...
 
double p (std::size_t x) const
 Calculates the probability of x. More...
 

Detailed Description

template<typename RngType = shark::DefaultRngType>
class shark::DiscreteUniform< RngType >

Implements the discrete uniform distribution.

Definition at line 48 of file DiscreteUniform.h.

Constructor & Destructor Documentation

◆ DiscreteUniform()

template<typename RngType = shark::DefaultRngType>
shark::DiscreteUniform< RngType >::DiscreteUniform ( RngType &  rng,
std::size_t  low_ = 0,
std::size_t  high_ = std::numeric_limits<std::size_t>::max() 
)
inline

C'tor, initializes the interval the random numbers are sampled from and associates the distribution with the supplied RNG.

Parameters
[in,out]rngThe RNG this distribution is associated with.
[in]low_The lower bound of the interval, defaults to 0.
[in]high_The upper bound of the interval, defaults to std::numeric_limits<std::size_t>::max().

Definition at line 61 of file DiscreteUniform.h.

Member Function Documentation

◆ high()

template<typename RngType = shark::DefaultRngType>
std::size_t shark::DiscreteUniform< RngType >::high ( ) const
inline

Adjusts the upper bound of the interval.

Definition at line 90 of file DiscreteUniform.h.

Referenced by shark::DiscreteUniform< RngType >::p().

◆ low()

template<typename RngType = shark::DefaultRngType>
std::size_t shark::DiscreteUniform< RngType >::low ( ) const
inline

Returns the lower bound of the interval.

Definition at line 84 of file DiscreteUniform.h.

Referenced by shark::DiscreteUniform< RngType >::p().

◆ operator()()

template<typename RngType = shark::DefaultRngType>
Base::result_type shark::DiscreteUniform< RngType >::operator() ( std::size_t  low_,
std::size_t  high_ 
)
inline

Reinitializes the distribution for the supplied bounds and samples a new random number. Default values are omitted to distinguish the operator from the default one.

Parameters
[in]low_The lower bound of the interval.
[in]high_The upper bound of the interval.

Definition at line 77 of file DiscreteUniform.h.

References remora::max(), and remora::min().

◆ p()

template<typename RngType = shark::DefaultRngType>
double shark::DiscreteUniform< RngType >::p ( std::size_t  x) const
inline

Calculates the probability of x.

Definition at line 103 of file DiscreteUniform.h.

References shark::DiscreteUniform< RngType >::high(), and shark::DiscreteUniform< RngType >::low().

◆ setRange()

template<typename RngType = shark::DefaultRngType>
void shark::DiscreteUniform< RngType >::setRange ( std::size_t  low_,
std::size_t  high_ 
)
inline

Adjusts the range of the interval.

Definition at line 96 of file DiscreteUniform.h.

References remora::max(), and remora::min().


The documentation for this class was generated from the following file: