Random Number Generation in Parallelized data step

Reply
Occasional Contributor
Posts: 15

Random Number Generation in Parallelized data step

Hi all

I am using this paper http://support.sas.com/resources/papers/proceedings10/109-2010.pdf to parallelize a data step (which is essentially a do loop simulating something).

I wonder what the best approach is to generate random numbers for the multiple threads. Right now I am initizalizing with different seeds "CALL STREAMINIT(&seed.); " where seed is different for each thread/task.

However this is not optimal since the different paths of the Pseudo-RNG could "coincide" after some time (if I am unlucky). Is there any way to improve this situation? Is there any documentation available on the Mersenne Twister configuration in SAS? I am only relying on  RAND in my code.

Thanks

Bernhard

Valued Guide
Posts: 3,206

Re: Random Number Generation in Parallelized data step

SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition The rand function is mentioning mersenne

Rick Wicklin did a blog on that topic Six reasons you should stop using the RANUNI function to generate random numbers - The DO Loop

---->-- ja karman --<-----
SAS Super FREQ
Posts: 3,413

Re: Random Number Generation in Parallelized data step

Yes, in theory you could get unlucky.  In practice I suspect that the probability of getting two streams that are not independent are extremely small. I haven't run the analysis myself, but other people have done what you are proposing and have not reported any dependencies.

If you want to see the literature in this area, search for articles by Piere L'Ecuyer and colleagues on PRNGs that have  provably independent streams.

Occasional Contributor
Posts: 15

Re: Random Number Generation in Parallelized data step

Thank you Rick.

Ask a Question
Discussion stats
  • 3 replies
  • 216 views
  • 3 likes
  • 3 in conversation