Summary
###########################################################################
File: random.icn
Subject: Procedures related to random numbers
Authors: Ralph E. Griswold and Gregg M. Townsend
Date: May 15, 2000
###########################################################################
This file is in the public domain.
###########################################################################
This file contains procedures related to pseudo-random numbers.
rand_num() is a linear congruential pseudo-random number
generator. Each time it is called, it produces
another number in the sequence and also assigns it
to the global variable random. With no arguments,
rand_num() produces the same sequence(s) as Icon's
built-in random-number generator. Arguments can be
used to get different sequences.
The global variable random serves the same role that
&random does for Icon's built-in random number
generator.
rand_int(i) produces a randomly selected integer in the range 1
to i. It models ?i for positive i.
randomize() sets &random to a "random" value, based on the time
of day and the date.
randrange(min, max)
produces random number in the range min <= i <= max.
randrangeseq(i, j)
generates the integers from i to j in random order.
randseq(seed) generates the values of &random, starting at seed,
that occur as the result of using ?x.
rng(a, c, m, x) generates a sequence of numbers using the linear
congruence method. With appropriate parameters, the
result is a pseudo-random sequence. The default
values produce the sequence used in Icon.
shuffle(x) shuffles the elements of x
###########################################################################
Links: factors
###########################################################################
Procedures:
rand_int, rand_num, randomize, randrange, randrangeseq, randseq, rng, shuffle
Global variables:
random
Links:
factors.icn
This file is part of the (main) package.
Source code.
rand_int(i)
: model ?i
rand_num(a_, c_, m_)
: random number generator
randomize()
: randomize
randrange(min, max)
: random number in range
randrangeseq(i, j)
: random sequence in range
randseq(seed)
: generate &random
rng(a, c, m, x)
: random number generator
shuffle(x)
: shuffle
random
This page produced by UniDoc on 2021/04/15 @ 23:59:54.