Back: 5.3 Interaction functions Forward: 5.5 Auxiliary functions   FastBack: 5. Built-in Functions Up: 5. Built-in Functions FastForward: 6. Device Functions         Top: fsc2 Contents: Table of Contents Index: Index About: About This Document

5.4 Mathematical functions

The following mathematical function can be used in all section of an EDL script that allow the use of functions.

List of all mathematical functions:

`abs()'
`acos()'
`acosh()'
`asin()'
`asinh()'
`atan()'
`atanh()'
`ceil()'
`cos()'
`cosh()'
`float()'
`floor()'
`grandom()'
`index_of_max()'
`index_of_min()'
`int()'
`round()'
`max_of()'
`mean()'
`mean_part_array()'
`min_of()'
`random()'
`rms()'
`set_seed()'
`sin()'
`sinh()'
`sqrt()'
`square()'
`tan()'
`tanh()'
`add_to_average()'

Descriptions of mathematical functions:

`abs()'

Returns the absolute value of an integer or floating point number (or all the elements of an 1- or more-dimensional array) .

`acos()'

Returns the inverse of the cosine function of the argument (simple number or all elements of an 1- or more-dimensional array) as an angle in radian. The argument must be in the interval [-1, 1], the result an element of the interval [0, pi].

`acosh()'

Returns the inverse of the hyperbolic cosine function of the argument (simple number or all elements of an 1- or more-dimensional array ).

`asin()'

Returns the inverse of the sine function of the argument (simple number or all elements of an 1- or more-dimensional array) as an angle in radian. The argument must be in the interval [-1, 1], the result an element of the interval [-pi/2, pi/2].

`asinh()'

Returns the inverse of the hyperbolic sine function of the argument (simple number or all elements of an 1- or more-dimensional array).

`atan()'

Returns the inverse of the tangent function of the argument (simple number or all elements of an 1- or more-dimensional array) as an angle in radian, the result an element of the interval [-pi, pi].

`atanh()'

Returns the inverse of the hyperbolic tangent function of the argument (simple number or all elements of an 1- or more-dimensional array).

`ceil()'

Converts a floating point number (or all the elements of an 1- or more-dimensional array) to the smallest integer that is not less than the argument, i.e.

 
round( 8.6 ) = 9     round( -8.6 ) = -8

`cos()'

Returns the cosine of the argument (simple number or all elements of an 1- or more-dimensional array), with the argument interpreted as the angle in radian.

`cosh()'

Returns the hyperbolic cosine of the argument (simple number or all elements of an 1- or more-dimensional array).

`float()'

Converts a number (or all the elements of an 1- or more-dimensional array) to floating point type.

`floor()'

Converts a floating point number (or all the elements of an 1- or more-dimensional array) to the largest integer that is not larger than the argument, i.e.

 
floor( 8.6 ) = 8    floor( -8.6 ) = -9

`grandom()'

If called without an argument the function returns one of a set of pseudo-random number with Gaussian distribution, a mean of zero and a variance of 1. If called with a non-zero, positive argument it returns an array of Gaussian distributed random numbers where the argument specifies the size of the array. These random numbers are probably better suited for simulating noise than the ones returned by random().

`index_of_max()'

The function expects a 1-dimensional array as its only argument and returns the index of the largest element in the array. If there's more that one element having the maximum value in the array the index designates the first of these elements.

`index_of_min()'

The function expects a 1-dimensional array as its only argument and returns the index of the smallest element in the array. If there's more that one element having the minimum value in the array the index designates the first of these elements.

`int()'

Converts a number (or all the elements of an 1- or more-dimensional array) to integer type by truncating all digits following the decimal point.

`round()'

Converts a floating point number (or all the elements of an 1- or more-dimensional array) to the nearest integer, i.e.

 
round( 8.5 ) = 9    round( 8.49 ) = 8    round( -1.75 ) = -2

`max_of()'

Returns the largest value of all arguments. Arguments can be any number of numbers or 1- or more-dimensional arrays. If all arguments are integer numbers an integer number is returned, otherwise a floating point value.

`mean()'

Expects an 1- or more-dimensional array as input and returns the mean value of the array elements. Optionally, it accepts up to two more integer arguments, the start index of the first element of the (1-dimensional) array or the index of the first sub-matrix (for more-dimensional array) to be included into the calculation and the number of elements to be used. If the length parameter is missing all elements up to the end of the 1D-array or all remaining sub-matrices of the more-dimensional array are used, otherwise only the number of elements or sub-arrays specified as the third argument are used. .

`mean_part_array()'

The function expects as its arguments an 1-dimensional arrays of integers or floats and a positive integer, with the length of the array being an integer multiple of this number. The array is now split into chunks of this size and the chunks are averaged. The resulting 1-dimensional float array is returned. This function is meant to speed up calculations in cases where a repeated signal, that has been sampled several times and is stored in a flat array, is to be averaged.

Calling the function with a chunk size of 1 is equivalent to invoking the mean() function while calling it with a sub-partition size equal to the length of the array itself is equivalent to calling the float() function on the array.

`min_of()'

Returns the smallest value of all arguments. Arguments can be any number of numbers or 1- or more-dimensional arrays. If all arguments are integer numbers an integer number is returned, otherwise a floating point value.

`random()'

If called with no argument the function returns a single pseudo-random number in the interval [0, 1]. If called with a non-zero, positive argument it returns an array of random numbers where the argument specifies the size of the array.

`rms()'

Expects an one-dimensional array as input and returns the square root of the sum of the squared array elements, divided by the number of elements. Optionally, it accepts up to two more integer arguments, the index of the first element of the 1-dimensional array or the index of the first sub-matrix (for more-dimensional arrays) to be included into the calculation and the number of elements to be used. If the length parameter is missing all elements up to the end of the array or all remaining sub-arrays are used, otherwise only as many array elements or sub-matrices as specified by the third argument are used..

`set_seed()'

Sets a seed for the random number generator used in the functions random() and grandom(). The argument has to be a positive integer. Alternatively, when no argument is given, the time in seconds since 00:00:00 UTC, January 1, 1970 is used as the seed.

`sin()'

Returns the sine of the argument (simple number or all elements of an 1- or more-dimensional array), with the argument interpreted as the angle in radian.

`sinh()'

Returns the hyperbolic sine of the argument (simple number or all elements of an 1- or more-dimensional array).

`sqrt()'

Returns the square root of an integer or floating point number (or all the elements of an 1- or more-dimensional array). The argument must be a positive number.

`square()'

Returns the square of an integer or floating point number (or all the elements of an 1- or more-dimensional array).

`tan()'

Returns the tangent of the argument (simple number or all elements of an 1- or more-dimensional array), with the argument interpreted as the angle in radian.

`tanh()'

Returns the hyperbolic tangent of the argument (simple number or all elements of an 1- or more-dimensional array).

`add_to_average()'

This is a utility functions to simplify (and speed up) the calculation of averaged data. It takes three arguments, as the first an already averaged (floating point) value or an array of such values, as the second a new value to be added to the average or an array of such data (obviously, both the first and the second argument must be either both simple values or arrays, and if they are arrays, must have the same lengths), and the third argument must be the an integer value which is the new count of the number of data sets having contributed to the average (i.e. if the average consists of already N data sets and now a new one gets added then this value must be N + 1).

With this function you can simply write

 
avg = add_to_average( avg, data, N + 1 );

instead of

 
avg = ( N * avg + data ) / ( N + 1 );

which is not only simpler to read but also a lot faster.


Back: 5.3 Interaction functions Forward: 5.5 Auxiliary functions   FastBack: 5. Built-in Functions Up: 5. Built-in Functions FastForward: 6. Device Functions

This document was generated by Jens Thoms Toerring on October, 4 2009 using texi2html 1.78.