boostorg / boostorg/random

MixMax RNG with variate_generator returns constant values when initialised with seed = 0

Open
#104 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
42
Forks
76
Avg merge
4d 8h
Merged PRs (30d)
5

Description

When the `mixmax` RNG is initialised with a seed of 0 and used with `variate_generator`, repeated calls always produce the same value:

Reproducible example ([here on godbolt](https://godbolt.org/z/jPa87dadY)):

```cpp
#include
#include

int main() {
using boost::normal_distribution;
using boost::random::uniform_real_distribution;
using boost::variate_generator;
using boost::random::mixmax;

mixmax rng(0);
variate_generator > norm_rng(rng, normal_distribution<>(5, 10));
variate_generator > unif_rng(rng, uniform_real_distribution<>(5.0, 10.0));

for (size_t i = 0; i < 5; ++i) {
std::cout << "Normal(5,10): " << norm_rng() << "\n"
<< "Uniform(5,10): " << unif_rng() << "\n";
}
std::cout << std::endl;
return 0;
}
```

Returns:

```
Normal(5,10): 5
Uniform(5,10): 5
Normal(5,10): 5
Uniform(5,10): 5
Normal(5,10): 5
Uniform(5,10): 5
Normal(5,10): 5
Uniform(5,10): 5
Normal(5,10): 5
Uniform(5,10): 5
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.