[GRASS-dev] using rand(x,y) in r.mapcalc (grass7)
Vaclav Petras
wenzeslaus at gmail.com
Tue Jul 22 14:04:45 PDT 2014
On Tue, Jul 22, 2014 at 4:39 PM, Glynn Clements <glynn at gclements.plus.com>
wrote:
>
> Paulo van Breugel wrote:
>
> > And it seems to be the default behaviour by python/numpy:
>
> It is, but ...
>
> > >>> import numpy as np
> > >>> np.random.random()
> > 0.8351426142559701
> > >>> np.random.random()
> > 0.4813823441998394
> > >>> np.random.random()
> > 0.7279314267025369
>
> ... this example doesn't demonstrate that.
Good point, on my computer I get:
>>> import numpy as np
>>> np.random.random()
0.49727844715398417
And in different (also freshly started) Python:
>>> import numpy as np
>>> np.random.random()
0.2457281014919791
Any PRNG returns different
> values for successive calls.
>
> The problem is that user may not see the difference between between two
module calls in GRASS command line and two calls of random() function in
Python. When calling GRASS module in Python the difference is even less
visible.
Anyway, the reproducibility would be really nice considering GRASS
scientific audience, however are you sure that different systems will give
same random number for the same seed? Or do you think about reproducible as
"as reproducible as possible, e.g. using the same system if necessary".
The question is whether the PRNG's initial value should autmatically
> be seeded from some external source of entropy (e.g. the system
> clock), so that the sequence of values differs on different runs.
>
> In turn, that brings up questions about the quality of the entropy
> source. The ANSI C time() function typically only has one second
> granularity (indeed, POSIX requires this, as time_t is defined as
> seconds since the epoch), which is sufficiently course that successive
> runs may get the same seed. Other functions aren't portable, and even
> where available, the granularity isn't guaranteed.
>
> What about time + process id?
> My main objection to automatic seeding is that people will inevitably
> produce non-repeatable results without even realising it.
>
> One possible solution would be to automatically add the seed to the
> history of any map generated by r.mapcalc (or possibly only those
> which use the rand() function). But that would still only help if the
> creator either provides access to the generated maps, or the output
> from r.info. Simply providing the commands used and the end result
> wouldn't help.
>
> --
> Glynn Clements <glynn at gclements.plus.com>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140722/01239a1e/attachment.html>
More information about the grass-dev
mailing list