Statistical Functions

EXPRND
MONTECARLO

NORMAL

POISSON

RANDOM

The statistical Builtins generate sequences of random numbers, each conforming to its specific distribution. The statistical functions thus enable you to introduce randomness into your models.

The software will sample from the distribution you have specified, each DT in the model simulation. Unless you have specified a seed for the distribution as a non-negative integer, the sample set drawn from the distribution will not be replicable.

 
EXPRND(<lambda>[,<seed>])

The EXPRND function generates a series of exponentially distributed random numbers with a mean of lambda. EXPRND samples a new random number in each iteration (that is, each DT) of a model run. If you wish to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use statistical functions must have seeds specified. Each variable using a statistical function should use a separate seed value.

Examples:

EXPRND (1) gives a non-replicable exponentially distributed stream of numbers (mean=1)

EXPRND (2,456) gives a replicable exponentially distributed stream of numbers (mean=2)

 
MONTECARLO(<probability>[,<seed>])

The MONTECARLO function randomly generates a series of zeros and ones, based on the probability you have provided. The probability is the percentage probability of an event happening per unit of simulation time. Probability can be a variable or a constant, but should evaluate to a number between 0 and 100 (numbers outside the range will be set to 0). Note that the probability you specify, divided by 100, is the mean number of occurrences per unit time.

MONTECARLO is equivalent to the following logic:

IF (RANDOM(0,100,<seed>) <= probability*DT THEN 1 ELSE 0

MONTECARLO samples a new random number in each iteration of a model. If you wish to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use statistical functions must have seeds specified. Each variable using a statistical function should use a separate seed value.

Examples:

MONTECARLO(20,1577) gives a replicable stream of numbers which are equal to 1 20% of the time and equal to 0 the remaining 80% of the time. This means that the mean number of occurrences generated by this distribution is 20/100, or 0.2 per unit time.

 
NORMAL(<mean>,<std>[,<seed>])

The NORMAL function generates a series of normally distributed random numbers with a specified mean and standard deviation. NORMAL samples a new random number in each iteration of a simulation. If you wish to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use statistical functions must have seeds specified. Each variable using a statistical function should use a separate seed value.

Examples:

NORMAL(0,1) gives a non-replicable normally distributed stream of numbers (mean=0, standard deviation=1)

NORMAL(0,1,147) gives a replicable normally distributed stream of numbers (mean=0, standard deviation=1)

NORMAL(5,1,12) gives a replicable normally distributed stream of numbers (mean=5, standard deviation=1)

NORMAL(10,5,102) gives a replicable normally distributed stream of numbers (mean=10, standard deviation=5)

 
POISSON(<mu>[,<seed>])

The POISSON function generates a series of random numbers that conform to a Poisson distribution. The mean per unit time for the distribution is given by mu. POISSON samples a new random number in each iteration of a model run (i.e., every DT). If you wish to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use statistical function must have seeds specified. Each variable using a statistical function should use a separate seed value.

Examples:

POISSON (1) gives a non-replicable Poisson sample set with mean of 1, per unit of simulation time.

POISSON (10, 256) gives a replicable Poisson sample set with mean of 10, per unit of simulation time.

 
RANDOM(<min>,<max>[,<seed>])

The RANDOM function generates a series of uniformly distributed random numbers between min and max. RANDOM samples a new random number in each iteration of a model run. If you wish to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use statistical functions must have seeds specified. Each variable using a statistical function should use a separate seed value.

Examples:

RANDOM(0,1) creates a non-replicable uniformly distributed stream of numbers between 0 and 1.

RANDOM(0,1,147) creates a replicable uniformly distributed stream of numbers between 0 and 1.

RANDOM(0,10,12) gives a replicable uniformly distributed stream of numbers between 0 and 10.

RANDOM(10,13,12) gives a replicable uniformly distributed stream of numbers between 10 and 13.

 

Sampling From Non-Uniform Distributions

In many cases you may wish to draw samples from distributions other than the ones explicitly provided by the software. A straightforward technique, known as inversion, allows you to transform a sample drawn from RANDOM into any distribution whose density function can be integrated and then inverted.

For example, it is possible to follow this technique to use the RANDOM function to generate Weibull variates. The expression below provides the transformation:

Weibull = b * (-LOGN(RANDOM(0,1,1575)))^(1/c) + a

where

a >= the location parameter

b >0 the scale parameter

c >0 the shape parameter

Transformations of this ilk can be quite useful, but are best left to the analytically inclined. For an in-depth coverage of techniques for sampling from non-uniform distributions, see: Naylor, T.H., J. Balintfy, D.S., and K. Chu, Computer Simulation Techniques, Wiley, 1966.

See Also