c++11 - c++ normal_distribution gives different results on different platforms -
this
std::mt19937 gen(123); std::normal_distribution<> distr(0., .2); printf("%f", distr(gen));
prints 0.339167
on osx 10.9 machine (built clang 3.5) prints -0.113922
on linux box (gcc 4.8). expecting see same results everywhere.
when inspecting underlying stream mt19937, see consistent sequence of numbers on both platforms. appears platform inconsistency in std::normal_distribution.
is expected behavior? there way can set guaranteed same results everywhere?
std::mt19937
, siblings specific algorithms. standard requires e.g. the 10000th consecutive invocation of default-constructed object of type mt19937 shall produce value 4123659995. there's no wiggle room here.
std::normal_distribution
, siblings, contrast, required produce results distributed according probability density function. there no requirement them specific function.
c++11 random
No comments:
Post a Comment