RANDOM Number Functions
RANDOM 0 1( ) RANDOM number between 0 and 1
RANDOM BETA(m,x,A,B,h,r,s) BETA distribution alpha=A and beta =B
RANDOM BINOMIAL(m,x,P,N,h,r,s) BINOMIAL on N trials of probability P
RANDOM EXPONENTIAL(m,x,h,r,s) EXPONENTIAL starting at 0 with mean 1
RANDOM GAMMA(m,x,O,h,r,s) GAMMA with order O
RANDOM LOOKUP(look,m,x,h,r,s) RANDOM number using LOOKUP PDF
RANDOM NEGATIVE BINOMIAL(m,x,P,N,h,r,s) NEGATIVE BINOMIAL N successes prob P
RANDOM NORMAL(m,x,h,r,s) NORMAL with mean 0 and standard deviation 1
RANDOM POISSON(m,x,M,h,r,s) POISSON and mean M
RANDOM TRIANGULAR(m,x,S,P,T,s) TRIANGULAR between S and T with peak at P
RANDOM UNIFORM(m,x,s) UNIFORM between m and x
RANDOM WEIBULL(m,x,S,h,r,s) WEIBULL with shape S starting at 0 with mean 1
|Top Previous Next|
Each of these routines returns a random number. The number returned is different on each successive invocation. These functions are used to introduce noise into a simulation.
All runs made using Vensim are reproducible (unless streams are randomized using GET TIME VALUE, which normally should be done only for gaming or other specific purposes that are deliberately nonreproducible). That means if you make two runs with the same inputs you will get the same results. If you want to make runs that differ based on the realized values of RANDOM… functions set the Stream ID on all RANDOM calls to 0 and change NOISE SEED for each run you want to make.
Version 6.3 introduces a new pseudorandom number generator. To replicate the random draws of runs from earlier versions, see NOISE RNG.
With the exception of the obsolete function RANDOM 0 1, which takes no arguments, all of the RANDOM functions take a common set of arguments (The TRIANGULAR and UNIFORM don’t use all the common arguments because they are simpler).
m is the minimum value that the function will return. Where necessary the distributions will be truncated to return values above this. Truncation occurs after the output has been stretched and shifted. If the number drawn is below this value it will be discarded and another number drawn.
x is the maximum value that the function will return. Where necessary the distributions will be truncated to return values below this. Truncation occurs after the output has been stretched and shifted. If the number drawn is bigger than this it will be discarded and another number drawn.
h is a shift parameter that indicates how much the distribution will shifted to the right after it has been stretched (but before being truncated).
r is a stretch parameter that indicates how much the distribution will be stretched before it is shifted and truncated. Note that for the NORMAL distribution h and r correspond to the mean and standard deviation.
s is a stream ID for the distribution to use. NOTE This is not only a noise seed. Please read carefully the definition of stream ID. In most cases the final argument should be 0!
NOTE If the minimum and maximum specified make it impossible for Vensim to find a number with the desired distribution (this occurs when more than 2000 attempts are discarded because of truncation) the function will return NA and an error message will be issued. The resulting return value will also likely cause a floating point error to occur in a downstream location which will stop the simulation. As a general rule of thumb the min and max should encompass 10% or more of the underlying probability distribution function to get reasonable results and avoid performance degradation.
RANDOM...(units,units...dmnl) --> units
The minimum, maximum arguments should have the same units and the RANDOM functions will return these units. If there is a shift argument it should also have these units. The seed argument should be dimensionless. If there is a stretch argument it should be dimensionless. Except as noted below, the remaining arguments should be dimensionless. If all inputs are numbers the output will be dimensioned by usage.
RANDOM 0 1() is uniformly distributed on the range 0 to 1. It is obsolete and will return exactly the same noise stream as RANDOM UNIFORM(0,1,0). It is retained to maintain backward compatibility only.
RANDOM BETA(m,x,A,B,h,r,s) provides a BETA distribution with alpha having the value A and beta having the value B before it is stretched, shifted and truncated.
RANDOM BINOMIAL(m,x,P,N,h,r,s) provides a binomial distribution where P is the underlying selection probability and N is the number of draws. Before stretching and shifting, RANDOM BINOMIAL always returns an integer between 0 and N. If N is not an integer it will be rounded to the nearest integer.
RANDOM EXPONENTIAL(m,x,h,r,s) provides an exponential distribution starting at 0 with a mean of 1 before being stretched, shifted and truncated.
RANDOM GAMMA(m,x,O,h,r,s) provides a gamma distribution of order O before it is stretched, shifted and truncated. When O is 1 RANDOM GAMMA is the same as RANDOM EXPONENTIAL. If O is less than 1 a warning will be generated and 1 used.
RANDOM LOOKUP(look,m,x,h,r,s) provides an arbitrary distribution with a probability density function specified by the Lookup function look. Before stretching or shifting the random number will have the same range as the x-axis in the Lookup. This means that the Lookup is the same as the probability density function (PDF) except that you do not need to make the area under the Lookup 1.0, Vensim will automatically adjust for that. The dimensions of look should match m, x, and h. After the random number is drawn from the supplied Lookup PDF it will be multiplied by r then have h added then tested against m and x.
RANDOM NEGATIVE BINOMIAL(m,x,P,N,s) same as binomial except N is the number of successes required so that random negative binomial returns an integer from N to infinity.
RANDOM NORMAL(m,x,h,r,s) provides a normal distribution of mean 0 and variance 1 before it is stretched, shifted and truncated. This is equivalent to a normal distribution with mean h and standard deviation r. The units of r should match m, x and h.
RANDOM POISSON(m,x,M,h,r,s) provides a Poisson distribution with mean M. The value returned is always an integer before it is stretched and shifted. The units for M should match m, x and h.
RANDOM TRIANGULAR(m,x,S,P,T,s) provides a triangular distribution from S to T with a peak at P. You can shift and stretch the triangular distribution by adjusting S, P and T. The units for S, P, and T, should match those of m and x.
RANDOM UNIFORM(m,x,s) provides a uniform distribution between m and x (exclusive of the endpoints).
RANDOM WEIBULL(m,x,S,h,r,s) provides a Weibull distribution with shape S starting at 0 and having a mean of 1 before it is stretched, shifted and truncated. When S is 1 the Weibull distribution is the same as the exponential distribution.
Availability: PLE and PLE Plus only support RANDOM UNIFORM and RANDOM NORMAL.