I have several runs through the loop and am trying to create a different, but pseudo-random integer in each run. Unfortunately, the first number created is always 0.
Interestingly, this only takes place for generating random integers via std::uniform_int_distribution<int> . If I replace it with std::uniform_real_distribution<double> , I will get the desired behavior.
Are there any special rules for creating a seed, or why is the first generated integer always 0?
Below is a minimal example of my problem:
#include <iostream>
The result is, for example:
run #1: random 1: 0 random 2: 1 random 3: 8 random 4: 5 random 5: 5 run #2 random 1: 0 random 2: 2 random 3: 15 random 4: 9 random 5: 11 run #3 random 1: 0 random 2: 8 random 3: 15 random 4: 28 random 5: 2 run #4 random 1: 0 random 2: 16 random 3: 10 random 4: 15 random 5: 24 run #5 random 1: 0 random 2: 26 random 3: 1 random 4: 42 random 5: 6
source share