swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
      Other Library Functions  
function  

random.set-seed

 
 

Library: Math, Random number utilities (OMRANDOM)
Import: omrandom.xmd

Declaration

  define external function random.set-seed
      to value integer seed


Purpose

This function provides a seed to prime the random number generator. Different seed values will produce different sequences of numbers.

By using the same seed for each run, the sequence of pseudo-random numbers can be kept the same. If the application is using random numbers to perform some kind of simulation, the simulation can be repeated by supplying the same seed.

This program will generate a different sequence of numbers each time, because the seed is always different:

  import "omutil.xmd" prefixed by util.
  import "omrandom.xmd" prefixed by random.

  process
     local integer seed initial {util.millisecond-time}

     output "The seed is: %d(seed)%n"
     random.set-seed to seed
     repeat for integer i to 100
        output "d" % i || ". " || "d" % random.uniform || "%n"
     again

This program will generate the same sequence of numbers each time, because the seed is always 12345:

  import "omrandom.xmd" prefixed by random.

  process
     local integer seed initial {12345}

     output "The seed is: %d(seed)%n"
     random.set-seed to seed
     repeat for integer i to 100
        output "d" % i || ". " || "d" % random.uniform || "%n"
     again

        Other Library Functions
   random.exponential
   random.omrandom-version
   random.set-seed
   random.uniform
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:42 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.