Feat C++ API
A feature engineering automation tool
FT::Util::Rnd Class Reference

Defines a multi-core random number generator and its operators. More...

#include <rnd.h>

Collaboration diagram for FT::Util::Rnd:

Public Member Functions

void set_seed (int new_seed)
 
int get_seed ()
 
int rnd_int (int lowerLimit, int upperLimit)
 
float rnd_flt (float min=0.0, float max=1.0)
 
float rnd_dbl (float min=0.0, float max=1.0)
 
float operator() (unsigned i)
 
float operator() ()
 
template<class RandomAccessIterator >
void shuffle (RandomAccessIterator first, RandomAccessIterator last)
 
template<typename Iter >
Iter select_randomly (Iter start, Iter end)
 
template<typename T >
random_choice (const vector< T > &v)
 
template<typename T , typename D >
random_choice (const vector< T > &v, const vector< D > &w)
 
float gasdev ()
 

Static Public Member Functions

static RndinitRand ()
 
static void destroy ()
 

Private Member Functions

 Rnd ()
 
 ~Rnd ()
 

Private Attributes

vector< std::mt19937 > rg
 
int seed
 

Static Private Attributes

static Rndinstance = NULL
 

Detailed Description

Defines a multi-core random number generator and its operators.

Definition at line 30 of file rnd.h.

Constructor & Destructor Documentation

◆ Rnd()

FT::Util::Rnd::Rnd ( )
private

need a random generator for each core to do multiprocessing

Definition at line 14 of file rnd.cc.

◆ ~Rnd()

FT::Util::Rnd::~Rnd ( )
private

Definition at line 182 of file rnd.cc.

Member Function Documentation

◆ destroy()

void FT::Util::Rnd::destroy ( )
static

Definition at line 33 of file rnd.cc.

◆ gasdev()

float FT::Util::Rnd::gasdev ( )

Definition at line 156 of file rnd.cc.

◆ get_seed()

int FT::Util::Rnd::get_seed ( )
inline

Definition at line 40 of file rnd.h.

◆ initRand()

Rnd * FT::Util::Rnd::initRand ( )
static

Definition at line 23 of file rnd.cc.

◆ operator()() [1/2]

float FT::Util::Rnd::operator() ( )

Definition at line 100 of file rnd.cc.

◆ operator()() [2/2]

float FT::Util::Rnd::operator() ( unsigned  i)

Definition at line 95 of file rnd.cc.

◆ random_choice() [1/2]

template<typename T >
T FT::Util::Rnd::random_choice ( const vector< T > &  v)
inline

return a random element of a vector.

Definition at line 73 of file rnd.h.

◆ random_choice() [2/2]

template<typename T , typename D >
T FT::Util::Rnd::random_choice ( const vector< T > &  v,
const vector< D > &  w 
)
inline

return a weighted random element of a vector

Definition at line 85 of file rnd.h.

◆ rnd_dbl()

float FT::Util::Rnd::rnd_dbl ( float  min = 0.0,
float  max = 1.0 
)

Definition at line 89 of file rnd.cc.

◆ rnd_flt()

float FT::Util::Rnd::rnd_flt ( float  min = 0.0,
float  max = 1.0 
)

Definition at line 83 of file rnd.cc.

◆ rnd_int()

int FT::Util::Rnd::rnd_int ( int  lowerLimit,
int  upperLimit 
)

Definition at line 77 of file rnd.cc.

◆ select_randomly()

template<typename Iter >
Iter FT::Util::Rnd::select_randomly ( Iter  start,
Iter  end 
)
inline

Definition at line 64 of file rnd.h.

◆ set_seed()

void FT::Util::Rnd::set_seed ( int  new_seed)

set seeds for each core's random number generator

Definition at line 41 of file rnd.cc.

◆ shuffle()

template<class RandomAccessIterator >
void FT::Util::Rnd::shuffle ( RandomAccessIterator  first,
RandomAccessIterator  last 
)
inline

Definition at line 53 of file rnd.h.

Member Data Documentation

◆ instance

Rnd * FT::Util::Rnd::instance = NULL
staticprivate

Definition at line 129 of file rnd.h.

◆ rg

vector<std::mt19937> FT::Util::Rnd::rg
private

Definition at line 127 of file rnd.h.

◆ seed

int FT::Util::Rnd::seed
private

Definition at line 131 of file rnd.h.


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