The random builtins provide a number of random number generators based on different distributions. These builtins enable you to introduce randomness into your models. Random numbers are generated using a robust 64 bit generator, except as noted for RANDOM. See the common parameters section for the description of optional parameters.
This section describes the following builtins:
The builtins generating random number all take 4 optional arguments (except RANDOM which only takes <seed>) .
Values are sample from the distribution you've specified, each DT during the model simulation. If you specify a value for seed other than NAN, the same values will occur every time the model is run. If you leave <seed> blank, or set it to NAN, then every time the model is run a different set of values will occur (it will not be possible to replicate the run).
Specifies the minimum acceptable value for the generated random number. This is useful when you want to truncate a distribution. Some distributions, such as NORMAL, can take on any values while other, such as POISSON, can only be positive integers. Setting a min is most useful for cases where some possible values are not reasonable. Leave empty or use NAN to specify no minimum.
Specifies the maximum acceptable value for the generated random number. This is useful when you want to truncate a distribution. Some distributions, such as NORMAL, can take on any values while other, such as POISSON, can only be positive integers. Setting a max is most useful for cases where some possible values are not reasonable. Leave empty or use NAN to specify no minimum.
Specified how frequently values will change. Normally generated values change every DT, but you can specify a larger number if you want to have them stay constant over an interval. For example, using 1 will keep the same during each unit time interval changing only at time 1, 2, 3 and so on independent of DT.
Note For some distributions, such as uniform, it really does not make sense to specify another minimum and maximum, however, the argument sequence is kept for consistency so to specify a sample time you will need to include the min and max (using NAN for each is easiest).
The BETA builtin generates a series of random numbers that conforms to a beta distribution defined by two shape parameters, alpha and beta. The BETA builtin samples from continuous distributions.
The BINOMIAL builtin generates a series of random numbers from a discrete probability distribution of the number of successes in a sequence of trials with a given success probability. The success probability should be a number between 0 and 1 (numbers outside the range are set to 1).
The negative binomial builtin is a discrete number generator that will only return integers, and treats the number of trials as an integer (similar to MONTECARLO, NEGBINOMIAL, and POISSON).
The EXPRND builtin generates a series of exponentially distributed random numbers with a mean of lambda. EXPRND samples a new random number for each DT of a model run unless sample is specified. If you want to replicate the stream of random numbers, specify seed as an integer. 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,1456) gives a replicable exponentially distributed stream of numbers (mean=2)
The GAMMA builtin generates a series of random numbers that conforms to a gamma distribution with the specified shape and scale. If unspecified, scale uses the value 1.0. The GAMMA function samples from continuous distributions.
The GEOMETRIC builtin generates a series of random numbers from a discrete probability distribution of the number of trials before the first success with a given success probability. The success probability should be a number between 0 and 1 (numbers outside the range are set to 1).
The GEOMETRIC builtin samples from discrete distributions (as the MONTECARLO and POISSON functions do).
The LOGISTIC builtin generates a series of random numbers that conforms to a logistic distribution with a specified mean and scale. The LOGISTIC builtin samples from continuous distributions.
The LOGNORMAL builtin generates a series of random numbers that conform to a Log-Normal distribution (that is, the log of the independent variable follows a normal distribution). The mean and stddev (standard deviation) are those of the resulting random number and must both be positive values. LOGNORMAL samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as a positive integer. 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.
LOGNORMAL will always return a positive value, and the mean must always be a positive value.
Examples:
LOGNORMAL(0,1) will give a floating point error.
LOGNORMAL(1,1) gives a non-replicable stream of numbers following a log-normal distribution with a mean or 1 and a standard deviation of 1.
LOGNORMAL(1,1,147) gives a replicable stream of numbers following a log-normal distribution (mean=1, standard deviation=1)
LOGNORMAL(5,2,12) gives a replicable stream of numbers following a log-normal distribution with a mean of 5 and a standard deviation of 2.
The LOOKUPRANDOM builtin generates a series of random numbers that conform to the probability density function (PDF) specified by graphical, which must be a graphical variable that is everywhere positive. The area underneath the curve for the graphical is automatically normalized so that it is a true PDF. LOOKUPGRAPHICAL samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as a positive integer. 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.
Note Specifying the same graphical for LOOKUPRANDOM and as the inflow profile for a conveyor allow you to create consistent continuous and discrete representations of a stochastic process.
The MONTECARLO builtin randomly generates a series of zeros and ones from a Bernoulli distribution based on the probability you've provided. The probability is the percentage probability of an event happening per DT divided by DT (it is similar too, but not the same as, the percent probability of an event per unit time). The probability value can be either a variable or a constant, but should evaluate to a number between 0 and 100/DT (numbers outside the range will be set to 0 or 100/DT). The expected value of the stream of numbers generated summed over a unit time is equation to probability/100.
MONTECARLO is equivalent to the following logic:
IF (UNIFORM(0,100,<seed>) < probability*DT THEN 1 ELSE 0
MONTECARLO samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as a positive integer. 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) with a DT of 1 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.
The MONTECARLO builtin samples from discrete distributions (as BINOMIAL, NEGBINOMIAL, and POISSON do).
The NEGBINOMIAL (Negative Binomial) builtin generates a series of random numbers from a discrete probability distribution of the number of failures in a sequence of trials with a given success probability that result in the specified number of successes. The success probability should be a number between 0 and 1 (numbers outside the range are set to 0 or 1).
The negative binomial builtin is a discrete number generator that will only return integers, and treats the number of successes as an integer.
The NORMAL builtin generates a series of normally distributed random numbers with a specified mean and stddev (standard deviation). NORMAL samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as a positive integer. 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)
The NORMALPINK builtin generates an autocorrelated series of normally distributed random numbers with a specified mean , stddev (standard deviation) and corr time (correlation time). NORMALPINK samples a new random number for each dt, then combines that with the result from the prior dt giving the prior result a weight of 1-dt/corr_time and the current draw a weight of dt/corr_time. This give a similar result to specifying sample in the NORMAL builtin.
unless sample is specified. If you want to replicate the stream of random numbers, specify seed as a positive integer. 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)
The PARETO builtin generates a series of random numbers that conforms to a distribution whose log is exponentially distributed with a specified shape and scale. The PARETO builtin samples from continuous distributions.
The POISSON builtin generates a series of random numbers that conform to a Poisson distribution. mu specifies the mean number of arrivals per unit of time. The output should be used with the PULSE function when computing flows. For example, the inflow PULSE(POISSON(3.5)) will have an average value of 3.5 (per time unit) and will always cause the level to change by an integer value. POISSON samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as an integer between 1 and 32767. To replicate a simulation, all variables that use random functions must have seeds specified. Each variable using a random function should use a separate seed value.
Examples:
POISSON (1) gives a non-replicable Poisson sample set with mean of 1 per unit time.
POISSON (10,1256) gives a replicable Poisson sample set with mean of 10 per unit time.
Note Because the POISSON builtin specifies a mean rate per unit time changing DT will change the magnitude of the values generated . This is why it is important to use it in combination with PULSE (or alternatively dividing the result by DT). This will insure that stocks are changed by the output of POISSON - always an integer.
The POISSON builtin returns the units of measure as mu multiplied by the units for time. You can specify a flow rate and then, when used with the PULSE function as described above, the units will be correct.
The POISSON builtin always returns an integer.
The RANDOM builtin is the same as the UNIFORM builtin, except that it uses the older version of the random number generator used in the version of iThink/STELLA before version 10.1. It's kept to support models that depended on its behavior. Specify seed as an integer between 1 and 32767.
The TRIANGULAR builtin generates a series of random numbers that conforms to a triangular distribution with a specified lower bound, mode, and upper bound. The TRIANGULAR builtin samples from continuous distributions.
The UNIFORM builtin generates a series of uniformly distributed random numbers between min and max. UNIFORM samples a new random number for each dt unless sample is specified. If you want to replicate the stream of random numbers, specify seed as positive integer. 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:
UNIFORM(0,1) creates a non-replicable uniformly distributed stream of numbers between 0 and 1.
UNIFORM(0,1,147) creates a replicable uniformly distributed stream of numbers between 0 and 1.
UNIFORM(0,10,12) gives a replicable uniformly distributed stream of numbers between 0 and 10.
UNIFORM(10,13,12) gives a replicable uniformly distributed stream of numbers between 10 and 13.
The WEIBULL builtin generates a series of random numbers that conforms to a Weibull distribution with the specified shape and scale. The WEIBULL builtin samples from continuous distributions.