|
Boost Users : |
From: Kuntz, David A (david.a.kuntz_at_[hidden])
Date: 2004-08-03 17:04:44
> I am instantiating normal_distribution from the random
> library incorrectly and looking for a simple example of how to do it
> correctly.
>
> I compiled, built and ran random_test.cpp and can see
> when I step through the normal_distribution () operator that _r1 and
> _r2 have values < 1.
>
> Here are the relevant excerpts from my incorrect attempt
> at instantiation and calling the () operator:
>
> typedef boost::mt19937 base_generator_type;
>
> boost::uint32_t x = 42u;
> Ideal4045EsmModel::base_generator_type
> base_generator(x);
>
> double randomDrawResult;
>
> boost::normal_distribution<double> boostNormalRand;
>
> boostNormalRand.reset();
>
> randomDrawResult = boostNormalRand(base_generator);
>
> This compiles, builds, and runs, but when I step through
> the normal_distribution () operator, _r1 and _r2 have very large
> positive values, resulting in an attempt to take the log of a
> negative number and an Indefinite value being returned.
>
> I am a relatively inexperienced C++ developer. I have
> built and stepped through random_test.cpp
> (http://www.boost.org/libs/random/random_test.cpp) and can see that
> its gets correct results, but I found it quite difficult to follow. Is
> there anyone out there who could show me a simpler way?
>
> Thanks,
>
> Dave
>
>
>
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net