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

random.set-seed

 
 

Library: 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
 
 

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

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.