Igor Schein on Tue, 29 Jun 2004 18:42:52 +0200


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

Re: seed for random()


On Tue, Jun 29, 2004 at 11:16:19AM -0500, Cliff Bergman wrote:
> 
> Hello,  
> surely this is an FAQ (but I can't find it discussed in the 
> documentation). Is there a way to set the seed in the random number 
> generator so that each time gp is started I'll get a different sequence 
> of random numbers? 

Here's an idea - add the following line in you .gprc:

read "$HOME/.gpsetrand"

Then create a file $HOME/.gpsetrand containing the following line:

setrand(extern("date +%s"))

I am implicitely assuming GNU date command availability, otherwise you
need to use some other Unix command which will give you a unique
number every time, e.g. reading from /dev/random if available, etc.

Igor