Have the Random functions changed?
The default random number generation method has changed from version 8 to version 9.
The default methods for version 8 and version 9 are:
PRNG | v8 | v9
-----------------------------------------------------
RandomInteger[] | ExtendedCA | Rule30CA
RandomReal[] | ExtendedCA | Rule30CA
The following does produce the same results for both versions:
methods = {
"Congruential",
"ExtendedCA",
"Legacy",
"MersenneTwister",
"MKL",
"ParallelGenerator",
"ParallelMersenneTwister",
"Rule30CA"
};
Table[BlockRandom[SeedRandom[42, Method -> m];
Print[m <> ": ", RandomInteger[{-9, 9}, 10]];
RandomInteger[{-9, 9}, 10]], {m, methods}];
Congruential: {-9, 0, 3, -7, -9, -3, 5, -1, 7, 4}
ExtendedCA: {4, -5, -7, -8, -3, -9, -5, -6, -1, 3}
Legacy: {9, -9, 0, 5, 7, -5, 9, 8, -1, 0}
MersenneTwister: {7, 6, 5, 2, 0, -3, 4, 4, -1, 8}
MKL: {-5, 2, -8, -3, -3, -5, 1, 1, 3, -5}
ParallelGenerator: {-2, 2, 3, 0, -6, -7, 3, -7, -9, -1}
ParallelMersenneTwister: {-4, -4, -1, -2, 0, -9, 0, -8, -9, -8}
Rule30CA: {9, -9, 0, 5, 7, -5, 9, 8, -1, 0}
If you use the default method, you indeed get different results:
BlockRandom[SeedRandom[42]; RandomInteger[{-9, 9}, 10]]
v8:
{4, -5, -7, -8, -3, -9, -5, -6, -1, 3}
v9:
{9, -9, 0, 5, 7, -5, 9, 8, -1, 0}
If they claim that the default is "ExtendedCA"
, than this is not true for version 9.
For version 9, the default is "Rule30CA"
, while on version 8 it uses "ExtendedCA"
.
So if you want to produce the same random numbers on version 9, you have to explicitly set the method to "ExtendedCA"
.
Incidentally, the reason why "Legacy"
and "Rule30CA"
gave the same results for RandomInteger
is that the legacy method does use the rule 30 generator in the integer case.
Now, let's test if this holds for RandomReal
as well:
Table[BlockRandom[SeedRandom[42, Method -> m];
Print[m <> ": ", InputForm @ RandomReal[10, 10]]], {m, methods}];
Congruential: {3.8461335440024715, 3.354304567149635, 4.51935934053208,
8.850230228014308, 3.6248509154618356, 8.157875428939777,
2.4513895134473387, 5.818949583945838, 4.969467831268059,
0.03347488955145989}
ExtendedCA: {4.259052837159626, 3.910231598741685, 3.4706935350965935,
4.53740630685645, 5.5596334203812, 2.8916925336738952,
2.9684806264504378, 2.064076444638916, 3.251697057830391,
9.733246886114031}
Legacy: {8.9572216046609, 4.970307857530802, 5.435846534404246,
7.085955661473399, 6.776487260106322, 8.054379667584591,
0.7094411741824413, 8.968322445752152, 8.901306909526046,
0.7502088503156987}
MersenneTwister: {5.153950855950999, 0.6727671698455833, 4.524316138874237,
9.921991209186388, 0.5443991248015738, 8.437734478961886,
6.959208913527714, 9.091869760437504, 2.310061068071903,
8.976972757532419}
MKL: {2.2010771720728672, 5.882083584870089, 0.7266383901861087,
3.3726500591458435, 3.3079876451216217, 2.488652193017376,
5.6151582821198005, 5.305289374386305, 6.735427495488978,
2.29022838609706}
ParallelGenerator: {2.8013742426114714, 8.147026088771263, 3.8405810263728526,
2.5308472947817595, 9.400530227458631, 9.054157508803371,
9.449607002369156, 4.3141703917759315, 6.087645635734276,
6.8637216165050745}
ParallelMersenneTwister: {9.999076480701376, 9.830697737962758, 8.382728461259866,
9.292582323124666, 0.487553230365652, 5.914364713788565,
1.6141971841606058, 1.4211558070777137, 9.501590480279376,
2.6447011005402707}
Rule30CA: {5.633636625848604, 0.19140585740303528, 6.149388826993686,
1.9144953965106026, 2.9253076004819345, 0.55162786941208,
1.995816904778028, 9.427477798414383, 0.39607049447435116,
1.8220850707267502}
Both lists are identical between version 8 and version 9.
Let's use the default method for RandomReal
:
v8:
BlockRandom[SeedRandom[42]; InputForm @ RandomReal[10, 10]]
{4.259052837159626, 3.910231598741685, 3.4706935350965935,
4.53740630685645, 5.5596334203812, 2.8916925336738952,
2.9684806264504378, 2.064076444638916, 3.251697057830391,
9.733246886114031}
So the default method for version 8 is "ExtendedCA"
.
v9:
BlockRandom[SeedRandom[42]; InputForm @ RandomReal[10, 10]]
{5.633636625848604, 0.19140585740303528, 6.149388826993686,
1.9144953965106026, 2.9253076004819345, 0.55162786941208,
1.995816904778028, 9.427477798414383, 0.39607049447435116,
1.8220850707267502}
And the default method for version 9 is "Rule30CA"
.
The default random number generation method has been the same for the last 12 years (in terms of releases, since V6).
It has not changed, certainly not between V8 and version V9, or more recently.
Both version 8 and version 9 should be using "ExtendedCA"
as documented.
On my machine, both of the following results are as expected
In[1]:= $Version
(* 9.0 for Linux x86 (64-bit) (November 20, 2012) *)
In[2]:= BlockRandom[SeedRandom[42]; RandomInteger[{-9, 9}, 10]]
(* {4, -5, -7, -8, -3, -9, -5, -6, -1, 3} *)
In[3]:= BlockRandom[SeedRandom[42]; InputForm @ RandomReal[10, 10]]
(* {4.259052837159626, 3.910231598741685, 3.4706935350965935,
4.53740630685645, 5.5596334203812, 2.8916925336738952,
2.9684806264504378, 2.064076444638916, 3.251697057830391, 9.733246886114031} *)
I have tried the other platforms as well.
No idea what was happening in the earlier answer which claims "Rule30CA"
was the default in V9, but it doesn't even seem possible.
I would think either a (mysterious!) bug, or some user initialization code switching the method.