Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++. Is it possible that a RNG gives different random variable in two different machines using the same seed?

Tags:

c++

random

gcc

I have this long and complex source code that uses a RNG with a fix seed.

This code is a simulator and the parameters of this simulator are the random values given by this RNG. When I execute the code in the same machine, no matter how many attempts I do the output is the same. But when I execute this code on two different machines and I compare the outputs of both the machines, they are different.

Is it possible that two different machines gives somehow different output using the same random number generator and the same seed?

The compiler version, the libraries and the OS are the same.

like image 625
user57528 Avatar asked Jan 21 '09 13:01

user57528


2 Answers

It is certainly possible, as the RNG may be combining machine specific data with the seed, such as the network card address, to generate the random number. It is basically implementation specific.

like image 161
SmacL Avatar answered Oct 11 '22 09:10

SmacL


As they do give different results it is obviously possible that they give different results. Easy-to-answer question, next!

Seriously: without knowing the source code to the RNG it’s hard to know whether you’re observing a bug or a feature. But it sounds like the RNG in question is using a second seed from somewhere else, e.g. the current time, or some hardware-dependent value like the network card’s MAC address.

like image 24
Bombe Avatar answered Oct 11 '22 08:10

Bombe