MRPT  2.0.4
Classes | Functions
mrpt::random Namespace Reference

Detailed Description

A namespace of pseudo-random numbers generators 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...
 
class  Generator_MT19937
 Portable MT19937 random generator, C++11 UniformRandomBitGenerator compliant. More...
 

Functions

template<class RandomIt , class URBG >
void shuffle (RandomIt first, RandomIt last, URBG &&g)
 Uniform shuffle a sequence. More...
 
template<class RandomIt >
void shuffle (RandomIt first, RandomIt last)
 Uniform shuffle a sequence. More...
 
CRandomGeneratorgetRandomGenerator ()
 A static instance of a CRandomGenerator class, for use in single-thread applications. More...
 
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 , typename MATRIX >
void randomNormalMultiDimensionalMany (const MATRIX &cov, size_t desiredSamples, std::vector< std::vector< T >> &ret, std::vector< T > *samplesLikelihoods=nullptr)
 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 MATRIX >
void randomNormalMultiDimensional (const MATRIX &cov, std::vector< T > &out_result)
 Generate multidimensional random samples according to a given covariance matrix. More...
 

Function Documentation

◆ getRandomGenerator()

CRandomGenerator & mrpt::random::getRandomGenerator ( )

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

Definition at line 89 of file RandomGenerator.cpp.

References randomGenerator.

Referenced by GraphSlamLevMarqTest< my_graph_t >::addEdge(), 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::apps::MonteCarloLocalization_Base::do_pf_localization(), mrpt::poses::CPoseRandomSampler::do_sample_2D(), mrpt::poses::CPoseRandomSampler::do_sample_3D(), do_test_init_random(), mrpt::poses::CPose3DQuatPDFGaussianInf::drawManySamples(), mrpt::poses::CPose3DQuatPDFGaussian::drawManySamples(), mrpt::poses::CPose3DPDFGaussianInf::drawManySamples(), mrpt::poses::CPosePDFGaussian::drawManySamples(), mrpt::poses::CPose3DPDFGaussian::drawManySamples(), mrpt::poses::CPosePDFGaussianInf::drawManySamples(), mrpt::poses::CPoint2DPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DQuatPDFGaussianInf::drawSingleSample(), mrpt::poses::CPose3DQuatPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DPDFGaussianInf::drawSingleSample(), mrpt::poses::CPosePDFGaussian::drawSingleSample(), mrpt::poses::CPosePDFParticles::drawSingleSample(), mrpt::poses::CPointPDFGaussian::drawSingleSample(), mrpt::poses::CPose3DPDFGaussian::drawSingleSample(), mrpt::poses::CPosePDFGaussianInf::drawSingleSample(), mrpt::poses::CPointPDFSOG::drawSingleSample(), mrpt::obs::CActionRobotMovement2D::drawSingleSample_modelThrun(), mrpt::math::RANSAC_Template< NUMTYPE, DATASET, MODEL >::execute(), mrpt::bayes::CParticleFilterCapable::fastDrawSample(), mrpt::obs::CActionRobotMovement2D::fastDrawSingleSample_modelGaussian(), fillImagePseudoRandom(), PosePDFGaussTests::generateRandomPose2DPDF(), Pose3DPDFGaussTests::generateRandomPose3DPDF(), Pose3DQuatPDFGaussTests::generateRandomPose3DPDF(), generateRandomSparseMatrix(), mrpt::maps::CBeaconMap::internal_insertObservation(), matrixRandomNormal(), matrixRandomUni(), mrpt::slam::PF_implementation< mrpt::math::TPose3D, CMonteCarloLocalization3D, mrpt::bayes::particle_storage_mode::VALUE >::PF_SLAM_aux_perform_one_rejection_sampling_step(), mrpt::slam::PF_implementation< mrpt::math::TPose3D, CMonteCarloLocalization3D, mrpt::bayes::particle_storage_mode::VALUE >::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(), randomNormalMultiDimensional(), randomNormalMultiDimensionalMany(), randomPermutation(), ransac_data_assoc_run(), mrpt::bayes::CRejectionSamplingCapable< CPose2D >::rejectionSampling(), mrpt::poses::CPosePDFParticles::resetAroundSetOfPoses(), mrpt::poses::CPose3DPDFParticles::resetUniform(), mrpt::poses::CPosePDFParticles::resetUniform(), mrpt::slam::CMonteCarloLocalization2D::resetUniformFreeSpace(), mrpt::slam::CRejectionSamplingRangeOnlyLocalization::RS_drawFromProposal(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::apps::RBPF_SLAM_App_Base::run(), run_test_pf_localization(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), mrpt::tfest::se2_l2_robust(), mrpt::tfest::se3_l2_robust(), 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(), mrpt::hmtslam::CHMTSLAM::thread_LSLAM(), mrpt::hmtslam::CHMTSLAM::thread_TBI(), mrpt::math::transform_gaussian_montecarlo(), vectorRandomNormal(), and vectorRandomUni().

Here is the caller graph for this function:

◆ 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::CMatrixDynamic or mrpt::math::CMatrixFixed

See also
matrixRandomUni

Definition at line 450 of file RandomGenerators.h.

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

Here is the call graph for this function:

◆ 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::CMatrixDynamic or mrpt::math::CMatrixFixed

See also
matrixRandomNormal

Definition at line 423 of file RandomGenerators.h.

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

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

Referenced by fillImagePseudoRandom(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Randomize() [2/2]

void mrpt::random::Randomize ( )
inline

Definition at line 479 of file RandomGenerators.h.

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

Here is the call graph for this function:

◆ randomNormalMultiDimensional()

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

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

Here is the call graph for this function:

◆ randomNormalMultiDimensionalMany() [1/2]

template<typename T , typename MATRIX >
void mrpt::random::randomNormalMultiDimensionalMany ( const MATRIX &  cov,
size_t  desiredSamples,
std::vector< std::vector< T >> &  ret,
std::vector< T > *  samplesLikelihoods = nullptr 
)

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

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020