Hello, in the gazebo_barometer_plugin.cpp, the noise is generated using polar form of Box-Muller transformation
// generate Gaussian noise sequence using polar form of Box-Muller transformation
double y1;
{
double x1, x2, w;
if (!baro_rnd_use_last_) {
do {
x1 = 2.0 * standard_normal_distribution_(random_generator_) - 1.0;
x2 = 2.0 * standard_normal_distribution_(random_generator_) - 1.0;
w = x1 * x1 + x2 * x2;
} while ( w >= 1.0 );
w = sqrt( (-2.0 * log( w ) ) / w );
// calculate two values - the second value can be used next time because it is uncorrelated
y1 = x1 * w;
baro_rnd_y2_ = x2 * w;
baro_rnd_use_last_ = true;
} else {
// no need to repeat the calculation - use the second value from last update
y1 = baro_rnd_y2_;
baro_rnd_use_last_ = false;
}
}
However, as Wikipedia says, The Box–Muller transform is a random number sampling method for generating pairs of independent, standard, normally distributed given a source of uniformly distributed random numbers. But this code uses standard_normal_distribution_(random_generator_). So I think using standard_normal_distribution_(random_generator_) without using Box–Muller transform is OK.
Hello, in the gazebo_barometer_plugin.cpp, the noise is generated using polar form of Box-Muller transformation
However, as Wikipedia says, The Box–Muller transform is a random number sampling method for generating pairs of independent, standard, normally distributed given a source of uniformly distributed random numbers. But this code uses
standard_normal_distribution_(random_generator_)
. So I think usingstandard_normal_distribution_(random_generator_)
without using Box–Muller transform is OK.