MRPT logo

mrpt::random Namespace Reference

A namespace of pseudo-random numbers genrators of diferent distributions. More...


Functions

double MRPTDLLIMPEXP normalizedGaussian (double *likelihood=NULL)
 Generate a normalized normally distributed pseudo-random number.
double MRPTDLLIMPEXP RandomNormal (double mean=0, double std=1)
 Generate a normally distributed pseudo-random number.
uint32_t MRPTDLLIMPEXP RandomUniInt ()
 Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, in the whole range of 32-bit integers.
double RandomUni (const double &min, const double &max)
 Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.
template<class T >
void matrixRandomUni (CMatrixTemplateNumeric< T > &matrix, const T &unif_min=0, const T &unif_max=1)
 Fills the given matrix with independent, uniformly distributed samples.
template<class T >
void vectorRandomUni (std::vector< T > &v_out, const T &unif_min=0, const T &unif_max=1)
 Fills the given matrix with independent, uniformly distributed samples.
template<class T >
void matrixRandomNormal (CMatrixTemplateNumeric< T > &matrix, const T &mean=0, const T &std=1)
 Fills the given matrix with independent, normally distributed samples.
template<class T >
void vectorRandomNormal (std::vector< T > &v_out, const T &mean=0, const T &std=1)
 Generates a random vector with independent, normally distributed samples.
void MRPTDLLIMPEXP Randomize (const uint32_t &seed)
 Randomize the generators.
void MRPTDLLIMPEXP Randomize ()
template<class T >
void randomPermutation (const std::vector< T > &in_vector, std::vector< T > &out_result)
 Returns a random permutation of a vector: all the elements of the input vector are in the output but at random positions.
template<typename T >
void MRPTDLLIMPEXP randomNormalMultiDimensional (const CMatrixTemplateNumeric< T > &cov, std::vector< T > &out_result)
 Generate multidimensional random samples according to a given covariance matrix.
template<typename T >
void MRPTDLLIMPEXP randomNormalMultiDimensionalMany (const CMatrixTemplateNumeric< T > &cov, size_t desiredSamples, std::vector< std::vector< T > > &ret, std::vector< T > *samplesLikelihoods=NULL)
 Generate a given number of multidimensional random samples according to a given covariance matrix.


Detailed Description

A namespace of pseudo-random numbers genrators of diferent distributions.


Function Documentation

template<class T >
void mrpt::random::matrixRandomNormal ( CMatrixTemplateNumeric< T > &  matrix,
const T &  mean = 0,
const T &  std = 1 
) [inline]

Fills the given matrix with independent, normally distributed samples.

See also:
matrixRandomUni

Definition at line 110 of file RandomGenerators.h.

References mrpt::math::CMatrixTemplate< T >::getColCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), mrpt::math::mean(), and mrpt::math::CMatrixTemplate< T >::set_unsafe().

template<class T >
void mrpt::random::matrixRandomUni ( CMatrixTemplateNumeric< T > &  matrix,
const T &  unif_min = 0,
const T &  unif_max = 1 
) [inline]

Fills the given matrix with independent, uniformly distributed samples.

See also:
matrixRandomNormal

Definition at line 82 of file RandomGenerators.h.

References mrpt::math::CMatrixTemplate< T >::getColCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), RandomUni(), and mrpt::math::CMatrixTemplate< T >::set_unsafe().

double MRPTDLLIMPEXP mrpt::random::normalizedGaussian ( double *  likelihood = NULL  ) 

Generate a normalized normally distributed pseudo-random number.

Parameters:
likelihood If desired, pass a pointer to a double which will receive the likelihood of the given sample to have been obtained, that is, the value of the normal pdf at the sample value.

Referenced by vectorRandomNormal().

void MRPTDLLIMPEXP mrpt::random::Randomize (  ) 

void MRPTDLLIMPEXP mrpt::random::Randomize ( const uint32_t &  seed  ) 

Randomize the generators.

A seed can be providen, or a current-time based seed can be used (default)

double MRPTDLLIMPEXP mrpt::random::RandomNormal ( double  mean = 0,
double  std = 1 
)

Generate a normally distributed pseudo-random number.

Parameters:
mean The mean value of desired normal distribution
std The standard deviation value of desired normal distribution

template<typename T >
void MRPTDLLIMPEXP mrpt::random::randomNormalMultiDimensional ( const CMatrixTemplateNumeric< T > &  cov,
std::vector< T > &  out_result 
) [inline]

Generate multidimensional random samples according to a given covariance matrix.

Exceptions:
std::exception On invalid covariance matrix
See also:
randomNormalMultiDimensionalMany

template<typename T >
void MRPTDLLIMPEXP mrpt::random::randomNormalMultiDimensionalMany ( const CMatrixTemplateNumeric< T > &  cov,
size_t  desiredSamples,
std::vector< std::vector< T > > &  ret,
std::vector< T > *  samplesLikelihoods = NULL 
) [inline]

Generate a given number of multidimensional random samples according to a given covariance matrix.

Parameters:
cov The covariance matrix where to draw the samples from.
desiredSamples The number of samples to generate.
samplesLikelihoods If desired, set to a valid pointer to a vector, where it will be stored the likelihoods of having obtained each sample: the product of the gaussian-pdf for each independent variable.
ret The output list of samples
Exceptions:
std::exception On invalid covariance matrix
See also:
randomNormalMultiDimensional

template<class T >
void mrpt::random::randomPermutation ( const std::vector< T > &  in_vector,
std::vector< T > &  out_result 
) [inline]

Returns a random permutation of a vector: all the elements of the input vector are in the output but at random positions.

Definition at line 143 of file RandomGenerators.h.

double mrpt::random::RandomUni ( const double &  min,
const double &  max 
) [inline]

Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.

This function uses internally RandomUniInt to generate the number, then scales it to the desired range. Since MRPT 0.6.0 the MT19937 algorithm is used instead of C runtime library "rand" version. See: http://en.wikipedia.org/wiki/Mersenne_twister

See also:
RandomUniInt, Randomize

Definition at line 72 of file RandomGenerators.h.

References RandomUniInt().

Referenced by matrixRandomUni(), mrpt::bayes::CRejectionSamplingCapable< poses::CPose2D >::rejectionSampling(), and vectorRandomUni().

uint32_t MRPTDLLIMPEXP mrpt::random::RandomUniInt (  ) 

Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, in the whole range of 32-bit integers.

See: http://en.wikipedia.org/wiki/Mersenne_twister

See also:
RandomUni, Randomize

Referenced by RandomUni().

template<class T >
void mrpt::random::vectorRandomNormal ( std::vector< T > &  v_out,
const T &  mean = 0,
const T &  std = 1 
) [inline]

Generates a random vector with independent, normally distributed samples.

See also:
matrixRandomUni

Definition at line 124 of file RandomGenerators.h.

References mrpt::math::mean(), and normalizedGaussian().

template<class T >
void mrpt::random::vectorRandomUni ( std::vector< T > &  v_out,
const T &  unif_min = 0,
const T &  unif_max = 1 
) [inline]

Fills the given matrix with independent, uniformly distributed samples.

See also:
vectorRandomNormal

Definition at line 96 of file RandomGenerators.h.

References RandomUni().




Page generated by Doxygen 1.5.9 for MRPT 0.6.5 SVN:exported at Thu May 21 04:14:55 UTC 2009