Functions

RiskScape allows user defined Python functions to be used for risk modelling. For more information, see Python functions.

RiskScape also provides some built-in functions for maths, geometry, and aggregation operations. These built-in functions are listed in the next section.

Functions can be used from any RiskScape expression. This includes both user-defined Python functions and built-in RiskScape functions. For example, to round a floating point number, you can use the round built-in function like round(-34.23).

Tip

Advanced users, who are familiar with the RiskScape expression language, can also build their own functions out of RiskScape expressions. See Expression language functions for more details.

Built-in function reference

RiskScape comes with the following sets of built-in functions that are useful for doing things like mathematics in the context of RiskScape and Risk Analysis.

Tip

You can also see a list of built-in functions available via the CLI. For example, to list the maths functions available in RiskScape, run riskscape function list --category maths

Where possible, RiskScape makes use of common Java packages that are widely used and are proven to produce reliable mathematical results. For example, the square_root() RiskScape function is just a simple ‘wrapper’ for the Java Math.sqrt() function.

Jython discrete functions

For users defining their own Jython functions, RiskScape also makes some maths functionality available for historic reasons. See Jython discrete functions for more details. However, most users will probably find it simpler to use CPython and the standard numpy or scipy libraries.