SimLang: Function Reference
Each equation that defines a decision or variable can include not only constant values (strings, booleans, numeric values), but also functions, loops, and conditionals built in to SimLang.
This reference page lists all functions available in SimLang as implemented in Epicenter. If your model was originally written for SimLang as implemented in Simulate, see migrating from Simulate to verify you are not using any functions not available in Epicenter.
- Operators
- Logical Functions
- Mathematical Functions
- Time Functions
- Financial Functions
- Array Functions
- Miscellaneous Functions
Operators
Logical operators can be part of an equation for any variable or decision. Typically they are used as part of the <expression>
in loops or conditionals.
They are listed here in order of precedence:
!
: logical not%
: percent (divides the number immediately to the left by 100)^
: power*
: multiply/
: divide+
: add-
: subtract==
: logical equal!=
: logical not equal>
: greater than<
: less than>=
: greater than or equal to<=
: less than or equal to&&
: logical and||
: logical or
Logical Functions
Logical functions can be part of an equation for any variable or decision, and in many cases are simply another way of expressing a logical operator. Often they are used as part of the <expression>
in loops or conditionals.
AND: Returns 1 (TRUE) if all its arguments are non-zero; returns 0 (FALSE) if one or more arguments are 0 (FALSE).
Syntax: AND(<logicalexpression1>, <logicalexpression2>, ...)
Example use:
V All These Statements Are True = AND(1, 5 > 4, 5 == 2)
returns 0
FALSE: Logical "False". Returns 0.
Syntax: FALSE
Example use:
V Value of False = FALSE
returns 0
IF: Returns second argument if <logicalexpression>
evaluates to a non-zero value (TRUE) and third argument if it evaluates to 0 (FALSE).
Syntax: IF (<logicalexpression>, <returniftrue>, <returniffalse>)
Example use:
V Sell Stock = IF(58 > 20, 1, 0)
returns 1
NOT: Inverts a logical expression. Returns 0 (FALSE) if argument is non-zero, and 1 (TRUE) if argument is 0 (FALSE).
Syntax: NOT(<logicalexpression>)
Example use:
V Opposite of False = NOT(FALSE)
returns 1
OR: Returns 0 (FALSE) if all its arguments are 0 (FALSE); returns 1 (TRUE) if one or more arguments are non-zero.
Syntax: OR(<logicalexpression1>, <logicalexpression2>, ...)
Example use:
V One is True = OR(0, 3 > 2, 10 == 11)
returns 1
TRUE: Logical "True". Returns 1.
Syntax: TRUE
Example use:
V Value of True = TRUE
returns 1
Mathematical Functions
Mathematical functions can be part of an equation for any variable or decision.
In some cases mathematical functions return NaN
, which is the value for "not a number." If necessary, remember to check for this value in your model.
ABS: Returns the absolute value of a number. The absolute value of a number is the number without its sign.
Syntax: ABS(<expression>)
Example use:
V Change in Sales = ABS(-100)
returns 100V Change in Sales = ABS(100)
returns 100
ACOS: Returns the arc cosine (in radians) of a number.
Syntax: ACOS(<expression>)
Example use:
V Angle = ACOS(0.5)
returns 1.047198
ASIN: Returns the arc sine (in radians) of a number.
Syntax: ASIN(<expression>)
Example use:
V Angle = ASIN(0.5)
returns 0.523599
ATAN: Returns the arc tangent (in radians) of a number.
Syntax: ATAN(<expression>)
Example use:
V Angle = ATAN(0.5)
returns 0.463548
CEILING: Returns number rounded up, away from zero, to the nearest multiple of <significance>
. Specifying the <significance>
is optional; the default value is 1.
Syntax: CEILING(<expression>, <significance>)
Example use:
V Value of Ceiling = CEILING(44.2, 10)
returns 50V Value of Ceiling = CEILING(2.5, 1)
returns 3V Value of Ceiling = CEILING(2.5, -1)
returns NaNV Value of Ceiling = CEILING(-2.5, 1)
returns -2V Value of Ceiling = CEILING(-2.5, -1)
returns -3V Value of Ceiling = CEILING(2.5, -1)
returns NaNV Value of Ceiling = CEILING(2.5, 0)
returns 0V Value of Ceiling = CEILING(1.5, 0.1)
returns 1.5V Value of Ceiling = CEILING(0.234, 0.01)
returns 0.24
COS: Returns the cosine of the given angle (in radians).
Syntax: COS(<expression>)
Example use:
V Cosign Value = COS(0.78)
returns 0.7109
COSH: Returns the hyperbolic cosine of the given number. Equal to the expression (e^x + e^(-x)) / 2.
Syntax: COSH(<expression>)
Example use:
V Result = COSH(0)
returns 1
E: Returns the value of e.
Syntax: E
Example use:
V E Value = E
returns 2.718281828459045
EXP: Returns a power of e.
Syntax: EXP(<expression>)
Example use:
V Power of E Value = EXP(0.5)
returns 1.6487
FLOOR: Returns number rounded down, toward zero, to the nearest multiple of <significance>
. Specifying the <significance>
is optional; the default value is 1.
Syntax: FLOOR(<expression>, <significance>)
Example use:
V Machinery Needed = FLOOR(112.7, 10)
returns 110V Machinery Needed = FLOOR(112.7)
returns 112V Value of Floor = FLOOR(2.5, 1)
returns 2V Value of Floor = FLOOR(2.5, -1)
returns NaNV Value of Floor = FLOOR(-2.5, 1)
returns -3V Value of Floor = FLOOR(-2.5, -1)
returns -2V Value of Floor = FLOOR(2.5, 0)
returns NaNV Value of Floor = FLOOR(1.5, 0.1)
returns 1.5V Value of Floor = FLOOR(0.234, 0.01)
returns 0.23
FRAC: Returns the fractional part of a number. If the argument is negative, then the result will be negative.
Syntax: FRAC(<expression>)
Example use:
V Population = FRAC(40.9)
returns 0.9
INT: Rounds a number down (towards negative infinity) to the nearest integer.
Syntax: INT(<expression>)
Example use:
V Population = INT(40.9)
returns 40
LN: Returns the natural logarithm of a number.
Syntax: LN(<expression>)
Example use:
V Natural Log Value = LN(5.3)
returns 1.6677
LOG10: Returns the base-10 logarithm of a number.
Syntax: LOG10(<expression>)
Example use:
V Log 10 Value = LOG10(5.3)
returns 0.72427
MOD: Returns the modulus when <expression>
is divided by <divisor>
.
Syntax: MOD (<expression>, <divisor>)
Example use:
V Remainder = MOD(8,3)
returns 2V Remainder = MOD(1,10)
returns 1V Remainder = MOD(-1,10)
returns 9
NAN: Returns the value NaN or "Not a Number"
Syntax: NAN
Example use:
V No Value = NAN
PCT: Converts a fraction into a percentage. Equivalent to multiplying by 100.
Syntax: PCT(<expression>)
Example use:
V Profitability = PCT(0.34)
returns 34
PI: Returns the value of pi.
Syntax: PI
Example use:
V Value of PI = PI
returns 3.141592653589793
ROUND: Rounds to a specified number of digits.
If <num_digits>
is greater than 0, then <expression>
is rounded to the specified number of decimal places.
If <num_digits>
is 0, then <expression>
is rounded to the nearest integer.
If <num_digits>
is less than 0, then <expression>
is rounded to the left of the decimal point.
Syntax:
ROUND(<expression>)
ROUND(<expression>,<num_digits>)
Example use:
V Value = ROUND(45.7, -1)
returns 50V Value = ROUND(2.15, 1)
returns 2.2V Value = ROUND(2.149, 1)
returns 2.1V Value = ROUND(-1.475, 2)
returns -1.48V Value = ROUND(21.5, -1)
returns 20
ROUNDDOWN: Rounds down to a specified number of digits.
If <num_digits>
is greater than 0, then <expression>
is rounded to the specified number of decimal places.
If <num_digits>
is 0, then <expression>
is rounded to the nearest integer.
If <num_digits>
is less than 0, then <expression>
is rounded to the left of the decimal point.
Syntax:
ROUNDDOWN(<expression>)
ROUNDDOWN(<expression>, <num_digits>)
Example use:
V Value = ROUNDDOWN(45.7, -1)
returns 40V Value = ROUNDDOWN(3.2, 0)
returns 3V Value = ROUNDDOWN(76.9, 0)
returns 76V Value = ROUNDDOWN(3.14159, 3)
returns 3.141V Value = ROUNDDOWN(-3.14159, 1)
returns -3.1V Value = ROUNDDOWN(31415.92654, -2)
returns 31,400
ROUNDUP: Rounds up to a specified number of digits.
If <num_digits>
is greater than 0, then <expression>
is rounded to the specified number of decimal places.
If <num_digits>
is 0, then <expression>
is rounded to the nearest integer.
If <num_digits>
is less than 0, then <expression>
is rounded to the left of the decimal point.
Syntax:
ROUNDUP(<expression>)
ROUNDUP(<expression>, <num_digits>)
Example use:
V Value = ROUNDUP(43.3, -1)
returns 50V Value = ROUNDDOWN(3.2, 0)
returns 4V Value = ROUNDDOWN(76.9, 0)
returns 77V Value = ROUNDDOWN(3.14159, 3)
returns 3.142V Value = ROUNDDOWN(-3.14159, 1)
returns -3.2V Value = ROUNDDOWN(31415.92654, -2)
returns 31,500
SAFEDIV0: Divides <expression1>
by <expression2>
. If <expression2>
is 0, returns 0.
Note that you can use this operation regardless of the value of the AllowDivisionByZero
property.
Syntax: SAFEDIV0(<expression1>, <expression2>)
Example use:
V Profitability = SAFEDIV0(500, 0)
returns 0
SAFEDIVX: Divides <expression1>
by <expression2>
. If <expression2>
is 0, returns <expression3>
.
Note that you can use this operation regardless of the value of the AllowDivisionByZero
property.
Syntax: SAFEDIV0(<expression1>, <expression2>, <expression3>)
Example use:
V Product Attractiveness = SAFEDIVX(5.4, 0, 1)
returns 1
SIGN: Determines the sign of a number. Returns 1 if positive, 0 if 0, and -1 if negative.
Syntax: SIGN(<expression>)
Example use:
V Is It Profitable = SIGN(-10000)
returns -1
SIN: Returns the sine of the given angle (given in radians).
Syntax: SIN(<expression>)
Example use:
V SINE VALUE = SIN(0.73)
returns 0.66686
SINH: Returns the hyperbolic sine of the given number. Equal to the expression (e^x - e^(-x)) / 2.
Syntax: SINH(<expression>)
Example use:
V Result = SINH(0)
returns 0
SQRT: Returns a positive square root.
Syntax: SQRT(<expression>)
Example use:
V Square Root of a Million = SQRT(1000000)
returns 1000V Result = SQRT(16)
returns 4V Result = SQRT(-16)
returns NaN
TAN: Returns the tangent of the given angle (given in radians).
Syntax: TAN(<expression>)
Example use:
V Tangent Value = TAN(0.35)
returns 0.365028
TANH: Returns the hyperbolic tangent of the given number. Equal to the expression (e^x - e^(-x)) / (e^x + e^(-x)).
Syntax: TANH(<expression>)
Example use:
V Result = TANH(0)
returns 0
TRUNC: Truncates a number to an integer by removing the fractional part of the number.
Syntax: TRUNC(<expression>)
Example use:
V Truncated Number = TRUNC(45.764321)
returns 45V Truncated Number = TRUNC(8.9)
returns 8V Truncated Number = TRUNC(-8.9)
returns -8
Time Functions
Time functions can be part of an equation for any variable or decision.
Some time functions are functions whose values change with each step of the model (e.g. ACCUM), or whose value depends on other values over time (e.g. HIVAL). Others are functions that return time-related values (e.g. ENDSTEP).
Remember that you can also ask for details about the current time and step within the model.
ACCUM: Accumulates the <value>
for each time step up to and including the current time step. If no initial value (<init>
) is given, the initial value is the first argument.
Syntax: ACCUM(<value>, <init>)
Example use:
V Cumulative Sales = ACCUM(1, 100)
- In step 0, returns 100
- In step 1, returns 101
- In step 2, returns 102
- In step 3, returns 103
ACCUMPERIOD: Returns the cumulative amount, adding the value of <expression>
for each step over specified period. For example, use this to report last year's revenue. The value of the function is held constant during the time step and refreshed at the start of the next time step.
Syntax:
ACCUMPERIOD(<expression>, <period>, <offset>, <initialvalue>)
ACCUMPERIOD(<expression>, <period>, <offset>)
ACCUMPERIOD(<expression>, <period>)
ACCUMPERIOD(<expression>)
where
<expression>
is the amount to accumulate<period>
is the amount of time over which to accumulate (default: 1)<offset>
is the offset of accumulation period (default: 0)<initialvalue>
is the value of function during first time step (before anything has accumulated) (default: 0)
Example use:
V Two Step Cumulation = ACCUMPERIOD(1, 2, 0, 100)
- In step 0, returns 100
- In step 1, returns 100
- In step 2, returns 2
- In step 3, returns 2
DELAY: Delays <input>
for <delaytime>
. The delay function works like a pipeline or conveyor. Each time step, the value of <input>
is assigned a delay length. If <delaytime>
changes over the course of the simulation, new inputs will be assigned the new time, but existing amounts in the pipeline will still wait for the original amount of time before being returned. This means that all quantities within the delay are conserved.
Syntax:
DELAY(<input>, <delaytime>, <initialvalue>)
DELAY(<input>, <delaytime>)
Example use:
V Two Step Delay = DELAY(5, 2, 0)
- In step 0, returns 0
- In step 1, returns 0
- In step 2, returns 5
- In step 3, returns 5
DELAYSTATE: Returns the internal state of a delay function. First argument must be a variable containing a delay function. The second argument indicates which internal state subscript to return. For a fixed delay, a subscript of 1 means the output from the delay function, a subscript of 2 means the next (upcoming) output from the delay function, etc.
Syntax: DELAYSTATE(<delayed_variable>, <state_subscript>)
Example use:
V Two Step Delay = DELAY(5, 2, 0)
V Delay State = DELAYSTATE(Two Step Delay, 1)
- In step 0, Two Step Delay returns 0 and Delay State returns 0
- In step 1, Two Step Delay returns 0 and Delay State returns 0
- In step 2, Two Step Delay returns 5 and Delay State returns 5
- In step 3, Two Step Delay returns 5 and Delay State returns 5
V Two Step Delay = DELAY(5, 2, 0)
V Delay State = DELAYSTATE(Two Step Delay, 2)
- In step 0, Two Step Delay returns 0 and Delay State returns 0
- In step 1, Two Step Delay returns 0 and Delay State returns 5
- In step 2, Two Step Delay returns 5 and Delay State returns 5
- In step 3, Two Step Delay returns 5 and Delay State returns 5
DERIVN: Returns the Nth order derivative of <input>
, or zero if it is not possible to calculate the derivative. If no <order>
is given, assumes first order.
Syntax:
DERIVN(<input>, <order>)
DERIVN(<input>)
Example use:
V Series = 5 + RAMP(2, 1, 3)
V First Derivative = DERIVN(series)
- In step 0, Series returns 5 and First Derivative returns 0
- In step 1, Series returns 5 and First Derivative returns 0
- In step 2, Series returns 7 and First Derivative returns 2
- In step 3, Series returns 9 and First Derivative returns 2
ENDSTEP: Returns the final step of the simulation, counting 0 as the initial step.
Syntax: ENDSTEP
Example use:
M StartTime = 2010
M EndTime = 2020
V Last Step = ENDSTEP
returns 10 for all steps.
ENDTIME: Returns the final time of the simulation, as defined in the EndTime
property.
Syntax: ENDTIME
Example use:
M EndTime 2020
V Final Year = ENDTIME
returns 2020 for all steps.
FORECAST: Returns a forecasted future value based on <input>
.
Syntax:
FORECAST(<input>, <averagingtime>, <futuretime>, <initial>)
FORECAST(<input>, <averagingtime>, <futuretime>)
Example use:
V Series = 5 + RAMP(1, 0, 5)
V Forecasted Result = FORECAST(Series, 2, 1, 6)
- In step 0, Series returns 5 and Forecasted Result returns 6
- In step 1, Series returns 6 and Forecasted Result returns 6.6
- In step 2, Series returns 7 and Forecasted Result returns 7.95
- In step 3, Series returns 8 and Forecasted Result returns 9.12
Note that FORECAST
is equivalent to the following equations:
V Change In Input = (<input> - Average of Input) / <averagingtime>
V Average of Input = stock(Change In Input, <input>)
V Trend = Change In Input / Average of Input
V Forecast = <input> + <input> *Trend * <futuretime>
HIVAL: Returns the highest value since the start of the simulation (including the current step).
Syntax: HIVAL(<expression>)
Example use:
V Series = {10,2,15,14,13,17,20,2}[STEP + 1]
V Highest Value = HIVAL(Series)
- In step 0, Series returns 10 and Highest Value returns 10
- In step 1, Series returns 2 and Highest Value returns 10
- In step 2, Series returns 15 and Highest Value returns 15
- In step 3, Series returns 14 and Highest Value returns 15
IMMEDIATE: Allows the model to access the current, user-entered value of a decision, even if the ExecuteDecisionImmediately
property is false.
Syntax: IMMEDIATE(<decision>)
Example use:
D Price1 = 100
P Price1.ExecuteDecisionImmediately = false
D Price2 = 200
P Price2.ExecuteDecisionImmediately = false
V Total Price = IMMEDIATE(Price1) + IMMEDIATE(Price2)
V Revenue = Total Price * Sales
INITIAL: Stores the initial value of an expression.
Syntax: INITIAL(<initvalue>)
Example use:
V Initial Sales = INITIAL(10 + STEP)
- In step 0, returns 10
- In step 1, returns 10
- In step 2, returns 10
- In step 3, returns 10
INTERVALCOUNT: Counts the number of steps to date that a value has been within the range <lowval>
to <hival>
. Optional fourth argument specifies if it counts when <expression>
equals <hival>
.
Syntax:
INTERVALCOUNT (<expression>, <lowval>, <hival>, <includeHiVal>)
INTERVALCOUNT (<expression>, <lowval>, <hival>)
Example use:
V Values Inside Range = INTERVALCOUNT(2 ^ STEP, 2, 4, true)
- In step 0, returns 0
- In step 1, returns 1
- In step 2, returns 2
- In step 3, returns 2
LOVAL: Returns the lowest value since the start of the simulation (including the current step).
Syntax: LOVAL(<expression>)
Example use:
V Series = {10,2,15,14,13,17,20,2}[STEP + 1]
V Lowest Value = LOVAL(Series)
- In step 0, Series returns 10 and Lowest Value returns 10
- In step 1, Series returns 2 and Lowest Value returns 2
- In step 2, Series returns 15 and Lowest Value returns 2
- In step 3, Series returns 14 and Lowest Value returns 2
NONNEGATIVE: Always evaluates to 1. When used as the third argument in a STOCK
function, indicates the stock should always be a non-negative value after time is advanced.
Syntax: NONNEGATIVE
Example use:
V Inventory = STOCK(-10, 0, NONNEGATIVE)
- In step 0, returns -10
- In step 1, returns 0
- In step 2, returns 0
- In step 3, returns 0
PREVIOUS: Returns the value from the previous step.
Syntax:
PREVIOUS (<expression>, <initvalue>)
PREVIOUS (<expression>)
Example use:
V Sales = PREVIOUS (Sales * 1.1, 100)
- In step 0, returns 100
- In step 1, returns 110
- In step 2, returns 121
- In step 3, returns 133.1
PULSE: A periodic pulse starting at <first>
and repeating every <interval>
. Amount of the pulse is <volume>
/ timestep
.
Syntax: PULSE(<volume>, <first>, <interval>)
Example use:
V Temporary Increase = PULSE(10,1,2)
- In step 0, returns 0
- In step 1, returns 10
- In step 2, returns 0
- In step 3, returns 10
RAMP: Returns 0 until time <starttime>
and then a ramp with slope <slope>
until <stoptime>
and then constant.
Syntax:
RAMP(<slope>, <starttime>, <stoptime>)
RAMP(<slope>, <starttime>)
RAMP(<slope>)
Example use:
V Steady Growth = RAMP(1, 1, 3)
- In step 0, returns 0
- In step 1, returns 0
- In step 2, returns 1
- In step 3, returns 2
- In step 4, returns 2
V Steady Growth = RAMP(2)
- In step 0, returns 0
- In step 1, returns 2
- In step 2, returns 4
- In step 3, returns 6
- In step 4, returns 8
REMEMBER: Reads and stores a value from <inputstream>
whenever <condition>
is true (non-zero).
Syntax:
REMEMBER(<condition>, <inputstream>, <initvalue>)
REMEMBER(<condition>, <inputstream>)
Example use:
V Step 2 Value = REMEMBER(STEP == 2, 5, 0)
- In step 0, returns 0
- In step 1, returns 0
- In step 2, returns 5
- In step 3, returns 5
SAMPLE: Periodically samples and holds on to a value from <inputstream>
.
Syntax:
SAMPLE(<inputstream>, <first>, <interval>, <initial>)
SAMPLE(<inputstream>, <first>, <interval>)
Example use:
V Every Other Value = SAMPLE(STEP, 1, 2, 99)
- In step 0, returns 99
- In step 1, returns 1
- In step 2, returns 1
- In step 3, returns 3
STEP: Returns the number of steps since the start of the simulation (starting at 0 when the simulation begins at StartTime
).
Syntax: STEP
Example use:
V Current Time Step = STEP
- In step 0, returns 0
- In step 1, returns 1
- In step 2, returns 2
- In step 3, returns 3
SMOOTH: Returns an exponential smooth (default: first order).
Syntax:
SMOOTH(<input>, <delaytime>, <order>, <initial>)
SMOOTH(<input>, <delaytime>, <order>)
SMOOTH(<input>, <delaytime>)
Example use:
V Perceived Value = SMOOTH(10, 2, 1, 0)
- In step 0, returns 0
- In step 1, returns 5
- In step 2, returns 7.5
- In step 3, returns 8.75
STARTTIME: Returns the start time of the simulation.
Syntax: STARTTIME
Example use:
M StartTime = 2010
V First Year = STARTTIME
- In step 0, First Year returns 2010
- In step 1, First Year returns 2010
- In step 2, First Year returns 2010
- In step 3, First Year returns 2010
STEPCHANGE: Returns 0 until time <starttime>
and then <height>
.
Syntax: STEPCHANGE(<height>, <starttime>)
Example use:
V Step Value = STEPCHANGE(100, 2)
- In step 0, returns 0
- In step 1, returns 0
- In step 2, returns 100
- In step 3, returns 100
STOCK: Accumulates the flows, not including the current time period (step). Equivalent to a system dynamics stock. If the third argument is set to NONNEGATIVE
(or the equivalent value of 1), then the stock is always forced to be zero or positive after time is advanced. (Note that you should combine this with the LIMITFLOW
function to ensure that the values of the flow are also changed to reflect the stock changes).
Syntax:
STOCK(<flow>, <initialvalue>, <nonnegative>)
STOCK(<flow>, <initialvalue>)
Example use:
V Inventory = STOCK(5, 100)
- In step 0, returns 100
- In step 1, returns 105
- In step 2, returns 110
- In step 3, returns 115
V Inventory = STOCK(-10, 0, NONNEGATIVE)
- In step 0, returns -10
- In step 1, returns 0
- In step 2, returns 0
- In step 3, returns 0
TIME: Returns the current time. (Remember that you can also ask for details about the current time and step within the model.)
Syntax: TIME
Example use:
M StartTime = 2010
M EndTime = 2020
V Current Year = TIME
- In step 0, Current Year returns 2010
- In step 1, Current Year returns 2011
- In step 2, Current Year returns 2012
- In step 3, Current Year returns 2013
TIMECYCLE: Returns 1 for a given <duration>
every <interval>
starting at <first>
, and a value of 0 otherwise. If no <duration>
is given, returns 1 for a <duration>
of 1 step.
Syntax:
TIMECYCLE(<first>, <interval>, <duration>)
TIMECYCLE(<first>, <interval>)
Example use:
V Periodic Value = TIMECYCLE(1,2)
- In step 0, Periodic Value returns 0
- In step 1, Periodic Value returns 1
- In step 2, Periodic Value returns 0
- In step 3, Periodic Value returns 1
TIMESTEP: Returns the current calculation interval set by the model property TimeStep
.
Syntax: TIMESTEP
Example use:
M TimeStep = 0.25
V Delta Time = TIMESTEP
- In step 0, Delta Time returns 0.25
- In step 1, Delta Time returns 0.25
- In step 2, Delta Time returns 0.25
- In step 3, Delta Time returns 0.25
TREND: Returns the relative change in <input>
per time unit.
Syntax:
TREND(<input>, <averagingtime>, <initial>)
TREND(<input>, <averagingtime>)
Example use:
V Series = 5 + RAMP(1, 0, 5)
V Trend Result = TREND(Series, 2)
- In step 0, Series returns 5 and Trend Result returns 0
- In step 1, Series returns 6 and Trend Result returns 0.1
- In step 2, Series returns 7 and Trend Result returns 0.136
- In step 3, Series returns 8 and Trend Result returns 0.14
Financial Functions
Financial functions can be part of an equation for any variable or decision.
ARRAYIRR: Internal Rate of Return (IRR) for a stream of cash flows. Each cash flow value is assumed to be the cash flow at the end of the current period (step). If the cash flow contains multiple sequences of positive and negative cash flow values there may be multiple valid IRR results. In such cases the IRR closest to the specified <guess>
is returned. If no guess is specified, a default of 0.2 is used.
Syntax:
ARRAYIRR (<cash_flow_array>, <guess>)
ARRAYIRR (<cash_flow_array>)
Example use:
V IRR Value = ARRAYIRR({-100,30,30,30,30,30})
returns 0.15
ARRAYNPV: Net Present Value (NPV) for a stream of cash flow which is either income (positive amount) or payments (negative amount) at a given discount rate. Each cash flow value is assumed to be the cash flow at the end of the current period (step). The NPV is calculated for the given array of cash flow at each point in time.
Syntax: ARRAYNPV (<cash_flow_array>, <rate>)
Example use:
V Net Present Value = ARRAYNPV({-100,30,30,30,30,30},10%)
returns 12.48
NPER: Number of periods to pay off an investment with a constant rate of <rate>
, a payment of <pmt>
, a present value of <pv>
and a future value of <fv>
(defaults to 0). If <type>
is 0 (default), payment is at start of period (step), otherwise payment is at end of period.
Syntax:
NPER(<rate>, <pmt>, <pv>, <fv>, <type>)
NPER(<rate>, <pmt>, <pv>, <fv>)
NPER(<rate>, <pmt>, <pv>)
Example use:
V Payment Periods = NPER(10%,-200,-2000,5000,0)
returns 5.87
NPV: Net Present Value (NPV) for a stream of cash flow which is either income (positive amount) or payments (negative amount) at a given discount rate. Each cash flow value is assumed to be the cash flow at the end of the current period (step). As the cash flow is accumulated over time, the value given at the end of the simulation is actually the Net Present Value from the perspective of the simulation start time.
Syntax:
NPV (<rate>, <amount>, <starttime>)
NPV (<rate>, <amount>)
Example use:
V Cash Flow = {-100,30,30,30,30,30}[step + 1]
V Result = NPV(10%, CashFlow, 0)
- In step 0, Cash Flow returns -100 and Result returns -90.91
- In step 1, Cash Flow returns 30 and Result returns -66.12
- In step 2, Cash Flow returns 30 and Result returns -43.58
- In step 3, Cash Flow returns 30 and Result returns -23.09
- In step 4, Cash Flow returns 30 and Result returns -4.46
- In step 5, Cash Flow returns 30 and Result returns 12.48
PMT: Payment for an investment with a constant rate of <rate>
over <nper>
periods (steps) with a present value of <pv>
and a future value of <fv>
(defaults to 0). If <type>
is 0 (default), payment is at start of period (step), otherwise payment is at end of period.
Syntax:
PMT(<rate>, <nper>, <pv>, <fv>, <type>)
PMT(<rate>, <nper>, <pv>, <fv>)
PMT(<rate>, <nper>, <pv>)
Example use:
V Payment = PMT (10%, 10, -2000, 1000, 0)
returns 262.75
PV: Present Value (PV) of an investment with a <rate>
over <nper>
periods (steps), with a payment of <pmt>
and a future value of <fv>
(defaults to 0). If <type>
is 0 (default), payment is at start of period (step), otherwise payment is at end of period.
Syntax:
PV(<rate>, <nper>, <pmt>, <fv>, <type>)
PV(<rate>, <nper>, <pmt>, <fv>)
PV(<rate>, <nper>, <pmt>)
Example use:
V Present Value = PV(10%, 3, -1000, 100, 0)
returns 2411.72
FV: Future Value (FV) of an investment with a <rate>
over <nper>
periods (steps), with a payment of <pmt>
and a present value of <pv>
(defaults to 0). If <type>
is 0 (default), payment is at start of period (step), otherwise payment is at end of period.
Syntax:
PV(<rate>, <nper>, <pmt>, <pv>, <type>)
PV(<rate>, <nper>, <pmt>, <pv>)
PV(<rate>, <nper>, <pmt>)
Example use:
V Future Value = FV(10%, 3, -1000, 100, 0)
returns 3176.90
Array Functions
Array functions can be part of an equation for any variable or decision that is an array.
ARRAYACCUM: Returns the cumulative value for each element in the array. In other words, the Nth element of the result is the sum of the Nth element and all preceding elements in the input. <array>
may be a multi-dimensional array, but only the first dimension is accumulated.
Syntax: ARRAYACCUM(<array>)
Example use:
V Cumulative Array[4] = ARRAYACCUM({10, 20, 30, 40})
returns {10, 30, 60, 100}
ARRAYALLOCP: Applies allocp function. Distributes supply across a vector of requests according to corresponding vector of priorities. The array dimensions of <priorityvector>
need to be identical (or a subset) of the array dimensions of <requestvector>
. An array with the same dimensions as <requestvector>
is returned.
Syntax: ARRAYALLOCP(<supply>,<requestvector>,<priorityvector>,<width>)
ARRAYAREAXY: Returns the area under the curve for an XY plot between x values <start>
and <end>
. Can be used to normalize a lookup graph. Note that the intervals between the x,y points are not interpolated.
Syntax: ARRAYAREAXY(<start>, <end>,{{X1, Y1}, {X2, Y2}, {X3, Y3}...})
Example use:
V Area = ARRAYAREAXY(0, 10, { {0,2},{5,2},{10,2} } )
returns 20
ARRAYAVG: Returns the average of the elements of an array.
Syntax: ARRAYAVG(<array>)
Example use:
V Average of Array = ARRAYAVG({0,10, 90, 100})
returns 50
ARRAYCOUNT: Counts the number of elements in an array.
Syntax: ARRAYCOUNT(<array>)
Example use:
V Number of Array Elements = ARRAYCOUNT({0, 10, 90, 100})
returns 4
ARRAYCOUNTEQ: Counts the number of elements in <array>
equal to <target>
.
Syntax: ARRAYCOUNTEQ(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTEQ(90, {0, 10, 90, 100})
returns 1
ARRAYCOUNTGT: Counts the number of elements in <array>
greater than <target>
.
Syntax: ARRAYCOUNTGT(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTGT(90, {0, 10, 90, 100})
returns 1
ARRAYCOUNTGTEQ: Counts the number of elements in <array>
greater than or equal to <target>
.
Syntax: ARRAYCOUNTGTEQ(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTGTEQ(90, {0, 10, 90, 100})
returns 2
ARRAYCOUNTLT: Counts the number of elements in <array>
less than <target>
.
Syntax: ARRAYCOUNTLT(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTLT(90, {0, 10, 90, 100})
returns 2
ARRAYCOUNTLTEQ: Counts the number of elements in <array>
less than or equal to <target>
.
Syntax: ARRAYCOUNTLTEQ(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTLTEQ(90, {0, 10, 90, 100})
returns 3
ARRAYCOUNTNEQ: Counts the number of elements in <array>
not equal to <target>
.
Syntax: ARRAYCOUNTNEQ(<target>, <array>)
Example use:
V Count of Elements = ARRAYCOUNTNEQ(90, {0, 10, 90, 100})
returns 3
ARRAYGRAPH: Returns the same value as GRAPH, except that the output argument is a one-dimensional array. Looks up a value from a table of equally spaced input values, with linear interpolation. The interpolation is based on a starting x value of <startx>
, with points spaced at equidistant intervals of <intervalx>
. If <input>
is below <startx>
, the result is <outval1>
. If <input>
is greater than the last x value, the result is the last output value.
Syntax: ARRAYGRAPH(<input>, <startx>, <intervalx>, {<outval1>, <outval2>, <outval3>, ...})
Example use:
V Result Over Time = ARRAYGRAPH(STEP, 0, 2, {10, 30, 0})
- In step 0, returns 10
- In step 1, returns 20
- In step 2, returns 30
- In step 3, returns 15
ARRAYGRAPHSTEP: Returns the same value as GRAPHSTEP, except that the output argument is a one-dimensional array. Looks up a value from a table of equally spaced input values with no interpolation. If <input>
is below <startx>
, the result is <outval1>
. If <input>
is greater than the last x value, the result is the last output value.
Syntax: ARRAYGRAPHSTEP(<input>, <startx>, <intervalx>, {<outval1>, <outval2>, <outval3>, ...})
Example use:
V Result Over Time = ARRAYGRAPHSTEP(STEP, 0, 2, {10, 30, 0})
- In step 0, returns 10
- In step 1, returns 10
- In step 2, returns 30
- In step 3, returns 30
ARRAYGRAPHXY: Looks up a value from a table of ordered pairs, with linear interpolation. If the lookup is not monotone (always increasing or always decreasing) there may actually be more than one value that would be applicable. In such a case the smallest such value will be returned. The <interpolation_mode>
is 0 for linear interpolation (the default), 1 to always use the start of a segment (similar to ARRAYGRAPHSTEP), and 2 to always use the end of a segment. The <extrapolation_mode>
is 0 for constant interpolation (default), 1 for linear interpolation, and -1 for no interpolation (return a NaN if the value is outside of the table boundary).
Syntax:
ARRAYGRAPHXY(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...}, <interpolation_mode>, <extrapolation_mode>)
ARRAYGRAPHXY(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...}, <interpolation_mode>)
ARRAYGRAPHXY(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...})
Example use:
V Result Over Time = ARRAYGRAPHXY(STEP, {{0,10},{2,5},{3,15}})
- In step 0, returns 10
- In step 1, returns 7.5
- In step 2, returns 5
- In step 3, returns 15
Extended example: compare & contrast with Vensim:
Vensim:
Crowding Effect Lookup([(0,0)-(4,2)],(0,0.333),(0.207951,0.403509),(0.66055,0.692982),(1,1),(1.65138,1.48246),(2.53211,1.80702),(3.21713,1.9386),(3.93884,2)
Crowding Effect = Crowding Effect Lookup(Rabbit Population / Carrying Capacity)
SimLang equivalent:
V Crowding Effect Lookup[1..8, 1..2] = {{0, 0.333}, {0.207951, 0.403509}, {0.66055, 0.692982}, {1, 1}, {1.65138, 1.48246}, {2.53211, 1.80702}, {3.21713, 1.9386}, {3.93884, 2}}
V Crowding Effect = ArrayGraphXY(Rabbit Population / Carrying Capacity, Crowding Effect Lookup)
ARRAYGRAPHYX: Looks up a value from a table of ordered pairs. Similar to ARRAYGRAPHXY, except that the input is looked up on the Y axis. If the lookup is not monotone (always increasing or always decreasing) there may actually be more than one value that would be applicable. In such a case the smallest such value will be returned. The <interpolation_mode>
is 0 for linear interpolation (the default), 1 to always use the start of a segment (similar to ARRAYGRAPHSTEP), and 2 to always use the end of a segment. The <extrapolation_mode>
is 0 for constant interpolation (default), 1 for linear interpolation, and -1 for no interpolation (return a NaN if the value is outside of the table boundary).
Syntax:
ARRAYGRAPHYX(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...}, <interpolation_mode>, <extrapolation_mode>)
ARRAYGRAPHYX(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...}, <interpolation_mode>)
ARRAYGRAPHYX(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...})
Example use:
V Result Over Time = ARRAYGRAPHYX(4, {{0,3},{2,5},{3,15}})
returns 1
ARRAYMAX: Returns the maxmium element of an array.
Syntax: ARRAYMAX(<array>)
Example use:
V Highest Number in Array = ARRAYMAX({0, 10, 90, 100})
returns 100
ARRAYMEDIAN: Returns the median value of an array.
Syntax: ARRAYMEDIAN(<array>)
Example use:
V Median Value of Array = ARRAYMEDIAN({0, 10, 90, 100})
returns 50
ARRAYMIN: Returns the minimum element of an array.
Syntax: ARRAYMIN(<array>)
Example use:
V Lowest Number in Array = ARRAYMIN({0, 10, 90, 100})
returns 0
ARRAYMIRR: Calculates the Modified IRR based on an array of cash flows. It considers both the cost of investment and the interest received on reinvestment of cash.
Syntax: ARRAYMIRR(<array>, <finance_rate>, <reinvestment_rate>)
where
array
is the array of cash flow valuesfinance_rate
is the interest rate you pay on the money used in cash flowsreinvestment_rate
is the interest you receive on the cash flows as you reinvest them
ARRAYPRODUCT: Returns the product of the elements of an array.
Syntax: ARRAYPRODUCT(<array>)
Example use:
V Product of Array = ARRAYPRODUCT({4, 2, 1, 3})
returns 24
ARRAYRANK: Calculates the relative rank (numerical order) of each element in the array. If the array contains duplicate items, the rank includes the number of duplicate items to the left of the current item. Output array must be the same size as the input array. Use this with INDEXOF to retrieve items with a particular order (e.g. the third smallest item in the list).
Syntax: ARRAYRANK(<array>)
Example use:
V Rank Array[4]= ARRAYRANK({400, 200, 200, 300})
returns the array {4, 1, 2, 3}V Rank Array[4]= ARRAYRANK({400, 200, 100, 300})
returns the array {4, 2, 1, 3}
ARRAYSLOPEXY: Returns the slope of a point on a line formed from a table of ordered pairs. The <extrapolation_mode>
is 0 to always report the slope as 0 outside of the table boundaries (default), 1 to use the same slope as the bordering segment, and -1 to always return a NaN if the value is outside of the table boundary.
Syntax:
ARRAYSLOPEXY(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...}, <extrapolation_mode>)
ARRAYSLOPEXY(<input>, {{X1, Y1}, {X2, Y2}, {X3, Y3}, ...})
Example use:
V Slope = ARRAYSLOPEXY(1, {{0,3},{2,5},{3,15}},0)
returns 1
ARRAYSORT: Sorts an array. Output array must be the same size as the input array. Typically used to sort one dimensional arrays. Multi-dimensional arrays may be given as input but only the first dimension is sorted.
Syntax: ARRAYSORT(<array>)
Example use:
V Sorted Array[4]= ARRAYSORT({40, 20, 10, 30})
returns the array {10, 20, 30, 40}
ARRAYSTDDEV: Returns the standard deviation of the elements of an array (similar to Excel's STDEVP function).
Syntax: ARRAYSTDDEV(<array>)
Example use:
V Standard Deviation = ARRAYSTDDEV({0, 10, 90, 100})
returns 45.27
ARRAYSUM: Returns the sum of all elements of an array.
Syntax: ARRAYSUM(<array>)
Example use:
V Total Value = ARRAYSUM({0, 10, 90, 100})
returns 200
FIRST: Takes a range, enumerated item, or element as an argument and returns the first enumerated item or array index.
Syntax: FIRST(<rangename>)
Example use:
R Array Range = 5..27
V First Element = FIRST(Array Range)
returns 5
FOREACH: Constructs a new array. This can be read "for each <item>
in <array_range>
, apply the <expression>
." See the Control Flow section for more information.
Syntax: FOREACH(<item>, <array_range>, <expression>)
Example use:
V New Array[4] = FOREACH(i, 1..4, i * 10)
returns the array {10, 20, 30, 40}
INDEXMAX: Returns the index of the largest value in a one-dimensional <array>
. For arrays with greater dimension, specify <dimension>
as an integer. 1 indicates the first dimension, 2 indicates the second dimension, 3 indicates the third dimension, etc. Default <dimension>
is 1.
Syntax:
INDEXMAX(<array>, <dimension>)
INDEXMAX(<array>)
Example use:
V Max Location = INDEXMAX({34, 78, 50, 67})
returns 2
INDEXMIN: Returns the index of the smallest value in a one-dimensional <array>
. For arrays with greater dimension, specify <dimension>
as an integer. 1 indicates the first dimension, 2 indicates the second dimension, 3 indicates the third dimension, etc. Default <dimension>
is 1.
Syntax:
INDEXMIN(<array>, <dimension>)
INDEXMIN(<array>)
Example use:
V Min Location = INDEXMIN({34, 78, 50, 67})
returns 1
INDEXOF: Returns the index of the <findval>
in a one-dimensional <vector>
, or NaN if not found. Starts at index <startindex>
if given.
Syntax:
INDEXOF(<findval>, <vector>, <startindex>)
INDEXOF(<findval>, <vector>)
Example use:
V Value Location = INDEXOF(50 ,{34, 67, 50, 78}, 0)
returns 3
INDEXGT: Returns the index of the first number greater than <findval>
in a one-dimensional <vector>
, or NaN if no match is found. Starts at index <startindex>
if given.
Syntax:
INDEXGT(<findval>, <vector>, <startindex>)
INDEXGT(<findval>, <vector>)
Example use:
V Value Location = INDEXGT(50 ,{34, 67, 50, 78}, 0)
returns 2
INDEXGTEQ: Returns the index of the first number greater than or equal to <findval>
in a one-dimensional <vector>
, or NaN if no match is found. Starts at index <startindex>
if given.
Syntax:
INDEXGTEQ(<findval>, <vector>, <startindex>)
INDEXGTEQ(<findval>, <vector>)
Example use:
V Value Location = INDEXGTEQ(50 ,{34, 67, 50, 78}, 0)
returns 2
INDEXLT: Returns the index of the first number less than <findval>
in a one-dimensional <vector>
, or NaN if no match is found. Starts at index <startindex>
if given.
Syntax:
INDEXLT(<findval>, <vector>, <startindex>)
INDEXLT(<findval>, <vector>)
Example use:
V Value Location = INDEXLT(50 ,{34, 67, 50, 78}, 0)
returns 1
INDEXLTEQ: Returns the index of the first number less than or equal to <findval>
in a one-dimensional <vector>
, or NaN if no match is found. Starts at index <startindex>
if given.
Syntax:
INDEXLTEQ(<findval>, <vector>, <startindex>)
INDEXLTEQ(<findval>, <vector>)
Example use:
V Value Location = INDEXLTEQ(50 ,{34, 67, 50, 78}, 0)
returns 1
INDEXNEQ: Returns the index of the first number not equal to <findval>
in a one-dimensional <vector>
, or NaN if no match is found. Starts at index <startindex>
if given.
Syntax:
INDEXNEQ(<findval>, <vector>, <startindex>)
INDEXNEQ(<findval>, <vector>)
Example use:
V Value Location = INDEXNEQ(50 ,{34, 67, 50, 78}, 0)
returns 1
LAST: Takes a range, enumerated item, or element as an argument and returns the last enumerated item or array index.
Syntax: LAST(<rangename>)
Example use:
R Array Range = 5..27
V Last Element = LAST(Array Range)
returns 27
MATRIXINVERT: Returns the inversion of a square m by m matrix.
Syntax: MATRIXINVERT(<squarematrix>)
Example use:
V Inverted Matrix[3,3] = MATRIXINVERT({{1,2,1},{3,4,-1},{0,2,0}})
returns the matrix { {0.25, 0.25, -0.75}, {0, 0, 0.5}, {0.75, -0.25, -0.25} }
MATRIXPRODUCT: Returns the product of two two-dimensional matrices. If <matrix1>
is m by n dimensions, and <matrix2>
is n by p dimensions, the resulting matrix is dimensioned m by p.
Syntax: MATRIXPRODUCT(<matrix1>, <matrix2>)
Example use:
V Matrix Product[2,3] = MATRIXPRODUCT({{1,2},{3,4}},{{1,2,3},{4,5,6}})
returns the matrix { {9, 12, 15}, {19, 26, 33} }
MATRIXTRANSPOSE: Transposes a two-dimensional matrix.
Syntax: MATRIXTRANPOSE(<matrix>)
Example use:
V Transposed Matrix[3,2] = MATRIXTRANSPOSE({{1,2,3},{4,5,6}})
returns the matrix { {1, 4}, {2, 5}, {3, 6} }
RANGECOUNT: Takes a range, enumerated item, or element as an argument and returns the number of elements in the range.
Syntax: RANGECOUNT(<rangename>)
Example use:
R Array Range = 5..27
V Number of Elements = RANGECOUNT(Array Range)
returns 23
Miscellaneous Functions
Time functions can be part of an equation for any variable or decision.
AVG: Returns the average of a list of arguments.
Syntax: AVG(<expression1>, <expression2>, ...)
Example use:
V Average Value = AVG(0, 10, 90, 100)
returns 50
BETADIST: Returns the cumulative beta probability density function.
Syntax: BETADIST(<x>, <alpha>, <beta>)
where
x
is the value of the functionalpha
andbeta
are parameter values
Example use:
V Cumulative beta probability density = BETADIST(2,8,10)
returns 1
BETAINV: Returns the inverse of the cumulative beta probability density for a specified beta distribution.
Syntax: BETAINV(<probability>, <alpha>, <beta>)
where
probability
is a probability associated with the beta distributionalpha
andbeta
are parameter values
Example use:
V Inverse of the cumulative beta probability density = BETAINV(0.685470581,8,10)
returns 0.5
BINOMDIST: Returns the individual term binomial distribution probability.
Syntax: BINOMDIST(<number_s>, <trials>, <probability_s>, <cumulative>)
where
number_s
is the probability associated with the functiontrials
is the number of trialsprobability_s
is the probability of success on each trialcumulative
indicates which form of the function to provide: if cumulative is 1, returns the cumulative distribution function; if cumulative is 0, returns the probability density function
Example use:
V Individual term binomial distribution probability = BINOMDIST(6,10,0.5,0)
returns 0.205078
EXPONDIST: Returns the exponential distribution.
Syntax: EXPONDIST(<x>, <lambda>, <cumulative>)
where
x
is the value of the functionlambda
is the parameter valuecumulative
indicates which form of the function to provide: if cumulative is 1, returns the cumulative distribution function; if cumulative is 0, returns the probability density function
Example use:
V Exponential Distribution= EXPONDIST(0.2,10,1)
returns 0.86466471676339
EXPRND: Returns a random number from an exponential distribution with a mean of <lambda>
(defaults to 1).
Syntax:
EXPRND(<lambda>)
EXPRND
Example use:
V Random Result = EXPRND(10)
- In step 0, returns 6.0985
- In step 1, returns 20.8459
- In step 2, returns 32.1514
- In step 3, returns 3.8784
FDIST: Returns the F probability distribution.
Syntax: FDIST(<x>, <degrees_freedom1>, <degrees_freedom2>)
where
x
is the value of the functiondegrees_freedom1
is the numerator degrees of freedomdegrees_freedom2
is the denominator degrees of freedom
Example use:
V F probability distribution = FDIST(15.20686486,6,4)
returns 0.01
FINV: Returns the inverse of the F probability distribution.
Syntax: FDINV(<probability>, <degrees_freedom1>, <degrees_freedom2>)
where
probability
is the probability associated with the functiondegrees_freedom1
is the numerator degrees of freedomdegrees_freedom2
is the denominator degrees of freedom
Example use:
V Inverse of the F probability distribution = FINV(0.01,6,4)
returns 15.20686486
GAMMADIST: Returns the gamma distribution.
Syntax: GAMMADIST(<x>, <alpha>, <beta>, <cumulative>)
where
x
is the value of the functionalpha
is a parameter valuebeta
is a parameter valuecumulative
indicates which form of the function to provide: if cumulative is 1, returns the cumulative distribution function; if cumulative is 0, returns the probability density function
Example use:
V Gamma Distribution = GAMMADIST(10.00001131,9,2,1)
returns 0.068094
GAMMAINV: Returns the inverse of the cumulative gamma distribution.
Syntax: GAMMAINV(<probability>, <alpha>, <beta>)
where
probability
is the probability associated with the functionalpha
is a parameter valuebeta
is a parameter value
Example use:
V Inverse of the cumulative gamma distribution = GAMMAINV(0.068094, 9, 2)
returns 10.00001131
GRAPH: Looks up a value from a table of equally spaced input values, with linear interpolation. The interpolation is based on a starting x value of <startx>
, with points spaced at equidistant intervals of <intervalx>
. If <input>
is below <startx>
, the result is <outval1>
. If <input>
is greater than the last x value, the result is the last output value.
Syntax: GRAPH(<input>, <startx>, <intervalx>, <outval1>, <outval2>, <outval3>, ...)
Example use:
V Result Over Time = GRAPH(STEP, 0, 2, 10, 30, 0)
- In step 0, returns 10
- In step 1, returns 20
- In step 2, returns 30
- In step 3, returns 15
GRAPHSTEP: Looks up a value from a table of equally spaced input values with no interpolation. If <input>
is below <startx>
, the result is <outval1>
. If <input>
is greater than the last x value, the result is the last output value.
Syntax: GRAPHSTEP(<input>, <startx>, <intervalx>, <outval1>, <outval2>, <outval3>, ...)
Example use:
V Result Over Time = GRAPHSTEP(STEP, 0, 2, 10, 30, 0)
- In step 0, returns 10
- In step 1, returns 10
- In step 2, returns 30
- In step 3, returns 30
HYPGEOMDIST: Returns the hypergeometric distribution.
Syntax: HYPGEOMDIST(<sample_s>, <number_sample>, <population_s>, <number_population>)
where
sample_s
is the number of successes in the samplenumber_sample
is the size of the samplepopulation_s
is the number of successes in the populationnumber_population
is the size of the population
Example use:
V HYPgeometric distribution= HYPGEOMDIST(1,4,8,20)
returns 0.363261
LIMITFLOW: Adjust a rate to keep one or two stocks non-negative. Assumes this element is an inflow or outflow for each stock. List just one stock when the flow is only used for that one stock. List two stocks when the flow is a positive flow (inflow) for one stock and a negative flow (outflow) for the other.
When trying to force a stock to be non-negative (zero or positive), all flows (inflows and outflows) should use this function.
This function assumes that the named stock(s) will follow a standard format of:
STOCK(<inflow1> + <inflow2> + ... - <outflow1> - <outflow2> ..., <initial value>)
Otherwise, LIMITFLOW will return NaN.
The <flowexpression>
is the original flow expression. This will be adjusted as necessary to keep the stock non-negative. Note that the value of the other flows for the stocks will affect whether this flow is adjusted. Outflows (or negative inflows) are prioritized with negative inflows draining from the stock first, followed by the outflows in the order listed in the STOCK function.
Syntax:
LIMITFLOW(<flowexpression>, <stock1>, <stock2>)
LIMITFLOW(<flowexpression>, <stock1>)
Example use:
V Factory Inventory = STOCK(-Shipments, 1000)
V Warehouse Inventory = STOCK(Shipments, 0)
V Shipments = LIMITFLOW(600, Factory Inventory, Warehouse Inventory)
In step 0,
Factory Inventory returns 1000, Warehouse Inventory returns 0, and Shipments returns 600
In step 1,
Factory Inventory returns 400, Warehouse Inventory returns 600, and Shipments returns 400
In step 2,
Factory Inventory returns 0, Warehouse Inventory returns 1000, and Shipments returns 0
In step 3,
Factory Inventory returns 0, Warehouse Inventory returns 1000, and Shipments returns 0
LOGINV: Returns the inverse of the lognormal cumulative distribution of x, where ln(x) is normally distributed with parameters <mean>
and <standard_dev>
.
Syntax: LOGINV(<probability>, <mean>, <standard_dev>)
Example use:
V Log Inverse = LOGINV(0.039084, 3.5, 1.2)
returns 4.000025
LOGNORMAL: Returns a random number from a log-normal distribution. This is equivalent to EXP(NORMAL()). If <mean>
is not specified it defaults to 0. If <standard-deviation>
is not specified it defaults to 1.
Syntax:
LOGNORMAL(<mean>, <standard-deviation>, <seed>)
LOGNORMAL(<mean>, <standard-deviation>)
LOGNORMAL(<mean>)
LOGNORMAL
Example use:
V Log Normal Distribution = LOGNORMAL(100)
returns 101.56 (for example)
LOGNORMDIST: Returns the cumulative lognormal distribution of <x>
, where ln(x) is normally distributed with parameters <mean>
and <standard_dev>
.
Syntax: LOGNORMDIST(<x>, <mean>, <standard_dev>)
where
x
is the value of the functionmean
is the meanstandard_dev
is the standard deviation
Example use:
V Cumulative Lognormal Distribution= LOGNORMDIST(4,3.5,1.2)
returns 0.039084
LOOKUP: Looks up a value by index. The index of the first value is assumed to be 0. Returns the first value with an index greater then or equal to input. If index is greater than the number of values, returns the last value.
Syntax: LOOKUP(<input>, <val1>, <val2>, <val3>)
Example use:
V Result Over Time = LOOKUP(STEP, 10, 30, 0, 50)
- In step 0, returns 10
- In step 1, returns 30
- In step 2, returns 0
- In step 3, returns 50
MAX: Returns the highest value in the list of arguments.
Syntax: MAX(<expression1>, <expression2>, ...)
Example use:
V Highest Value = MAX(100, -5, 300, 0)
returns 300
MIN: Returns the lowest value in the list of arguments.
Syntax: MIN(<expression1>, <expression2>, ...)
Example use:
V Lowest Value = MIN(100, -5, 300, 0)
returns -5
NORMAL: Returns a random number within a normal distribution with a mean of 0 and a standard deviation of 1.
Syntax:
NORMAL(<seed>)
NORMAL
Example use:
V Normal Distribution = NORMAL(6)
- In step 0, returns 0.5522
- In step 1, returns 0.2657
- In step 2, returns -0.3680
- In step 3, returns -1.1450
NORMDIST: Returns the normal distribution for the specified mean and standard deviation.
Syntax: NORMDIST(<x>, <mean>, <standard_dev>, <cumulative>)
where
x
is the value of the functionmean
is the meanstandard_dev
is the standard deviationcumulative
indicates which form of the function to provide: if cumulative is 1, returns the cumulative distribution function; if cumulative is 0, returns the probability density function
Example use:
V Normal Distribution = NORMDIST(42,40,1.5,1)
returns 0.908789V Normal Distribution = NORMDIST(42,40,1.5,0)
returns 0.10934005
NORMSDIST: Returns the standard normal cumulative distribution function of <z>
, the value of which you want the distribution. The distribution has a mean of 0 (zero) and a standard deviation of one.
Syntax: NORMSDIST(<z>)
Example use:
V Standard Distribution = NORMSDIST(0)
returns 0.5
NORMINV: Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation.
Syntax: NORMINV(<probability>, <mean>, <standard_dev>)
Example use:
V Inverse of normal cumulative distribution = NORMINV(0.908789, 40, 1.5)
returns 42
POISSON: Returns an integer number from a poisson distribution with a mean of <mean>
.
Syntax:
POISSON(<mean>, <seed>)
POISSON(<mean>)
Example use:
V Poisson Distribution = POISSON(10, 6)
- In step 0, returns 9
- In step 1, returns 11
- In step 2, returns 7
- In step 3, returns 10
RAND: Returns a random number between 0 and 1.
Syntax:
RAND(<seed>)
RAND
Example use:
V Uniform Distribution = RAND(6)
- In step 0, returns 0.5796
- In step 1, returns 0.7780
- In step 2, returns 0.1149
- In step 3, returns 0.3379
RANDBETWEEN: Returns a random number between <bottomvalue>
and <topvalue>
.
Syntax:
RANDBETWEEN(<bottomvalue>, <topvalue>, <seed>)
RANDBETWEEN(<bottomvalue>, <topvalue>)
Example use:
V Number Between 1 and 10 = RANDBETWEEN(1,10,6)
- In step 0, returns 6.2166
- In step 1, returns 8.0021
- In step 2, returns 2.0349
- In step 3, returns 4.0416
STDDEV: Returns the standard deviation of a list of arguments (similar to Excel's STDEVP function).
Syntax: STDDEV(<array>)
Example use:
V Standard Deviation = STDDEV(0, 10, 90, 100)
returns 45.27
SUM: Sums a list of arguments.
Syntax: SUM(<expression1>, <expression2>, ...)
Example use:
V Total Value = SUM(0, 10, 90, 100)
returns 200
TDIST: Returns the Percentage Points (probability) for the one tailed student t-distribution where a numeric value (x) is a calculated value of t for which the Percentage Points are to be computed.
Syntax: TDIST(<x>, <degrees_freedom>)
where
x
is the value of the functiondegrees_freedom
is the number of degrees of freedom
Example use:
V Percentage Points= TDIST(1.959999998,60)
returns 0.027322464
TINV: Returns the one-tailed t-value of the t-distribution as a function of the probability and the degrees of freedom.
Syntax: TDIST(<x>, <degrees_freedom>)
where
x
is the probability associated with the functiondegrees_freedom
is the number of degrees of freedom
Example use:
V T Value of T Distribution = TINV(0.054644927,60)
returns 1.63