27 #ifndef G2O_GAUSSIAN_SAMPLER_ 28 #define G2O_GAUSSIAN_SAMPLER_ 31 #include <Eigen/Cholesky> 32 #include <Eigen/StdVector> 47 template <
class SampleType,
class CovarianceType>
61 Eigen::LLT<CovarianceType> cholDecomp;
62 cholDecomp.compute(cov);
63 if (cholDecomp.info()==Eigen::NumericalIssue)
69 for (
int i=0; i<s.size(); i++){
90 x = -1.0 + 2.0 * uniformRand(0.0, 1.0);
91 y = -1.0 + 2.0 * uniformRand(0.0, 1.0);
93 }
while (r2 > 1.0 || r2 == 0.0);
94 return mean + sigma * y * std::sqrt(-2.0 * log(r2) / r2);
102 return lowerBndr + ((double) std::rand() / (RAND_MAX + 1.0)) * (upperBndr - lowerBndr);
109 seedRand(static_cast<unsigned int>(std::time(NULL)));
std::mt19937 * _generator
static double gaussRand(double mean, double sigma)
static void seedRand(unsigned int seed)
SampleType generateSample()
static double uniformRand(double lowerBndr, double upperBndr)
double sampleGaussian(std::mt19937 *generator)
GaussianSampler(bool hasGenerator=true)
void setDistribution(const CovarianceType &cov)
double sampleUniform(double min, double max, std::mt19937 *generator)