DataLab is a compact statistics package aimed at exploratory data analysis. Please visit the DataLab Web site for more information....



Mathematical Expressions in Import Scripts

The commands calc and emit in data extraction scripts may contain a mathematical or logical expression. This expression is not case sensitive. An expression may contain any number of user-defined variables, provided that the variable names are not equal to any of the reserved function names (see below). A user-defined variable always starts with a letter and may consist of any number of digits and letters and the underscore character ('_').

Care should be taken to avoid improper mixing of boolean and arithmetic subexpressions, for example:

(a>5) and (b=0) yields a boolean result, while
(a+5) and (b=0) yields an integer value (the and operator is used as a bitwise and)

The expression may use the following pre-defined constants, operators, and functions:

--- Constants ---
true logical true (or -1, if used as number)
false logical false (or 0, if used as number)
pi the number Pi (3.14159...)
--- Arithmetic Operators ---
+ sum: x+y
- difference: x-y
* product: x*y
/ division: x/y
# modulo: round(x) mod round(y)
^ power: exponentiation x^y , x>0, y..any real values
--- Logic Operators ---
> greater than
>= greater than or equal
= equal
>< not equal
< less than
<= less than or equal
and boolean or bitwise and
not boolean or bitwise not
or boolean or bitwise or
xor boolean or bitwise exclusive or
--- Functions ---
abs absolute value: abs(x), x..any real value
arccos inverse cosine: arccos(x), x..angle in radians
arcsin inverse sine: arcsin(x), x..angle in radians
arctan inverse tangens: arctan(x), x..angle in radians
cos cosine: cos(x), x..angle in radians
exp exponential function: exp(x)
frac fraction: frac(x) = x - int(x)
gauss gauss creates normally distributed random numbers with zero mean and unit standard deviation
int round towards zero: int(x)
lg decadic logarithm: lg(x)
ln natural logarithm: ln(x)
mean returns the mean of a list of variables: mean(list), with list containing a list of variables reparated by commas; a range of numbered variables may be abbreviated by the ':' sign (i.e. "xx8:11" expands to "xx8, xx9, xx10, xx11").
nddens density of the standard normal distribution: nddens(x)
ndint integral of the standard normal distribution from -infinity to x: ndint(x)
ndquant quantile of the standard normal distribution for a probability x: ndquant(x)
rand uniformly distributed random numbers: random(x), x..amplitude of noise (mean = 0.0)
round round to the nearest integer: round(x)
sign sign of x: sign(x)
sin sinus: sin(x)
sqr square: sqr(x)
sqrt square root: sqrt(x)
sum returns the sum of a list of variables: sum(list), with list containing a list of variables reparated by commas; a range of numbered variables may be abbreviated by the ':' sign (i.e. "zz1:3" expands to "zz1, zz2, zz3").
tan tangens: tan(x)
var returns the variance of a list of variables: var(list), with list containing a list of variables reparated by commas; a range of numbered variables may be abbreviated by the ':' sign (i.e. "xx8:10,aux4,y1:3" expands to "xx8, xx9, xx10, aux4, y1, y2, y3").

Hint: Please note that the mathematical expressions available for import scripts are quite similar to the expressions used for Math Transformations, except for predefined constants and variable identifiers.


Last Update: 2012-Dec-18