Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate Mersenne Twister RNG code is wrong #621

Closed
hollasch opened this issue May 25, 2020 · 0 comments
Closed

Alternate Mersenne Twister RNG code is wrong #621

hollasch opened this issue May 25, 2020 · 0 comments

Comments

@hollasch
Copy link
Collaborator

The alternate RNG proposed in the book (using C++11's std::mt19937 ) is wrong. It's listed as

inline double random_double(double min, double max) {
    static std::uniform_real_distribution<double> distribution(0.0, 1.0);
    static std::mt19937 generator;
    return generator(distribution);
}

but the last line as the items reversed. It should be

inline double random_double(double min, double max) {
    static std::uniform_real_distribution<double> distribution(0.0, 1.0);
    static std::mt19937 generator;
    return distribution(generator);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant