Function calls and parameters

Analytica provides a rich set of built-in functions including Math functions, array, statistical, Text, Date, Math, and Financial Functions, Probability Distributions, spreadsheet functions and more. You can also write and use your own User-defined Functions and Libraries).

Here are some simple expressions involving functions.

Exp(1) → 2.718281828459
Sqrt(3^2 + 4^2) → 5
Mod(7, 3) → 1
Normal(mean: 500, sdeviation: 100)
FindInText('ONE', 'Result is one or two.', caseInsensitive: True, return: 'S') → 'one'

You can see

Position-based function calls

With this conventional syntax, you just list the parameters after the function name between parentheses in the same sequence that they are defined for the function:

FunctionName(param1, param2, ...)

In a function call, each parameter may be a constant, name of a variable, or a more complex expression with operators, or function calls. In some cases, a parameter must be of an expected type -- for example, the second parameter of Sum must be an index to sum over:

Sum(Cash_by_year, Year)

Some parameters are optional, in which case you may omit them and the function will use default values.

Name-based function calls

With name-based syntax to call a function, you name each parameter, followed by a colon (:) and the value passed to that parameter. You may list the parameters in any order, and omit any optional parameters. For example, LogNormal has four parameters, of which you may provide any two to define the distribution:

LogNormal(median, gsdev, mean, stddev)

You can call it using name-based syntax:

LogNormal(mean: 10, stddev: 1.5)

This is equivalent to this position-based syntax, using extra commas to indicate omitted parameters:

LogNormal( , , 10, 1.5)

Name-based syntax is useful for functions with many optional parameters, since you don't have to count commas and remember the order of the parameters. It’s usually easier to read name-based function calls.

You may mix position- and named-based syntax if you use position for the initial parameters:

LogNormal(10, stddev: 4)

You may not use a position-based parameter after a name-based parameter:

LogNormal(mean: 10, 1.5) → syntax error

See Also


You are not allowed to post comments.