Inconsistent random behavior with same seed value?

I found this quote interesting from the Dreamworld Plus One challenge topic:

So this is harmless in this context.

But some modules repeatedly seed with the same value in an effort to get consistent “random” sequences. So does this mean such modules could be at risk of giving inconsistent behavior when switching platforms?

My Venom Rhythm Explorer uses rack::random::Xoroshiro128Plus. Hopefully this gives consistent results across all platforms.

1 Like

Rack seeds the xorshift like this:

// Get epoch time for seed
	double time = system::getUnixTime();
	uint64_t sec = time;
	uint64_t nsec = std::fmod(time, 1.0) * 1e9;
	rng.seed(sec, nsec);

It isn’t a question of how the RNG is seeded, but rather whether a given seed value produces the exact same pseudo random sequence regardless of platform. Paul reports that the RNG he is using can give different results depending on the platform or library or …

I am thinking/hoping that the RNG I am using always gives the same result for a given seed regardless of platform etc.

The question was clear, apparently the interpretation of my answer wasn’t.

getUnixTime is supposed to be consistent across platforms.

Yes, but that is used to seed the RNG. I give the user the option to provide their own seed, making the method that VCV establishes a default seed moot.

xorshifts are relatively simple to implement, in principle and Rack’s doesn’t do anything fancy: as long as the seed is constant, the results should be as well…

I see your module keeps its own local state, so, results should be consistent, at least from the rng.

In C# I’ve used RNG’s from C-source by George Marsaglia/Bob Wheeler. These are simple and with good distribution. E.g. MWC

public override int Next()
{
    unchecked
    {
        _z = (36969 * (_z & 0x0000FFFF) + (_z >> 16));
        _w = (18000 * (_w & 0x0000FFFF) + (_w >> 16));
        return ((_z << 16) + (_w & 0x0000FFFF)) & 0x7FFFFFFF;
    }
}

Searching for their names you should be able to locate multiple RNG’s. I’ve mostly used KISS which combines MWC and 2 others (SHR3 and CONG). But would say that’s overkill for VCV

EDIT: To seed the MWC simply set _z and _w. I simply used their “default values” (362436069 and 521288629) which I salted with a time based seed:

public RandomMWC()
{
    int timeSeed = GetDateTimeBasedSeedValue();
    _z = 362436069 ^ timeSeed;
    _w = 521288629 ^ timeSeed;
}
1 Like

This is a feature of the generator so if you use a different generator you will get different behavior.