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


Math Formulas - Constants, Variables, Operators

For entering mathematical formulas there are several special variables and constants, most of which are directly connected to the contents or indices of the data matrix:

Identifier Type Explanation
NCol const R/O Number of columns of the data matrix
NRow const R/O Number of rows of the data matrix
Pi const R/O The number Pi (3.14159...)
Cx var R/W Data in column x (x = 1..NCol)
Rx var R/W Data in row x (x =1..NRow)
Cx:Cy var R/W Data in columns x to y (x,y = 1..NCol)
Rx:Ry var R/W Data in rows x to y (x,y = 1..NRow)
CuRv:CxRy var R/W Data in a rectangular area of the data matrix which is bounded by the columns Cu and Cx and the rows Rv and Ry.
All var W/O All data of the data matrix; the identifier "All" is only allowed in the left part of an equation.
var R/O Current reference cell. This symbol indicates the value of the currently referenced cell when iterating through a range of cells.
Marked var W/O All marked cells of the data matrix; the identifier "Marked" is only allowed in the left part of an equation.
Rix var R/O Row index of the data matrix
Cix var R/O Column index of the data matrix

The following operators are currently available for mathematical transformations:

Operator Function Explanation Example
+ summation x+y c1+c2+c7 calculates the sum of the columns 1, 2, and 7
- subtraction x-y r5-r7 computes the difference between row 5 and 7
* multiplication x*y
/ division x/y
# modulo x#y, the modulo function returns the remainder of integer division of round(x)/round(y) c3#5 returns the values in column 3 modulo 5
^ exponentiation x^y , x,y..any real values
() parenthesis parenthesis can be used to change operator precedence (c1+c2)*(c3+c4) is different from c1+c2*c3+c4
ABS absolute value abs(x), x..any real number
ARCCOS inverse cosine arccos(x)
ARCSIN inverse sine arcsin(x)
ARCTAN inverse tangens arctan(x)
COS cosine cos(x), x..angle in radians cos(c1) returns the cosine of the values in column 1 (assuming that the column contains angles measured in radians)
EXP exponent exp(x)
FRAC decimal part of a real number frac(x) frac(-3.822) returns the value -0.822
GAUSS random number generates normally distributed random numbers with zero mean and unit standard deviation c1:=0.2*gauss+6.5 fills the column 1 with normally distributed random numbers having a mean of 6.5 and a standard deviation of 0.2
INT integer part of a real number int(x)
LG decadic logarithm lg(x)
LN natural logarithm ln(x)
MEAN returns the mean of a list of columns or rows mean(list), the list contains a list of columns or rows reparated by commas; a range of neighboring columns/rows may be abbreviated by the ':' sign. mean(r8:10,r5) calculates the mean of the rows 5, 8, 9, and 10.
NDDENS density y of the standard normal distribution at the position x 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 p ndquant(p)
RAND uniformly distributed random numbers random(x), x..amplitude of noise (mean = 0.0) rand(8) creates uniformly distributed random numbers in the range of -4 to +4
ROUND rounding to integer round(x)
SIGN returns the sign of variable x sign(x)
SIN sine sin(x), x..angle in radians sin(c1+pi/2) returns the sine of the values in column 1 plus pi/2 (assuming that the column contains angles measured in radians)
SQR square sqr(x)
SQRT square root sqrt(x), with x >= 0. Negative numbers generate an error message
SUM returns the sum of a list of columns or rows sum(list), the list contains a list of columns or rows reparated by commas; a range of neighboring columns/rows may be abbreviated by the ':' sign. sum(c2,c8:11) calculates the sum of the columns 2, 8, 9, 10, and 11.
TAN tangens tan(x), x..angle in radians tan(c4) returns the tangens of the values in column 4 (assuming the column contains angles measured in radians)
VAR returns the variance of a list of columns or rows var(list), the list contains a list of columns or rows reparated by commas; a range of neighboring columns/rows may be abbreviated by the ':' sign. var(c1:4,c7,c9) calculates the variance of the columns 1, 2, 3, 4, 7, and 9.

Hint: You should seriously consider to use the programming capabilities instead of the pocket calculator. The programming of DataLab provides much more flexibility (see section DLabPascal Scripts for more).