|
Boost Users : |
From: Jeffrey Brent McBeth (mcbeth_at_[hidden])
Date: 2007-04-23 08:20:48
#include <boost/random.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
boost::mt19937 eng;
boost::normal_distribution<> norm(0,1);
std::cout << norm(eng) << std::endl;
}
Gives me a NaN everytime. Looking at the code, it doesn't really surprise
me, as
_r1 = eng();
_r2 = eng();
_cached_rho = sqrt(-result_type(2)*log(result_type(1)-_r2));
would only work if eng were in the range (0,1) with 0 being degenerate, and
1 being undefined.
Looking through the mt19937, that is returning a full UInt32.
Perhaps those two eng() should be replaced by uniform_01?
Jeffrey McBeth
-- ---------------------------------------------------------------------------- Hofstadter's Law states: It always takes longer than you expect, even when you take into account Hofstadter's Law. ----------------------------------------------------------------------------
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