GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::Random Class Reference

Public Member Functions

 Random (unsigned long long seed=0)
 
 ~Random ()
 
void setSeed (unsigned long long seed=0)
 
int getRandomNumberInt (int minRange, int maxRange)
 
int getRandomNumberWeighted (const vector< int > &values, const vector< double > &weights)
 
int getRandomNumberWeighted (vector< IndexedDouble > weightedValues)
 
int getRandomNumberWeighted (vector< IndexedDouble > &weightedValues, vector< double > &x)
 
double getRandomNumberUniform (double minRange=0.0, double maxRange=1.0)
 
double getRandomNumberGauss (double mu=0.0, double sigma=1.0)
 
VectorDouble getRandomVectorUniform (UINT numDimensions, double minRange=0.0, double maxRange=1.0)
 
VectorDouble getRandomVectorGauss (UINT numDimensions, double mu=0.0, double sigma=1.0)
 
std::vector< unsigned int > getRandomSubset (const unsigned int startRange, const unsigned int endRange, const unsigned int subsetSize)
 

Detailed Description

Definition at line 39 of file Random.h.

Constructor & Destructor Documentation

GRT::Random::Random ( unsigned long long  seed = 0)
inline

Default constructor. Sets the random seed. If no seed is supplied then the seed will be set using the current system time.

Parameters
unsignedlong long seed: sets the current seed, If no seed is supplied then the seed will be set using the current system time

Definition at line 47 of file Random.h.

GRT::Random::~Random ( )
inline

Default destructor.

Definition at line 58 of file Random.h.

Member Function Documentation

double GRT::Random::getRandomNumberGauss ( double  mu = 0.0,
double  sigma = 1.0 
)
inline

Gets a random double, using a Gaussian distribution with mu 0 and sigma 1.0

Parameters
doublemu: the mu parameter for the Gaussian distribution
doublesigma: the sigma parameter for the Gaussian distribution
Returns
returns a double from the Gaussian distribution controlled by mu and sigma

Definition at line 208 of file Random.h.

int GRT::Random::getRandomNumberInt ( int  minRange,
int  maxRange 
)
inline

Gets a random integer in the range [minRange maxRange-1], using a uniform distribution

Parameters
intminRange: the minimum value in the range (inclusive)
intmaxRange: the maximum value in the range (not inclusive)
Returns
returns an integer in the range [minRange maxRange-1]

Definition at line 87 of file Random.h.

double GRT::Random::getRandomNumberUniform ( double  minRange = 0.0,
double  maxRange = 1.0 
)
inline

Gets a random double in the range [minRange maxRange], using a uniform distribution

Parameters
doubleminRange: the minimum value in the range (inclusive)
doublemaxRange: the maximum value in the range (inclusive)
Returns
returns a double in the range [minRange maxRange]

Definition at line 197 of file Random.h.

int GRT::Random::getRandomNumberWeighted ( const vector< int > &  values,
const vector< double > &  weights 
)
inline

Gets a random integer from the vector values. The probability of choosing a specific integer from the values vector is given by the corresponding weight in the weights vector. The size of the values vector must match the size of the weights vector. The weights do not need to sum to 1.

For example, if the input values are: [1 2 3] and weights are: [0.7 0.2 0.1], then the 1 value would be randomly returned 70% of the time, the 2 value returned 20% of the time and the 3 value returned 10% of the time.

Parameters
constvector< int > &values: a vector containing the N possible values the function can return
constvector< double > &weights: the corresponding weights for the values vector (must be the same size as the values vector)
Returns
returns a random integer from the values vector, with a probability relative to the values weight

Definition at line 104 of file Random.h.

int GRT::Random::getRandomNumberWeighted ( vector< IndexedDouble weightedValues)
inline

Gets a random integer from the input vector. The probability of choosing a specific integer is given by the corresponding weight of that value. The weights do not need to sum to 1.

For example, if the input values are: [{1 0.7},{2 0.2}, {3 0.1}], then the 1 value would be randomly returned 70% of the time, the 2 value returned 20% of the time and the 3 value returned 10% of the time.

Parameters
vector<IndexedDouble > weightedValues: a vector of IndexedDouble values, the (int) indexs represent the value that will be returned while the (double) values represent the weight of choosing that specific index
Returns
returns a random integer from the values vector, with a probability relative to the values weight

Definition at line 128 of file Random.h.

int GRT::Random::getRandomNumberWeighted ( vector< IndexedDouble > &  weightedValues,
vector< double > &  x 
)
inline

This function is similar to the getRandomNumberWeighted(vector< IndexedDouble > weightedValues), with the exception that the user needs to sort the weightedValues vector and create the accumulated lookup table (x). This is useful if you need to call the same function multiple times on the same weightedValues, allowing you to only sort and build the loopup table once.

Gets a random integer from the input vector. The probability of choosing a specific integer is given by the corresponding weight of that value. The weights do not need to sum to 1.

For example, if the input values are: [{1 0.7},{2 0.2}, {3 0.1}], then the 1 value would be randomly returned 70% of the time, the 2 value returned 20% of the time and the 3 value returned 10% of the time.

Parameters
vector<IndexedDouble > &weightedValues: a sorted vector of IndexedDouble values, the (int) indexs represent the value that will be returned while the (double) values represent the weight of choosing that specific index
vector<double > &x: a vector containing the accumulated lookup table
Returns
returns a random integer from the values vector, with a probability relative to the values weight

Definition at line 172 of file Random.h.

std::vector< unsigned int > GRT::Random::getRandomSubset ( const unsigned int  startRange,
const unsigned int  endRange,
const unsigned int  subsetSize 
)
inline

Gets an N-dimensional vector of random unsigned ints drawn from the range controlled by the start and end range parameters.

Parameters
constunsigned int startRange: indicates the start of the range the random subset will selected from (e.g. 0)
constunsigned int endRange: indicates the end of the range the random subset will selected from (e.g. 100)
constunsigned int subsetSize: controls the size of the vector returned by the function (e.g. 50
Returns
returns a vector of unsigned ints selected from the

Definition at line 267 of file Random.h.

VectorDouble GRT::Random::getRandomVectorGauss ( UINT  numDimensions,
double  mu = 0.0,
double  sigma = 1.0 
)
inline

Gets an N-dimensional vector of random doubles drawn from the Gaussian distribution controlled by mu and sigma.

Parameters
UINTnumDimensions: the size of the vector you require
doublemu: the mu parameter for the Gaussian distribution
doublesigma: the sigma parameter for the Gaussian distribution
Returns
returns a vector of doubles drawn from the Gaussian distribution controlled by mu and sigma

Definition at line 251 of file Random.h.

VectorDouble GRT::Random::getRandomVectorUniform ( UINT  numDimensions,
double  minRange = 0.0,
double  maxRange = 1.0 
)
inline

Gets an N-dimensional vector of random doubles drawn from the uniform distribution set by the minRange and maxRange.

Parameters
UINTnumDimensions: the size of the vector you require
doubleminRange: the minimum value in the range (inclusive)
doublemaxRange: the maximum value in the range (inclusive)
Returns
returns a vector of doubles drawn from the uniform distribution set by the minRange and maxRange

Definition at line 235 of file Random.h.

void GRT::Random::setSeed ( unsigned long long  seed = 0)
inline

Sets the current seed used to compute the random distrubutions.

Parameters
unsignedlong long seed: sets the current seed, If no seed is supplied then the seed will be set using the current system time
Returns
returns void

Definition at line 67 of file Random.h.


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