- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posting this question on behalf of maadi ( copied from http://software.intel.com/en-us/articles/thread-safety-issue-for-random_number-intrinsic/?wapkw=(random+number)#comment-62387 ) :
I am running Monte Carlo simulation and I have to run 1 million replications.
I have to run simulations simultaneously and using "Call Random_seed " to change my random seed and using command "Call random_number()" to generate random numbers.
I have noticed that when I run 20 simulations simultaneously I get some repeated results. This problem is because same random numbers are generated.
How I can resolve this problem?
I am using IVF11 with windows.
I appreciate your help
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By simultaneously, do you mean in separate jobs, or multiple threads within one job?
The fix described in the KB article means that if you set a single random seed in serial code, and then call random_number from within a parallel region, you should not see the same random number in different threads.
If you are running multiple jobs, then you need to set separate, different random number seeds for each job. (and these seeds shouldnt be generated by calling the same random generator). The execution of one job should not have any impact on the execution of another job at the same time. The implementation of RANDOM_NUMBER in the Intel Fortran RTL has a period of roughly 10**18, before you get back to where you started. But if you choose 10**6 random seeds, that doesnt mean you can get 10**12 random numbers before you start to see the same random numbers in multiple streams. You would need to do a calculation using Poisson statistics, but I speculate that if the seeds were truly randomly chosen, on average there would be one pair that was separated by only about 10**6 random numbers in the stream, so that you would typically start to get some duplication of sequences after about 10**6 random number calls. If the seeds arent themselves random, then it depends how you choose them.
Random number generation for parallel processing is a complex topic, with an extensive literature, try a web search. A variety of more sophisticated generators is available. You might take a look at SPRNG, http://sprng.cs.fsu, for example. Other readers may have additional suggestions.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page