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

random.uniform

 
 

Library: Math, Random number utilities (OMRANDOM)
Import: omrandom.xmd
Return type: Integer
Returns: 

A pseudo-random number


Declaration

  define external integer function random.uniform
     from value integer low    optional
     to   value integer high   optional

Argument definitions

low
The smallest number that can be generated
high
The largest number that can be generated


Purpose

This function returns a pseudo-random number in the given range. If the lower bound is not given, 0 is used. If the higher bound is not given, then random.max-random is used.

This program outputs 10 random numbers between 0 and random.max-random (32767), inclusive:

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

  process
     random.set-seed to util.millisecond-time
     repeat to 10
        output "d" % random.uniform || "%n"
     again

This program outputs 5 random numbers between 1 and 6, inclusive:

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

  process
     random.set-seed to util.millisecond-time
     repeat to 5
        output "d" % random.uniform from 1 to 6 || " "
     again
     output "%n"

In the examples above, random.set-seed uses the millisecond timer value to "prime" the random number generator. This ensures a different sequence of pseudo-random numbers each time the program is run.

The distribution of returned values over the range is uniform. (Each value has the same chance of occurring.)

The difference between the upper and lower bounds should not exceed random.max-random (32767). If it does, not all discrete values in the range may be returned.

    Related Syntax
   random.set-seed
   random.exponential
 
  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.