2
$\begingroup$

I want to generate low-discrepancy sequences and for that purpose I use SeedRandom[], like:

BlockRandom[
   SeedRandom[(* ..., *) Method -> {"MKL", Method -> {"Sobol", "Dimenstion"->2}}];
RandomReal[1,10]]

The problem is that RandomReal[] returns the same sequence always as if I set the seed to some fixed number.

My question is: what should I put as argument to SeedRandom[] in order to restore the default behaviour or how could I change the method without affecting the way the generator is seeded ?

EDIT: One work-around would be to calculate a bunch of seeds with, say, seeds = RandomInteger[2^32] before calling SeedRandom[] for the 1st time and subsequently feed them to the latter.

$\endgroup$
5
  • 1
    $\begingroup$ "The problem is that RandomReal[] returns the same sequence always as if I set the seed to some fixed number." — Isn't that the whole point of using BlockRandom/SeedRandom? Why are you using them if you do not want the same sequence? $\endgroup$
    – rm -rf
    Oct 26, 2013 at 17:13
  • $\begingroup$ Hm? I use SeedRandom[] to change the method of how random numbers are generated and BlockRandom[] to not affect the generator in the rest of my notebook. $\endgroup$
    – stathisk
    Oct 26, 2013 at 17:21
  • $\begingroup$ Can't you remove the SeedRandom option completely? $\endgroup$
    – bill s
    Oct 26, 2013 at 17:34
  • $\begingroup$ Not really since I don't know any other way to change the method of random number generation. $\endgroup$
    – stathisk
    Oct 26, 2013 at 18:40
  • $\begingroup$ Try BlockRandom[SeedRandom[Method -> ...]; SeedRandom[]; ...]. The second SeedRandom resets the seed using the time of day. $\endgroup$
    – Michael E2
    Oct 27, 2013 at 15:34

2 Answers 2

1
$\begingroup$

If you put SeedRandom[], the seed will be reset using the time of day. This gives a new starting point to the random generator at the time of execution. One can use SeedRandom[Method -> ...] to set the method first, if desired.

Example:

BlockRandom[
  SeedRandom[Method -> {"MKL", Method -> {"Sobol", "Dimension"->2}}];
  SeedRandom[];
  RandomReal[1,10]]
$\endgroup$
2
$\begingroup$

You can use SeedRandom without the first argument to change the method (without changing the way it is seeded) by specifying only the Method (and not the actual seed). For example:

SeedRandom[Method -> "Congruential"]
RandomReal[{0, 1}, {10, 10}]

SeedRandom[Method -> "ExtendedCA"]
RandomReal[{0, 1}, {10, 10}]
$\endgroup$
1
  • $\begingroup$ That would work unless I enclose it into a BlockRandom[] construct. $\endgroup$
    – stathisk
    Oct 27, 2013 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.