Sign in to follow this  

boost normal_distribution

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this