[GRASS-dev] r.mapcalc addition

Hamish hamish_nospam at yahoo.com
Mon Oct 23 19:15:11 EDT 2006

Glynn Clements wrote:
> Joel Pitt wrote:
> > It'd be great if someone could commit the attached addition to
> > r.mapcalc
> > 
> > It basically allows one to specify the seed for random number
> > generation by adding a new function "erand(a,b,s)" which takes a and
> > b as the lower and upper limit, and s is a seed that is used to
> > initiate the pseudo random number generator.
> > 
> > This is useful in modelling and simulation so that particular
> > replicates can be rerun exactly.
> > 
> > If it needs any extra work let me know and I'll make the changes.
> I consider this to be the wrong approach. At a minimum, setting the
> seed should be decoupled from the generation of random numbers;
> there's no reason to have what is essentially another copy of
> f_rand().
> Also, it's debatable whether an r.mapcalc function is the correct
> mechanism for setting an operating parameter. An environment variable
> might be more suitable.
> Finally, even if f_erand() was the correct interface, having it call
> f_rand() once the seed has been set is preferable to including a clone
> of f_rand() in the body of f_erand().

what if r.mapcalc's rand(a,b) fn had an optional third argument? ie the
seed. rand(a,b) would work as it currently does, but rand(a,b,seed)
would be available if you wanted it.


More information about the grass-dev mailing list