[GAP Forum] RandomMat with really random source

Frank Lübeck frank.luebeck at math.rwth-aachen.de
Tue Jul 29 13:34:07 BST 2014


On Thu, Jul 24, 2014 at 09:57:56AM -0400, J DIXON wrote:
> The original question was: how can you produce a different series of
> "random" elements each time?  Surely in this case it is enough to
> have a procedure (perhaps using RealRandomSource) to produce a new
> seed and then run the standard generator from there?
>         - John Dixon

Dear Forum,

Yes, this is the right suggestion. You just need a session dependent seed
to reset the global random number generator which is used by all
Random-functions in the GAP library. Here is how you can do this:

If you have the IO-package installed put this before your code for which you
want a different random-behaviour in different GAP sessions:

#####################################################################
LoadPackage("io"); # better make sure IO is loaded at startup
Reset(GlobalMersenneTwister,
      Random(RandomSource(IsRealRandomSource, "urandom"), 1, 2^512));;
#####################################################################

Alternatively, you may also find a trick without the IO-package. For
example, on a Linux system you could do:

#####################################################################
Reset(GlobalMersenneTwister,
      Int(Filtered(Concatenation(DirectoryContents("/proc")), IsDigitChar)));;
#####################################################################

We do not do this by default because we believe that having GAP sessions
reproducible, even if they involve some pseudo-random computations, is more
useful for debugging.

With best regards,
   Frank
-- 
///  Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Pontdriesch 14/16,
\\\                    52062 Aachen, Germany
///  E-mail: Frank.Luebeck at Math.RWTH-Aachen.De
\\\  WWW:    http://www.math.rwth-aachen.de/~Frank.Luebeck/



More information about the Forum mailing list