Can someone tell me what’s going on with this bit of code using boost’s normal distribution?
boost::mt19937 rng; // A random number generator
boost::normal_distribution<> nd(3.0, 1.0); // mean 3, sigma 1
// Attach the distribution to the random number generator to get a function
// that returns normally distributed variables.
boost::variate_generator<boost::mt19937&,boost::normal_distribution<> > var_nor(rng, nd);
// Use it. But why is function signature different?
double x = var_nor();
I’m confused as to what’s happening with var_nor with its two function signature.
Thanks
Pete
var_norisn’t a function, it’s an object.The first line creates it (passing the rng and distribution as arguments to the constructor).
The second line calls its
operator()member.