g2o
Loading...
Searching...
No Matches
g2o::Sampler Class Reference

#include <sampler.h>

Static Public Member Functions

static double gaussRand (double mean, double sigma)
static double uniformRand (double lowerBndr, double upperBndr)
static void seedRand ()
static void seedRand (unsigned int seed)

Detailed Description

Definition at line 83 of file sampler.h.

Member Function Documentation

◆ gaussRand()

double g2o::Sampler::gaussRand ( double mean,
double sigma )
inlinestatic

Gaussian random with a mean and standard deviation. Uses the Polar method of Marsaglia.

Definition at line 89 of file sampler.h.

89 {
90 double y, r2;
91 do {
92 double x = -1.0 + 2.0 * uniformRand(0.0, 1.0);
93 y = -1.0 + 2.0 * uniformRand(0.0, 1.0);
94 r2 = x * x + y * y;
95 } while (r2 > 1.0 || r2 == 0.0);
96 return mean + sigma * y * std::sqrt(-2.0 * log(r2) / r2);
97 }
static double uniformRand(double lowerBndr, double upperBndr)
Definition sampler.h:102
Jet< T, N > log(const Jet< T, N > &f)
Definition jet.h:430

References uniformRand().

Referenced by main(), main(), main(), sample_noise_from_line(), sample_noise_from_plane(), sample_noise_from_se3(), g2o::tutorial::Simulator::sampleTransformation(), and g2o::tutorial::Simulator::simulate().

◆ seedRand() [1/2]

void g2o::Sampler::seedRand ( )
inlinestatic

default seed function using the current time in seconds

Definition at line 109 of file sampler.h.

109 {
110 seedRand(static_cast<unsigned int>(std::time(NULL)));
111 }
static void seedRand()
Definition sampler.h:109

References seedRand().

Referenced by main(), seedRand(), and g2o::tutorial::Simulator::Simulator().

◆ seedRand() [2/2]

void g2o::Sampler::seedRand ( unsigned int seed)
inlinestatic

seed the random number generator

Definition at line 114 of file sampler.h.

114{ std::srand(seed); }

◆ uniformRand()

double g2o::Sampler::uniformRand ( double lowerBndr,
double upperBndr )
inlinestatic

sample a number from a uniform distribution

Definition at line 102 of file sampler.h.

102 {
103 return lowerBndr +
104 ((double)std::rand() / (RAND_MAX + 1.0)) * (upperBndr - lowerBndr);
105 }

Referenced by gaussRand(), main(), main(), main(), g2o::tutorial::Simulator::simulate(), and Sample::uniform().


The documentation for this class was generated from the following file: