Defining User Functions |
![]() ![]() ![]() |
In Predictive Systems Lab, you can specify functions that can serve as filters to existing information by first defining the functions, and then applying them with the Apply User Function command in the Data Operations dialog box. They can also be used as neural activation functions in Predictive Systems Lab's artificial neural networks.
User functions are stored independently of documents and therefore are available to any document edited by Predictive Systems Lab when Predictive Systems Lab is ran from the computer where the function was defined.
The User Functions subsystem consists of a formal language, a functional expression parser, and a set of mathematical functions (see list of predefined functions). The value returned by a user function is the value to which the function evaluates.
The grammar of the language is based on standard mathematical notation, 5+3 for example, and consists of two kinds of expressions, namely constant expressions and variable expressions.
A constant expression is any expression that readily evaluates to a value. Examples of this type of expression are 5, 3+2, 10/2, SQRT(25), all of which evaluate to 5.
Variable expressions, on the other hand, are expressions that cannot be evaluated until execution time. As an example, consider 3*X, SQRT( ABS(X) ), and so forth.
Grammar
Function: |
Expression |
|
|
|
|
Expression: |
Variable |
| |
|
Constant |
|
|
|
|
Constant: |
Number |
| |
|
CONST |
| |
|
UOP Constant |
| |
|
Constant BOP Constant |
| |
|
( Constant ) |
| |
|
FN( CARGS ) |
|
|
|
|
Variable: |
X |
| |
|
ROW |
| |
|
COL |
| |
|
UOP Variable |
| |
|
Variable BOP Constant |
| |
|
Constant BOP Variable |
| |
|
Variable BOP Variable |
| |
|
( Variable ) |
| |
|
FN( VARGS ) |
|
|
|
|
CONST : |
PI |
| |
|
EN |
| |
|
INF |
|
|
|
|
UOP : |
- |
|
|
|
|
BOP : |
- |
| |
|
+ |
| |
|
/ |
| |
|
* |
| |
|
^ |
|
|
|
|
CARGS : |
Constant [, Constant]* |
|
|
|
|
VARGS : |
[<Constant | Valriable> ,]* Variable [, <Constant | Variable>]* |
|
Notation
· | CONST stands for any of the pre-defined constant symbols: PI (pi), EN (natural number e), INF (maximum machine double precision representation). |
· | UOP stands for unary operator, unary negation in this case. |
· | BOP stands for binary operator—subtraction, addition, division, multiplication and exponentiation, in that order of precedence. |
· | CARGS stands for a list of constant expression arguments, and VARG, for a list of arguments, of which at least one is a variable expression. |
· | FN stands for one of the predefined functions. |
· | Parentheses and commas stand literally. |
· | Brackets denote optional arguments (see note). |
· | Asterisks denote zero or more repetitions of the preceding optional expression (see note). |
· | Angle brackets denote grouping (see note). |
· | Vertical bars denote exclusive choice (see note). |
Notes
· | X, ROW and COL are language reserved words, used to denote (1) the function's argument, (2) the current processing worksheet row, and (3) the current processing worksheet column, respectively. When a function is evaluated out of a worksheet location context, as in the Test Function dialog box for example, the ROW and COL variables evaluate to zero; otherwise, the ROW and COL variables assume the row number and the column number, respectively, of the current processing worksheet cell. |
· | Consideration must be given to the use of parentheses when formulating functions with unary and binary operators in order to achieve the intended order of evaluation. As an example, the expressions 3^5*4 and 4*3^5 evaluate both to (3^5) * 4, whereas 3^(5*4) and (4*3)^5 evaluate to 3^20 and 12^5, respectively. The expression -3^5 reduces to -(3^5), whereas (-3)^5 should be expressed with the parentheses. The same care must be given to expressions dealing with mixed operators of distinct order of precedence. |
Examples of User Functions
Linear Function: |
3*X+1
|
Gaussian: |
EN^( -X^2/2) / (2*PI), or |
|
EXP(-X^2/2) / (2*PI)
|
Trigonometric: |
SIN(X) / COS(X)
|
Mixed: |
(3*X+1 - LN(ABS(X)) + SIN(X) - EN^(-X^2/2) / (2*PI)) / X, or |
|
(3*X+1 - LN(ABS(X)) + SIN(X) - EXP(-X^2/2) / (2*PI)) / X |
Predefined Mathematical Functions
Miscellaneous Functions
Function |
Syntax |
Description |
Absolute Value |
ABS( E ) |
Evaluates to the absolute value of expression <E>. |
Sign Function |
SGN ( E) |
Evaluates to -1, 0, or 1, depending whether expression <E> reduces to a negative number, zero, or a positive number, respectively. |
Floor Function |
FLOOR ( E ) |
Evaluates to the largest integer value less than or equal to expression <E>. |
Ceiling Function |
CEIL ( E ) |
Evaluates to the smallest integer value greater than or equal to expression <E>. |
Round Up |
ROUNDUP ( E ) |
Evaluates to the smallest integer value greater than expression <E> if expression <E> is greater than or equal to (FLOOR(<E>)+0.5). Otherwise, it evaluates to the largest integer value smaller than expression <E>. |
Round Down |
ROUNDDN ( E ) |
Evaluates to the smallest integer value greater than expression <E> if expression <E> is greater than (FLOOR(<E>)+0.5). Otherwise, it evaluates to the largest integer value smaller than expression <E>. |
Minimum |
MIN ( E1, E2 ) |
Evaluates to the smallest of the given arguments. |
Maximum |
MAX ( E1, E2 ) |
Evaluates to the largest of the given arguments. |
Threshold |
THRESH ( Low, High, E ) |
Evaluates to <Low> if expression <E> is smaller than <Low>, <High> if expression <E> is greater than <High>; to expression <E> otherwise. |
Floating-point Modulus |
FMOD ( E1, E2 ) |
Evaluates to the floating-point remainder of expression <E1> divided by expression <E2>. |
Logical Functions
Function |
Syntax |
Description |
Logical Not |
NOT ( E ) |
Evaluates to one (1) if the value of expression <E> is equal to zero; zero (0), otherwise. |
Logical And |
AND ( E1, E2 ) |
Evaluates to one (1) if both arguments are different from zero (0); zero (0), otherwise. |
Inclusive OR |
OR ( E1, E2 ) |
Evaluates to one (1) if at least one of the arguments is different from zero (0); zero (0), otherwise. |
Exclusive OR |
XOR ( E1, E2 ) |
Evaluates to one (1) if exactly one of the arguments is different from zero (0); zero (0), otherwise. |
Power, Exponential and Logarithmic Functions
Function |
Syntax |
Description |
Square |
SQR ( E ) |
Evaluates to the square value of expression <E>. |
Square Root |
SQRT ( E) |
Evaluates to the square root value of expression <E>. |
Exponential |
EXP ( E ) |
Evaluates to the exponential value of expression <E>. |
Natural Logarithm |
LN ( E ) |
Evaluates to the natural logarithm of expression <E>. |
Base-10 Logarithm |
LOG ( E ) |
Evaluates to the base-10 logarithm of expression <E>. |
Base-N Logarithm |
LOGN ( N, E ) |
Evaluates to the base-<N> logarithm of expression <E>. |
Trigonometric and Inverse Trigonometric Functions
Function |
Syntax |
Description |
Sine |
SIN ( E ) |
Evaluates to the sine of expression <E>. |
Inverse Sine |
ASIN ( E ) |
Evaluates to the arc sine of expression <E>. |
Cosine |
COS ( E ) |
Evaluates to the cosine of expression <E>. |
Inverse Cosine |
ACOS ( E ) |
Evaluates to the arc cosine of expression <E>. |
Tangent |
TAN ( E ) |
Evaluates to the tangent of expression <E>. |
Inverse Tangent |
ATAN ( E ) |
Evaluates to the arc tangent of expression <E>. |
Cotangent |
COT ( E ) |
Evaluates to the cotangent of expression <E>. |
Inverse Cotangent |
ACOT ( E ) |
Evaluates to the arc cotangent of expression <E>. |
Secant |
SEC ( E ) |
Evaluates to the secant of expression <E>. |
Inverse Secant |
ASEC ( E ) |
Evaluates to the arc secant of expression <E>. |
Cosecant |
CSC ( E ) |
Evaluates to the cosecant of expression <E>. |
Inverse Cosecant |
ACSC ( E ) |
Evaluates to the arc cosecant of expression <E>. |
Hyperbolic and Inverse Hyperbolic Functions
Function |
Syntax |
Description |
Hyperbolic Sine |
SINH ( E ) |
Evaluates to the hyperbolic sine of expression <E>. |
Inverse Hyperbolic Sine |
ASINH ( E ) |
Evaluates to the area hyperbolic sine of expression <E>. |
Hyperbolic Cosine |
COSH ( E ) |
Evaluates to the hyperbolic cosine of expression <E>. |
Inverse Hyperbolic Cosine |
ACOSH ( E ) |
Evaluates to the area hyperbolic cosine of expression <E>. |
Hyperbolic Tangent |
TANH ( E ) |
Evaluates to the hyperbolic tangent of expression <E>. |
Inverse Hyperbolic Tangent |
ATANH ( E ) |
Evaluates to the area hyperbolic tangent of expression <E>. |
Hyperbolic Cotangent |
COTH ( E ) |
Evaluates to the hyperbolic cotangent of expression <E>. |
Inverse Hyperbolic Cotangent |
ACOTH ( E ) |
Evaluates to the area hyperbolic cotangent of expression <E>. |
Hyperbolic Secant |
SECH ( E ) |
Evaluates to the hyperbolic secant of expression <E>. |
Inverse Hyperbolic Secant |
ASECH ( E ) |
Evaluates to the area hyperbolic secant of expression <E>. |
Hyperbolic Cosecant |
CSCH ( E ) |
Evaluates to the hyperbolic cosecant of expression <E>. |
Inverse Hyperbolic Cosecant |
ACSCH ( E ) |
Evaluates to the area hyperbolic cosecant of expression <E>. |
Bessel Functions
Function |
Syntax |
Description |
Bessel Function of the First Kind |
BESSEL1 ( N, E ) |
Evaluates to the Bessel function of the first kind of expression <E>, order <N>. |
Bessel Function of the Second Kind |
BESSEL2 ( N, E ) |
Evaluates to the Bessel function of the second kind of expression <E>, order <N>. |
![]() | Some of these functions may evaluate to #NaN for some range of argument values. |
Try Predictive Systems Lab
Need Help?
Contact support