Difference between revisions of "Function calls and parameters"

m
Line 5: Line 5:
  
  
Analytica provides a large number of built-in functions for performing mathematical, array, statistical, textual, and financial computations. There are also probability distribution functions for uncertainty and sensitivity analysis. Other more advanced or specialized functions are described in [[Text, Date, Math, and Financial Functions]]. The Enterprise edition of Analytica also includes functions for accessing external ODBC data sources. Finally, you can write and use your own user-defined functions (see [[User-defined Functions and Libraries]]).
+
Analytica provides a large number of built-in functions for performing mathematical [[Math functions]], [[Array Functions and Operators|array]], [[Statistical functions|statistical]],  [[Text, Date, Math, and Financial Functions]]. There are also [[Probability Distributions|probability]] distribution functions for [[uncertainty]] and [[Sensitivity analysis functions|sensitivity analysis]]. The Enterprise edition of Analytica also includes database [[Database functions|functions]]. Finally, you can write and use your own user-defined functions (see [[User-defined Functions and Libraries]]).
  
'''Position-based function calls''': The conventional position-based syntax to call a function uses this form:
+
Here are some simple examples of expressions involving functions.
:<code>FunctionName(param1, param2, ...)</code>
 
 
 
You follow the function name by a comma-separated list of parameters enclosed between parentheses, with the parameters in the specified sequence. In most cases, parameters can them- selves be expressions built out of constants, variable names, operators, and function calls. Here are some simple examples of expressions involving functions.
 
 
:<code>Exp(1) &rarr; 2.718281828459</code>
 
:<code>Exp(1) &rarr; 2.718281828459</code>
 
:<code>Sqrt(3^2 + 4^2) &rarr; 5 Mod(7, 3) &rarr; 1</code>
 
:<code>Sqrt(3^2 + 4^2) &rarr; 5 Mod(7, 3) &rarr; 1</code>
Line 16: Line 13:
 
:<code>Normal(500, 100)</code>
 
:<code>Normal(500, 100)</code>
  
Some functions have optional parameters. In that case, you can simply omit the trailing parameters that will use their default values.
+
'''Position-based function calls''': With this conventional syntax, you just list the parameters in sequence between parentheses after the function name:
 +
:<code>FunctionName(param1, param2, ...)</code>
 +
 
 +
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''': Analytica also offers name-based parameter syntax as an alternative for calling most functions: 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:
+
'''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:
 
:<code>Lognormal(median, gsdev, mean, stddev)</code>
 
:<code>Lognormal(median, gsdev, mean, stddev)</code>
  

Revision as of 21:08, 19 April 2017



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


Comments


You are not allowed to post comments.