Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
1  
"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? –  rm -rf Oct 26 '13 at 17:13
    
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. –  Zet Oct 26 '13 at 17:21
    
Can't you remove the SeedRandom option completely? –  bill s Oct 26 '13 at 17:34
    
Not really since I don't know any other way to change the method of random number generation. –  Zet Oct 26 '13 at 18:40
    
Try BlockRandom[SeedRandom[Method -> ...]; SeedRandom[]; ...]. The second SeedRandom resets the seed using the time of day. –  Michael E2 Oct 27 '13 at 15:34

2 Answers 2

up vote 1 down vote accepted

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]]
share|improve this answer

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}]
share|improve this answer
    
That would work unless I enclose it into a BlockRandom[] construct. –  Zet Oct 27 '13 at 10:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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