boost normal_distribution
I search the boost site and google for a way to use this thing but I cant figure it out. operate() returns the gaussian number but its a template that needs some UniformRandomGenerator. anyone know how to use this?
It is not a function "operate()", but an operator overload "operator()". That is, you "call" the object as if it were a function. It is templated, meaning that it accepts (in theory) an argument of any type that supports the operations that the function implementation does with it; the name 'UniformRandomGenerator' is meant to indicate what operations it needs to provide, and what they should do. In this case, you're expected to provide a callable thing (either another object with an operator() overload, or a (non-member or static member) function pointer) to return a random number with a uniform distribution. Plain old std::rand() will do this, as will some other Boost widgets (which will do it "better" - i.e. more random).
Actually, I guessed almost all of that, but that's how these kinds of things normally are designed :)
Actually, I guessed almost all of that, but that's how these kinds of things normally are designed :)
yea I was thinking about using rand() but I thought I saw somewhere where it looked like it wouldnt accept a function pointer..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement