[GRASS-dev] [GRASS GIS] #2272: Improve consistency in random generator usage

GRASS GIS trac at osgeo.org
Sat May 3 23:13:30 PDT 2014


#2272: Improve  consistency in random generator usage
-------------------------+--------------------------------------------------
 Reporter:  neteler      |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  normal       |   Milestone:  7.0.0                    
Component:  Default      |     Version:  svn-releasebranch70      
 Keywords:  random       |    Platform:  Unspecified              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------

Comment(by glynn):

 Replying to [ticket:2272 neteler]:
 > The usage of drand48()/srand48() should be consolitated,
 > perhaps using G_math_rand() which is provided in
 > lib/gmath/rand1.c:

 First, G_math_rand() should be fixed. Currently, it returns a value
 strictly less than 1.0 if drand48 is used, or a value less than or equal
 to 1.0 if rand() is used.

 Also, seeding should be a separate function.

 And we should probably have a portable equivalent to lrand48(), i.e.
 something which returns a non-negative 31-bit integer. The version in
 r.random is broken, as bit 15 will always be zero if RAND_MAX is 32767
 (the minimum value allowed by the ISO C standards).

 My suggestion would be to re-implement the LCG used by lrand48() etc.
 [attachment:lrand48.c Sample implementation]

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2272#comment:1>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list