# Does SeedRandom give the same set of random numbers across operating systems?

If I use

SeedRandom[12345]
RandomReal[{0,1},100]


I get the same random numbers on two versions of Mathematica: 10.4.1.0 on Windows 10 and 11.1.1.0 on Windows 7.

But does the same seed get the same set of random numbers on OS X and flavors of Linux?

• Yes, the default algorithm is the same since some fairly old version. (A cellular automaton based one.) No, I don't have proof or a reference ready for you :( – Szabolcs Oct 11 '17 at 19:56
• As an example, RandomReal[{0, 1}, 3] with SeedRandom[12345] gives {0.121246, 0.329922, 0.782753} on OS X, mathematica 11.0.0 – egwene sedai Oct 11 '17 at 19:57
• Same on a Raspberry Pi too (which is 32-bit). – Szabolcs Oct 11 '17 at 20:01
• I believe it has been platform independent for many years now, possibly as far back as version 6 or so. – Daniel Lichtblau Oct 11 '17 at 20:47
• Thanks to all. This is good to know. I'll certainly start setting the random number seed in all of my future answers that involve random samples. – JimB Oct 12 '17 at 4:03

Turning Daniels comment into an answer:

Random things with a fixed seed is platform-independent for many versions. The feature is implemented possibly since version 6.

I tested

SeedRandom[12345]
RandomReal[{0, 1}, 3]


with version 11.2 on Linux and get the same output as provided by egwene sedai for OSX with version 11.0

{0.121246, 0.329922, 0.782753}


I've tested this also on version 2.2 on XP 32 bit (1993) and on 11.2 on windows 7 64 bit (2017). They also give same result. I do not have Mathematica version 1.0 to test this on. Version 2.2 did not have RandomReal yet. So had to use loop to generate 3 numbers.

0.214347
0.539981
0.0875722


But also noticed that Random[Real, {0, 1}] gives different random from RandomReal[{0, 1}]

• As an addendum: it is often a good idea to enclose any operations involving seeding in a BlockRandom[], if you're concerned about interfering with the current random stream being used. As a typical example: suppose you are running a long Monte Carlo job, and in the middle of it, you need to generate a few random numbers unrelated to the Monte Carlo operation. You will then need to wrap that quick job in a BlockRandom[] so that the stream being used for the long job remains uninterrupted. – J. M. will be back soon Oct 12 '17 at 13:19
• Older versions with Random will not be fully platform independent. Random may have become platform independent by version 5, I'm not sure. But that involved addressing some issues in 32 vs 64 bit platforms and also in endianness. – Daniel Lichtblau Oct 12 '17 at 17:57
• @Daniel, if memory serves, the current Method -> "Legacy" was the version 5 iteration, and versions before that didn't even have the cellular-automaton method, and just used plain "subtract-with-borrow". – J. M. will be back soon Oct 12 '17 at 20:32
• @j.M. Not quite. A CA was used for some things, I think including machine reals. Somewhat different innards, it used rule 30 and I think the current one uses a different rule. – Daniel Lichtblau Oct 12 '17 at 23:13
• @J.M. Let me emend that. Random used (and probably still uses) rule 30 for machine integers (not reals) and bignum reals. SWB was used for big ints and machine reals. Go figure. – Daniel Lichtblau Oct 13 '17 at 4:04