Main MRPT website > C++ reference for MRPT 1.5.7
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 mrpt::math::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 mrpt::math::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 , typename MATRIXLIKE >
void randomNormalMultiDimensionalMany (const MATRIXLIKE &cov, size_t desiredSamples, std::vector< std::vector< T > > &ret)
 Generate multidimensional random samples according to a given covariance matrix. More...
 
template<typename T , typename MATRIXLIKE >
void randomNormalMultiDimensional (const MATRIXLIKE &cov, std::vector< T > &out_result)
 Generate multidimensional random samples according to a given covariance matrix. More...
 
double normalizedGaussian (double *likelihood)
 
double RandomNormal (double mean, double std)
 
uint32_t RandomUniInt ()
 
double RandomUni (const double min, const double max)
 

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 mrpt::math::CMatrixTemplateNumeric or mrpt::math::CMatrixFixedNumeric

See also
matrixRandomUni

Definition at line 345 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 mrpt::math::CMatrixTemplateNumeric or mrpt::math::CMatrixFixedNumeric

See also
matrixRandomNormal

Definition at line 316 of file RandomGenerators.h.

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

◆ normalizedGaussian()

double mrpt::random::normalizedGaussian ( double *  likelihood)

◆ 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 306 of file RandomGenerators.h.

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

Referenced by mrpt::slam::PF_implementation< mrpt::poses::CPose3D, CMonteCarloLocalization3D >::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 372 of file RandomGenerators.h.

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

◆ Randomize() [2/2]

void mrpt::random::Randomize ( )
inline

◆ RandomNormal()

double mrpt::random::RandomNormal ( double  mean,
double  std 
)

◆ randomNormalMultiDimensional() [1/2]

template<typename T >
void mrpt::random::randomNormalMultiDimensional ( const mrpt::math::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 395 of file RandomGenerators.h.

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

◆ randomNormalMultiDimensional() [2/2]

template<typename T , typename MATRIXLIKE >
void mrpt::random::randomNormalMultiDimensional ( const MATRIXLIKE &  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 440 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 mrpt::math::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 413 of file RandomGenerators.h.

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

◆ randomNormalMultiDimensionalMany() [2/2]

template<typename T , typename MATRIXLIKE >
void mrpt::random::randomNormalMultiDimensionalMany ( const MATRIXLIKE &  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 427 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 382 of file RandomGenerators.h.

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

◆ RandomUni()

double mrpt::random::RandomUni ( const double  min,
const double  max 
)

◆ RandomUniInt()

uint32_t mrpt::random::RandomUniInt ( )

◆ 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 359 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 330 of file RandomGenerators.h.

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

Variable Documentation

◆ randomGenerator

CRandomGenerator mrpt::random::randomGenerator

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

Definition at line 23 of file RandomGenerator.cpp.

Referenced by EdgeAdder< mrpt::poses::CPosePDFGaussianInf >::add(), EdgeAdder< mrpt::poses::CPose3DPDFGaussianInf >::add(), mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), atan2_lut_test(), mrpt::hmtslam::CHierarchicalMapMHPartition::computeCoordinatesTransformationBetweenNodes(), mrpt::obs::CActionRobotMovement3D::computeFromOdometry_model6DOF(), mrpt::obs::CActionRobotMovement2D::computeFromOdometry_modelThrun(), mrpt::bayes::CParticleFilterCapable::computeResampling(), mrpt::poses::CPosePDFParticles::copyFrom(), GraphSlamLevMarqTest< my_graph_t >::create_ring_path(), mrpt::opengl::CPolyhedron::CreateRandomPolyhedron(), mrpt::poses::CPoseRandomSampler::do_sample_2D(), mrpt::poses::CPoseRandomSampler::do_sample_3D(), do_test_init_random(), mrpt::poses::CPose3DQuatPDFGaussian::drawManySamples(), mrpt::poses::CPose3DQuatPDFGaussianInf::drawManySamples(), mrpt::poses::CPose3DPDFGaussianInf::drawManySamples(), mrpt::poses::CPosePDFGaussianInf::drawManySamples(), mrpt::poses::CPosePDFGaussian::drawManySamples(), mrpt::poses::CPose3DPDFGaussian::drawManySamples(), mrpt::poses::CPoint2DPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DQuatPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DQuatPDFGaussianInf::drawSingleSample(), mrpt::poses::CPointPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DPDFGaussianInf::drawSingleSample(), mrpt::poses::CPosePDFGaussianInf::drawSingleSample(), mrpt::poses::CPosePDFParticles::drawSingleSample(), mrpt::poses::CPosePDFGaussian::drawSingleSample(), mrpt::poses::CPose3DPDFGaussian::drawSingleSample(), mrpt::poses::CPointPDFSOG::drawSingleSample(), mrpt::obs::CActionRobotMovement2D::drawSingleSample_modelThrun(), mrpt::math::RANSAC_Template< NUMTYPE >::execute(), mrpt::bayes::CParticleFilterCapable::fastDrawSample(), mrpt::obs::CActionRobotMovement2D::fastDrawSingleSample_modelGaussian(), PosePDFGaussTests::generateRandomPose2DPDF(), Pose3DPDFGaussTests::generateRandomPose3DPDF(), Pose3DQuatPDFGaussTests::generateRandomPose3DPDF(), generateRandomSparseMatrix(), mrpt::maps::CBeaconMap::internal_insertObservation(), matrixRandomNormal(), matrixRandomUni(), my_CriticalSections_Multi(), normalizedGaussian(), mrpt::slam::PF_implementation< mrpt::poses::CPose3D, CMonteCarloLocalization3D >::PF_SLAM_aux_perform_one_rejection_sampling_step(), mrpt::slam::PF_implementation< mrpt::poses::CPose3D, CMonteCarloLocalization3D >::PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal(), mrpt::hmtslam::CLSLAM_RBPF_2DLASER::prediction_and_update_pfAuxiliaryPFOptimal(), mrpt::maps::CMultiMetricMapPDF::prediction_and_update_pfOptimalProposal(), random_generator_for_STL(), Randomize(), RandomNormal(), randomNormalMultiDimensional(), randomNormalMultiDimensionalMany(), randomPermutation(), RandomUni(), RandomUniInt(), ransac_data_assoc_run(), mrpt::bayes::CRejectionSamplingCapable< mrpt::poses::CPose2D >::rejectionSampling(), mrpt::poses::CPosePDFParticles::resetAroundSetOfPoses(), mrpt::poses::CPosePDFParticles::resetUniform(), mrpt::slam::CMonteCarloLocalization2D::resetUniformFreeSpace(), mrpt::slam::CRejectionSamplingRangeOnlyLocalization::RS_drawFromProposal(), run_test_pf_localization(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), mrpt::tfest::se2_l2_robust(), mrpt::tfest::se3_l2_robust(), sem_thread_example(), mrpt::maps::CBeaconMap::simulateBeaconReadings(), mrpt::maps::CLandmarksMap::simulateBeaconReadings(), mrpt::kinematics::CVehicleSimulVirtualBase::simulateOneTimeStep(), mrpt::maps::CLandmarksMap::simulateRangeBearingReadings(), mrpt::maps::COccupancyGridMap2D::simulateScanRay(), mrpt::nav::PlannerRRT_SE2_TPS::solve(), TEST(), TEST_F(), thread_example(), mrpt::hmtslam::CHMTSLAM::thread_LSLAM(), mrpt::hmtslam::CHMTSLAM::thread_TBI(), mrpt::math::transform_gaussian_montecarlo(), vectorRandomNormal(), and vectorRandomUni().




Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019