The FUNCTION command allows you to define functions that return numeric values, either through direct calculations or through precomputed distribution tables. These functions are used to simulate variable and realistic behavior in operations such as ADVANCE, ASSIGN, TABULATE, etc., and they represent times, quantities, costs, probabilities, and more.
In GPSS-Plus, functions can be classified into two broad groups:
1. Functions based on statistical distributions (with a value table)
These functions pre-generate an internal table with a configurable number of points (intervals) and interpolate the result over it. They are ideal for representing random behavior with known patterns. Available types are:
-
GAUSS: Normal distribution (Gaussian bell curve). -
EXP: Decreasing exponential distribution. -
UNIFORM: Uniform (rectangular) distribution. -
TRIANGULAR: Triangular distribution. -
LOGNORMAL: Log-normal distribution, right-skewed. -
FDISTRIBUTION: Lets you define a custom distribution function using a mathematical formula.
2. Direct-calculation functions (no table)
These functions evaluate the result directly, without generating or consulting a table. They are more flexible when you want to work with formulas or with discrete event-count models. They include:
-
POISSON: Generates a random integer according to a Poisson distribution (number of events per interval). -
MATH: Directly evaluates a mathematical expression. It accepts multiple parameters that are substituted by letters (A,B,C, etc.) in order.
Example
Function {name:funGauss, type:"GAUSS", a:1, b:30, sigma1:3.3, sigma2:3.3,intervals:100 }
Function {name:funExp, type:"EXP", b:0, lambda:0.15, intervals:100}
Function {name:funUni, type:"UNIFORM", min:20, max:40, intervals:100}
Function {name:funTri, type:"TRIANGULAR", min:20, max:40, mode:30, intervals:100}
Function {name:funLog, type:"LOGNORMAL", mu:3.4, sigma:0.3, intervals:100}
Function {name:funLog2, type:"LOGNORMAL", b:30, spread:5, intervals:100}
Function {name:funCus, type:"FDISTRIBUTION", function:"A * Math.sin(B * x)", a:10, b:0.5, min:0, max:10, intervals:100}
Function {name:funPoi, type:"POISSON", lambda:3.5}
Function {Name:math1, type: math, EXPRESSION:"A * 2 + B"}