Skip to content

Alternate Mersenne Twister RNG code is wrong #621

@hollasch

Description

@hollasch

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);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions