Turi Create  4.0
turi::random::generator Class Reference

#include <core/random/random.hpp>

Public Member Functions

void seed ()
 Seed the generator using the default seed.
 
void nondet_seed ()
 Seed the generator nondeterministically.
 
void time_seed ()
 Seed the generator using the current time in microseconds.
 
void seed (size_t number)
 Seed the random number generator based on a number.
 
void seed (generator &other)
 Seed the generator using another generator.
 
template<typename NumType >
NumType uniform (const NumType min, const NumType max)
 
template<typename NumType >
NumType fast_uniform (const NumType min, const NumType max)
 
double gamma (const double alpha=double(1))
 
double gaussian (const double mean=double(0), const double stdev=double(1))
 
double normal (const double mean=double(0), const double stdev=double(1))
 
double cauchy (const double location=double(0), const double scale=double(1))
 
template<typename Double >
size_t multinomial (const std::vector< Double > &prb)
 
template<typename VecType , typename VType >
size_t multinomial (const VecType &prb, VType norm)
 
template<typename Double >
size_t multinomial_cdf (const std::vector< Double > &cdf)
 
template<typename T >
std::vector< T > permutation (const size_t nelems)
 
template<typename T >
void shuffle (std::vector< T > &vec)
 
template<typename Iterator >
void shuffle (Iterator begin, Iterator end)
 

Detailed Description

The generator class is the base underlying type used to generate random numbers. User threads should use the functions provided in the random namespace.

Definition at line 89 of file random.hpp.

Member Function Documentation

◆ cauchy()

double turi::random::generator::cauchy ( const double  location = double(0),
const double  scale = double(1) 
)
inline

Generate a cauchy random variable with zero location and unit scale.

Definition at line 207 of file random.hpp.

◆ fast_uniform()

template<typename NumType >
NumType turi::random::generator::fast_uniform ( const NumType  min,
const NumType  max 
)
inline

Generate a random number in the uniform real with range [min, max) or [min, max] if the number type is discrete.

Definition at line 159 of file random.hpp.

◆ gamma()

double turi::random::generator::gamma ( const double  alpha = double(1))
inline

Generate a random number in the uniform real with range [min, max);

Definition at line 172 of file random.hpp.

◆ gaussian()

double turi::random::generator::gaussian ( const double  mean = double(0),
const double  stdev = double(1) 
)
inline

Generate a gaussian random variable with zero mean and unit variance.

Definition at line 185 of file random.hpp.

◆ multinomial() [1/2]

template<typename Double >
size_t turi::random::generator::multinomial ( const std::vector< Double > &  prb)
inline

Draw a random number from a multinomial

Definition at line 237 of file random.hpp.

◆ multinomial() [2/2]

template<typename VecType , typename VType >
size_t turi::random::generator::multinomial ( const VecType &  prb,
VType  norm 
)
inline

Draw a random number from a multinomial with normalizing constant provided.

Definition at line 260 of file random.hpp.

◆ multinomial_cdf()

template<typename Double >
size_t turi::random::generator::multinomial_cdf ( const std::vector< Double > &  cdf)
inline

Generate a draw from a multinomial using a CDF. This is slightly more efficient since normalization is not required and a binary search can be used.

Definition at line 296 of file random.hpp.

◆ normal()

double turi::random::generator::normal ( const double  mean = double(0),
const double  stdev = double(1) 
)
inline

Generate a gaussian random variable with zero mean and unit variance.

Definition at line 198 of file random.hpp.

◆ permutation()

template<typename T >
std::vector<T> turi::random::generator::permutation ( const size_t  nelems)
inline

Construct a random permutation

Definition at line 307 of file random.hpp.

◆ shuffle() [1/2]

template<typename T >
void turi::random::generator::shuffle ( std::vector< T > &  vec)
inline

Shuffle a standard vector

Definition at line 318 of file random.hpp.

◆ shuffle() [2/2]

template<typename Iterator >
void turi::random::generator::shuffle ( Iterator  begin,
Iterator  end 
)
inline

Shuffle a range using the begin and end iterators

Definition at line 324 of file random.hpp.

◆ uniform()

template<typename NumType >
NumType turi::random::generator::uniform ( const NumType  min,
const NumType  max 
)
inline

Generate a random number in the uniform real with range [min, max) or [min, max] if the number type is discrete.

Definition at line 146 of file random.hpp.


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