rndseed

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

TimGrun
Posts: 36
Joined: Wed Sep 16, 2009 8:01 am

rndseed

Postby TimGrun » Wed Jun 27, 2012 6:24 am

Hi,

I have a couple of questions about rndseed.
First if the rndseed is not set, then I assume that the time of day is used as the seed. Is the time used in thousandths of a second? I'm running several jobs simultaneously where that would be important.

Second, once the rndseed is set to some scalar, is it possible to reset it back to time of day?
This is important to be able to run multiple jobs simultaneously where each job runs repeatable simulations, but then use utility programs that require unique random numbers between the multiple jobs. (Did I make that confusing enough?)

Thanks,
Tim

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13583
Joined: Tue Sep 16, 2008 5:38 pm

Re: rndseed

Postby EViews Gareth » Wed Jun 27, 2012 7:50 am

Is is based on time of day, yes.

I do not believe there is a way to unseed the RNG. However you could always generate a random integer, then set the rndseed, then, when you need it off, set it again using the random integer you created.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: rndseed

Postby EViews Glenn » Wed Jun 27, 2012 9:22 am

Gareth's suggestion is a fine one, but we probably should offer a way to reset to clock. We'll put it on the list of things to look at.

TimGrun
Posts: 36
Joined: Wed Sep 16, 2009 8:01 am

Re: rndseed

Postby TimGrun » Wed Jun 27, 2012 9:36 am

Thanks Gareth and Glenn for your replies.
The problem with Garath's suggestion is I have an addin that is used by everyone to access our databases. This addin uses files to store the temporary data before reading and writing into eviews. The filenames have to have unique names so there aren't any conflicts when someone is running multiple jobs. The problem with using the RNG is someones program might have set the rndseed before calling the addin, therefore making the filenames not unique.
Another solution is to get the process id to use as part of the filename. EViews doesn't appear to have easy access to the process id, so I'll have to spawn a shell process and then parse the output. :(
In the Perl language the process id is $$. Something like that would be very nice.

Do you guys have any better ideas?

Thanks,
Tim

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13583
Joined: Tue Sep 16, 2008 5:38 pm

Re: rndseed

Postby EViews Gareth » Wed Jun 27, 2012 9:58 am

Shell to DOS random number generator:

Code: Select all

shell(out=t) echo %random%
That gets you outside of EViews' RNG, and thus outside of RNDSEED.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests