Jump to content
  • Advertisement
Sign in to follow this  
michael879

boost normal_distribution

This topic is 4507 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
Advertisement
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
yea I was thinking about using rand() but I thought I saw somewhere where it looked like it wouldnt accept a function pointer..

Share this post


Link to post
Share on other sites
ok yea the rand() function may work for normal_distribution but it doesnt work for uniform_distribution because that makes calls to eng.min and eng.max.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!