Main MRPT website > C++ reference
MRPT logo
Classes | Functions | Variables
mrpt::random Namespace Reference

Detailed Description

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

The central class in this namespace is mrpt::random::CRandomGenerator

Classes

class  CRandomGenerator
 A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator. More...
 

Functions

ptrdiff_t random_generator_for_STL (ptrdiff_t i)
 A random number generator for usage in STL algorithms expecting a function like this (eg, random_shuffle): More...
 
template<class MAT >
void matrixRandomUni (MAT &matrix, const double unif_min=0, const double unif_max=1)
 Fills the given matrix with independent, uniformly distributed samples. More...
 
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. More...
 
template<class MAT >
void matrixRandomNormal (MAT &matrix, const double mean=0, const double std=1)
 Fills the given matrix with independent, normally distributed samples. More...
 
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. More...
 
void Randomize (const uint32_t seed)
 Randomize the generators. More...
 
void 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. More...
 
template<typename T >
void randomNormalMultiDimensional (const CMatrixTemplateNumeric< T > &cov, std::vector< T > &out_result)
 Generate multidimensional random samples according to a given covariance matrix. More...
 
template<typename T >
void 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. More...
 
template<typename T , size_t N>
void randomNormalMultiDimensionalMany (const CMatrixFixedNumeric< T, N, N > &cov, size_t desiredSamples, std::vector< std::vector< T > > &ret)
 Generate multidimensional random samples according to a given covariance matrix. More...
 
template<typename T , size_t N>
void randomNormalMultiDimensional (const CMatrixFixedNumeric< T, N, N > &cov, std::vector< T > &out_result)
 Generate multidimensional random samples according to a given covariance matrix. More...
 

Variables

BASE_IMPEXP CRandomGenerator randomGenerator
 A static instance of a CRandomGenerator class, for use in single-thread applications. More...
 

Function Documentation

◆ matrixRandomNormal()

template<class MAT >
void mrpt::random::matrixRandomNormal ( MAT &  matrix,
const double  mean = 0,
const double  std = 1 
)

Fills the given matrix with independent, normally distributed samples.

Matrix classes can be CMatrixTemplateNumeric or CMatrixFixedNumeric

See also
matrixRandomUni

Definition at line 347 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::drawGaussian1D_normalized(), mean(), and randomGenerator.

◆ matrixRandomUni()

template<class MAT >
void mrpt::random::matrixRandomUni ( MAT &  matrix,
const double  unif_min = 0,
const double  unif_max = 1 
)

Fills the given matrix with independent, uniformly distributed samples.

Matrix classes can be CMatrixTemplateNumeric or CMatrixFixedNumeric

See also
matrixRandomNormal

Definition at line 318 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::drawUniform(), and randomGenerator.

◆ random_generator_for_STL()

ptrdiff_t mrpt::random::random_generator_for_STL ( ptrdiff_t  i)
inline

A random number generator for usage in STL algorithms expecting a function like this (eg, random_shuffle):

Definition at line 308 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::drawUniform32bit(), and randomGenerator.

Referenced by mrpt::slam::PF_implementation< CPose2D, CMonteCarloLocalization2D >::PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal().

◆ Randomize() [1/2]

void mrpt::random::Randomize ( const uint32_t  seed)
inline

Randomize the generators.

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

Definition at line 374 of file RandomGenerators.h.

References randomGenerator, and mrpt::random::CRandomGenerator::randomize().

◆ Randomize() [2/2]

void mrpt::random::Randomize ( )
inline

◆ randomNormalMultiDimensional() [1/2]

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

Generate multidimensional random samples according to a given covariance matrix.

Exceptions
std::exceptionOn invalid covariance matrix
See also
randomNormalMultiDimensionalMany

Definition at line 397 of file RandomGenerators.h.

References mrpt::math::cov(), mrpt::random::CRandomGenerator::drawGaussianMultivariate(), and randomGenerator.

◆ randomNormalMultiDimensional() [2/2]

template<typename T , size_t N>
void mrpt::random::randomNormalMultiDimensional ( const CMatrixFixedNumeric< T, N, N > &  cov,
std::vector< T > &  out_result 
)

Generate multidimensional random samples according to a given covariance matrix.

Exceptions
std::exceptionOn invalid covariance matrix
See also
randomNormalMultiDimensionalMany

Definition at line 442 of file RandomGenerators.h.

References mrpt::math::cov(), mrpt::random::CRandomGenerator::drawGaussianMultivariate(), and randomGenerator.

◆ randomNormalMultiDimensionalMany() [1/2]

template<typename T >
void mrpt::random::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.

Parameters
covThe covariance matrix where to draw the samples from.
desiredSamplesThe number of samples to generate.
samplesLikelihoodsIf 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.
retThe output list of samples
Exceptions
std::exceptionOn invalid covariance matrix
See also
randomNormalMultiDimensional

Definition at line 415 of file RandomGenerators.h.

References mrpt::math::cov(), mrpt::random::CRandomGenerator::drawGaussianMultivariateMany(), and randomGenerator.

◆ randomNormalMultiDimensionalMany() [2/2]

template<typename T , size_t N>
void mrpt::random::randomNormalMultiDimensionalMany ( const CMatrixFixedNumeric< T, N, N > &  cov,
size_t  desiredSamples,
std::vector< std::vector< T > > &  ret 
)

Generate multidimensional random samples according to a given covariance matrix.

Exceptions
std::exceptionOn invalid covariance matrix
See also
randomNormalMultiDimensional

Definition at line 429 of file RandomGenerators.h.

References mrpt::math::cov(), mrpt::random::CRandomGenerator::drawGaussianMultivariateMany(), and randomGenerator.

◆ randomPermutation()

template<class T >
void mrpt::random::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.

Definition at line 384 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::permuteVector(), and randomGenerator.

◆ vectorRandomNormal()

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

Generates a random vector with independent, normally distributed samples.

See also
matrixRandomUni

Definition at line 361 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::drawGaussian1D_normalized(), mean(), and randomGenerator.

◆ vectorRandomUni()

template<class T >
void mrpt::random::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.

See also
vectorRandomNormal

Definition at line 332 of file RandomGenerators.h.

References mrpt::random::CRandomGenerator::drawUniform(), and randomGenerator.

Variable Documentation

◆ randomGenerator

BASE_IMPEXP CRandomGenerator mrpt::random::randomGenerator



Page generated by Doxygen 1.8.14 for MRPT 1.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo