- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I want to do a Monte Carlo simulation using fortran. But I was confused by random numbers in visual fortran.
Q1
I want to get mass random numbers over [0,1] from RAND() . I wonder how many times should I use the RANDOM_SEED () routine in the whole simulation to get eligible random numbers? Should I use it only once before the first using of RAND()? or using it every time before RAND() being called? Should I call RNISD() (an IMSL routine to change the seed number) when needed? Since the random number is generated frequently? I am worrying the quality of random number.
Q2
Another question is about the IMSL routine, DRNNOA(), which generates a standard normal distribution N(0,1)? The question is similar. How many times should I call RNSET(ISEED) in whole simulation? Does RANDOM_SEED() take effect on the DRNNOA(..) similar to RNSET(..)?
Thank you very much.
James
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Typically, you call RANDOM_SEED just once at the beginning of the program. If you want to get the same numbers on each run, then set the seed explicitly. If you want different numbers on each run, pass no arguments to RANDOM_SEED and it will set the seed based on the date/time.
You can then call RANDOM_NUMBER to get your numbers. The argument can be a scalar or an array if you want multiple values at once.
If you want to use the IMSL routines, do not use RANDOM_SEED. You can use the IMSL routine for setting the seed, and again it would typically be called just once. If you call it multiple times, you will reduce the quality of the distribution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have some problems with rand() function.
1) Whenrand is called without an argument, flag is assumed to be 0 (the next random number in the sequence is selected). But this leads to Access Violation in my program.
2) This code:
USE IFPORT
CALL SEED(RND$TIMESEED)
randval = rand(0)
gives error at compile time: The type of the actual argument differs from the type of the dummy argument. [RND$TIMESEED]
Is this compiler bugs? The version of WFC- 9.1.024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
USE IFPORT
ii = RND$TIMESEED
CALL SEED (ii)
randval = rand(0)
Hans
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page