Custom distributions
The FDISTRIBUTION type lets you define fully customized distribution functions using a mathematical expression, without being limited to predefined formulas such as GAUSS, EXP or TRIANGULAR.
These functions internally generate a distribution table by evaluating a mathematical expression over a given range. This is ideal for representing non-standard distributions or variants of the classic ones.
How does it work?
GPSS-Plus builds a distribution table based on:
-
A mathematical expression that defines the shape of the function (a bell, a triangle, etc.)
-
A value range (
min,max) over which that function is evaluated -
A number of
intervalsthat determines the table resolution -
Optional parameters (
A,B,C...) that you can use inside the formula
Once the table is built, the function behaves like any other distribution: a random value is drawn, the table is consulted, and the corresponding result is returned.
Syntax:
Function {
Name: name,
Type: FDISTRIBUTION,
Expression: "formula",
min: minValue,
max: maxValue,
intervals: count,
A: value, B: value, ...
}
Example 1: Custom Gaussian distribution
Function {
Name:gauss1,
Type: FDISTRIBUTION,
EXPRESSION: "(1 / (A * SQRT(2 * PI))) * EXP(-0.5 * ((X - B) / A)^2)",
A: 2.3,
B: 30,
min: B - (3 * A),
max: B + (3 * A),
intervals: 100
}
This example creates a bell-shaped function centered at 30, with dispersion 2.3. It is equivalent to a classic Gaussian, but fully configurable.
Example 2: Triangular distribution defined by formula
Function {
Name:tri1,
Type: FDISTRIBUTION,
EXPRESSION: "(1 / C) * (1 - ABS((X - B) / (C / 2)))",
B: 25, C: 30,
min: B - C / 2,
max: B + C / 2,
intervals: 100
}
This function generates a triangular distribution with its peak at 25, total width 30, and base [10, 40].
Technical details:
-
The variable
Xis the horizontal axis (domain). -
The function is evaluated
intervalstimes betweenminandmax. -
The integral is automatically normalized so it behaves like a probability distribution.
-
All parameters (
A,B,C, etc.) can be expressions.
Example
/*
FDistribution
*/
SYSTEM {TYPE:OPTIONS,Speed:5}
Facility {NAME:VENTANILLA1,X:244,Y:190,E_BIN_start:5,E_BIN_SIZE:1,E_BIN_COUNT:80,capacity:20}
Facility {NAME:VENTANILLA2,X:412,Y:188,E_BIN_start:5,E_BIN_SIZE:1,E_BIN_COUNT:80,capacity:20}
POSITION {NAME:POS1,X:200,Y:387}
POSITION {NAME:POS2,X:341,Y:381}
POSITION {NAME:POS3,X:507,Y:380}
;GAUSSIAN
Function {Name:tName1, type: FDISTRIBUTION, EXPRESSION:"(1 / (A * SQRT(2 * PI))) * EXP(-0.5 * ((X - B) / A)^2)", b:30, a: 2.3, min:B - (3 * A), max:B + (3 * A),intervals:100}
; TRIANGULAR B: center of the range C: total width of the range
Function {Name:tName2, A:0, B:25, C:30, D:0, type: FDISTRIBUTION, EXPRESSION:"(1 / C) * (1 - ABS((X - B) / (C / 2)))", min:B - C/2, max:B + C/2, intervals:100}
START 1000
;*****************************************************
GENERATE 2,0,0,0 {NAME:GEN1,X:56,Y:319}
ADVANCE 20,0 {TO:POS1}
ADVANCE 30,10 {TO:VENTANILLA1}
SEIZE VENTANILLA1
ADVANCE FN$tName1
RELEASE VENTANILLA1
ADVANCE 20,0 {TO:POS2}
ADVANCE 20,10 {TO:VENTANILLA2}
SEIZE VENTANILLA2
ADVANCE FN$tName2
RELEASE VENTANILLA2
ADVANCE 20,0 {TO:POS3}
ENDGENERATE 1