(j3.2006) RANDOM_INIT question

Malcolm Cohen malcolm
Tue Sep 22 04:06:47 EDT 2015


INTEGER,ALLOCATABLE :: seed(:)
REAL x(10)
CALL RANDOM_INIT(REPEATABLE=.FALSE.) ! Set the seed
CALL RANDOM_SEED(SIZE=N)
ALLOCATE(seed(N))
CALL RANDOM_SEED(GET=seed) ! Get the seed
CALL RANDOM_NUMBER( x )
PRINT *,x
CALL RANDOM_SEED(PUT=seed) ! Reset the seed
CALL RANDOM_NUMBER( x )
PRINT *,x

The standard explicitly states the second set of values is the same as the first set.

This means a PRNG, not a TRNG.  TRNG?s cannot replay sequences!

Yes, replaying sequences is actually used to good effect by real programs.

As for ?any other PRNG?, well, as long as the info returned by SEED= includes all the necessary info to replay the sequence there is no problem; when multiple PRNG?s are in use, that would imply that ?which PRNG? is part of the SEED, even though it would not be part of the ?seed? of any particular PRNG.

(As it happens, NAG does this already ? there is extra info encoded into the seed, both to allow PRNG variation without losing ABI compatibility, and also so we can tell whether we?re replaying or initialising a sequence.)

Cheers, Maru.


From: Keith Bierman 
Sent: Tuesday, September 22, 2015 2:10 PM
To: fortran standards email list for J3 
Subject: Re: (j3.2006) RANDOM_INIT question

For the case with REPEATABLE=.false. how would any meaningful test be able to tell the difference between use of the PRNG generator used in the REPEATABLE=.true. case vs. any other PRNG or the hardware device Bill speaks of?

Keith Bierman
khbkhb at gmail.com
kbiermank AIM
303 997 2749

On Mon, Sep 21, 2015 at 10:13 PM, Bill Long <longb at cray.com> wrote:

  OK.  I?ll keep a copy of this email for future use when questions arise.

  I do think it would be at least a good idea to link what RANDON_INIT does to RANDOM_NUMBER.  In the description of RANDOM_SEED, we specify "The pseudorandom number generator used by RANDOM_NUMBER?.  We should make the ?used by RANDOM_NUMBER? connection in RANDOM_INIT as well.   That would close the loop to connect RANDOM_INIT to the description of RANDOM_SEED where the requirement of the ?same sequence? is stated.

  Cheers,
  Bill



  On Sep 21, 2015, at 7:16 PM, Malcolm Cohen <malcolm at nag-j.co.jp> wrote:

  > <<<
  >  Since ?repeatable?  can be used to describe whether a generator would
  > generate the same sequence given a particular starting seed,  there is
  > possibility of confusion.
  >>>>>
  >
  > There is no confusion in the standard.
  >
  > The actual words in the standard
  > (a) explicitly specify that this is a pseudo-random number generator, not a
  > (scare quotes) "true random" generator;
  > (b) explicitly specify that a particular seed, (actual quote) "shall result
  > in the same sequence of pseudorandom numbers being generated";
  > (c) explicitly specify that REPEATABLE=.FALSE. merely sets the seed (actual
  > quote) "to a processor-dependent, unpredictably different value on each
  > call".
  >
  > There is no ambiguity here!
  >
  > <<<
  >  A Note to say that there is only one generator, and we don?t mean that
  > usage of ?repeatable?,  might be clarifying.
  >>>>
  >
  > We have Already Fully Specified *Precisely* what the effect of the *Argument
  > Whose Name Is "REPEATABLE"* is.
  >
  > In fact we do not use the word "repeatable" ***ANYWHERE IN THE ENTIRE
  > STANDARD***.  Not even once.  Not here, and not anywhere else either.  The
  > argument name is REPEATABLE, that's it.  And I repeat, the semantics are
  > Fully Specified.
  >
  > Such a note, following the text which actually Specifies The Semantics
  > Normatively, would not only be completely unnecessary but also
  > counter-productive.  One might as well word it as "You might think that you
  > can ignore the semantics we've just specified, because you went into an
  > entire imaginary world based on the spelling of the argument name, but you
  > would be wrong."
  >
  > There is simply No Case To Answer here.
  >
  > Grumpily,
  > --
  > ..............................The Editor.
  >
  > _______________________________________________
  > J3 mailing list
  > J3 at mailman.j3-fortran.org
  > http://mailman.j3-fortran.org/mailman/listinfo/j3


  Bill Long                                                                       longb at cray.com
  Fortran Technical Support  &                                  voice:  651-605-9024
  Bioinformatics Software Development                     fax:  651-605-9142
  Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101



  _______________________________________________
  J3 mailing list
  J3 at mailman.j3-fortran.org
  http://mailman.j3-fortran.org/mailman/listinfo/j3



________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________



--------------------------------------------------------------------------------
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150922/a9de82d6/attachment-0001.html 



More information about the J3 mailing list