Hi
I am using boost/random library in order to create a normal distributed noise.
I want to call my my_class::noise() functions several times, but I want to initialize the generator only once.
I tried to declare and initialize the generator at the constructor of my_class, but then my_class::noise() doesn't recognized the generator.
I wrote it the following way:
my_class::my_class()
{
boost::mt19937 gen(42u);
}
my_class::noise()
{
boost::normal_distribution<
float> n_d(5, 10); //n_d(mean,stdev)
boost::variate_generator<boost::mt19937&, boost::normal_distribution<float> > normal(gen, n_d);
return normal();
}
I guess I need to declare the generator at the header, and only initialize it at the constructor, but I don't know how to do it.
Thanks for your help.
Dvir