Turi Create  4.0
Random Number Generators

Namespaces

 turi::random
 

Classes

class  turi::random::alias_sampler
 

Functions

void turi::random::seed ()
 
void turi::random::seed (size_t seed_value)
 
void turi::random::nondet_seed ()
 
void turi::random::time_seed ()
 
generatorturi::random::get_source ()
 
template<typename NumType >
NumType turi::random::uniform (const NumType min, const NumType max)
 
template<typename NumType >
NumType turi::random::fast_uniform (const NumType min, const NumType max)
 
double turi::random::rand01 ()
 
int turi::random::rand ()
 
double turi::random::gamma (const double alpha=double(1))
 
double turi::random::gaussian (const double mean=double(0), const double stdev=double(1))
 
double turi::random::normal (const double mean=double(0), const double stdev=double(1))
 
double turi::random::cauchy (const double location=double(0), const double scale=double(1))
 
bool turi::random::bernoulli (const double p=double(0.5))
 
bool turi::random::fast_bernoulli (const double p=double(0.5))
 
template<typename Double >
size_t turi::random::multinomial (const std::vector< Double > &prb)
 
template<typename VecLike , typename Double >
size_t turi::random::multinomial (const VecLike &prb, Double norm)
 
template<typename Double >
size_t turi::random::multinomial_cdf (const std::vector< Double > &cdf)
 
template<typename T >
std::vector< T > turi::random::permutation (const size_t nelems)
 
template<typename T >
void turi::random::shuffle (std::vector< T > &vec)
 
template<typename Iterator >
void turi::random::shuffle (Iterator begin, Iterator end)
 

Detailed Description

Function Documentation

◆ bernoulli()

bool turi::random::bernoulli ( const double  p = double(0.5))
inline

Draw a sample from a bernoulli distribution

Definition at line 478 of file random.hpp.

◆ cauchy()

double turi::random::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 469 of file random.hpp.

◆ fast_bernoulli()

bool turi::random::fast_bernoulli ( const double  p = double(0.5))
inline

Draw a sample form a bernoulli distribution using the faster generator

Definition at line 486 of file random.hpp.

◆ fast_uniform()

template<typename NumType >
NumType turi::random::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 416 of file random.hpp.

◆ gamma()

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

Generate a random number from a gamma distribution.

Definition at line 438 of file random.hpp.

◆ gaussian()

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

Generate a gaussian random variable with zero mean and unit standard deviation.

Definition at line 449 of file random.hpp.

◆ get_source()

generator& turi::random::get_source ( )

Get the local generator

◆ multinomial() [1/2]

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

Generate a draw from a multinomial. This function automatically normalizes as well.

Definition at line 496 of file random.hpp.

◆ multinomial() [2/2]

template<typename VecLike , typename Double >
size_t turi::random::multinomial ( const VecLike &  prb,
Double  norm 
)
inline

Generate a draw from a multinomial, with preknown normalization This function automatically normalizes as well.

Definition at line 506 of file random.hpp.

◆ multinomial_cdf()

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

Generate a draw from a cdf;

Definition at line 515 of file random.hpp.

◆ nondet_seed()

void turi::random::nondet_seed ( )

Seed all generators using a nondeterministic source

◆ normal()

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

Generate a gaussian random variable with zero mean and unit standard deviation.

Definition at line 459 of file random.hpp.

◆ permutation()

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

Construct a random permutation

Definition at line 526 of file random.hpp.

◆ rand()

int turi::random::rand ( )
inline

Simulates the standard rand function as defined in cstdlib

Definition at line 431 of file random.hpp.

◆ rand01()

double turi::random::rand01 ( )
inline

Generate a random number between 0 and 1

Definition at line 425 of file random.hpp.

◆ seed() [1/2]

void turi::random::seed ( )

Seed all generators using the default seed

Examples:
/build/src/core/storage/sframe_interface/unity_sframe.hpp.

◆ seed() [2/2]

void turi::random::seed ( size_t  seed_value)

Seed all generators using an integer

◆ shuffle() [1/2]

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

Shuffle a standard vector

Definition at line 536 of file random.hpp.

◆ shuffle() [2/2]

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

Shuffle a range using the begin and end iterators

Definition at line 545 of file random.hpp.

◆ time_seed()

void turi::random::time_seed ( )

Seed all generators using the current time in microseconds

◆ uniform()

template<typename NumType >
NumType turi::random::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 405 of file random.hpp.