Function calls and parameters
Analytica provides a large number of built-in functions for performing mathematical Math functions, array, statistical, Text, Date, Math, and Financial Functions. There are also probability distribution functions for uncertainty and sensitivity analysis. The Enterprise edition of Analytica also includes database functions. Finally, you can write and use your own user-defined functions (see User-defined Functions and Libraries).
Here are some simple examples of expressions involving functions.
Exp(1) → 2.718281828459
Sqrt(3^2 + 4^2) → 5 Mod(7, 3) → 1
Pmt(8%, 30, -1000) → $88.83
Normal(500, 100)
Position-based function calls: With this conventional syntax, you just list the parameters in sequence between parentheses after the function name:
FunctionName(param1, param2, ...)
In most cases, each parameter can be an expression built out of constants, variable names, operators, and function calls and so on.
You can omit any optional parameters if you want them to use their default value.
Name-based function calls: With this syntax, you name each parameter, followed by a colon (:) and the value passed to that parameter. Since the parameters are named, you can list them in any order. For example, this function has four parameters, of which you can provide any two to define the distribution:
LogNormal(median, gsdev, mean, stddev)
Calling it using name-based syntax:
LogNormal(mean: 10, stddev: 1.5)
is equivalent to the following using position-based syntax, which uses commas to indicate that the first two parameters are omitted:
LogNormal( , , 10, 1.5)
because mean
and stddev
(standard deviation) are the third and fourth parameters. Name-based syntax is useful for functions with many optional parameters. It’s usually easier to read name-based function calls because you don’t need to remember the ordering of the parameters.
See Also
- Using Named Parameters
- Function Parameter Qualifiers
- Parameter qualifiers
- ParameterEnumeration
- Conventions for parameters and operands
- Repeated parameters
- Repeated Parameter Forwarding
- User-Defined Functions
- Expression Syntax
- Expression Assist
- Procedural Programming Example
- Summary of Programming Constructs
Enable comment auto-refresher