[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fun with random numbers



Hi,
The bug comes from the unidentification of seed in
the first randomu call of every call of test.pro
The solution is to save the value of seed between
different calls of test.pro
Or you might use common block (Ok, David, I know...) or
a system variable:

PRO test
common seed_for_test,seed

  x= RANDOMU(seed,1)
  y= RANDOMU(seed,4)
  PRINT,'x',x
  PRINT,'y',y

  RETURN

END

or

PRO test
   defsysv,'!seed',EXISTS = seed_exists
   if seed_exists then seed = !seed

   x= RANDOMU(seed,1)
   y= RANDOMU(seed,4)

   defsysv,'!seed',seed

   PRINT,'x',x
   PRINT,'y',y

   RETURN

END







Sent via Deja.com http://www.deja.com/
Before you buy.