Please enable JavaScript to view this site.

ESL Documentation

MATHLIB Subroutine

Return the median of the values in a float array.

call MEDIAN(ARRAY_FV, MEDIAN_VALUE_FV)

ARRAY_FV

A floating point array identifier.

MEDIAN_VALUE_FV

The name of a floating point variable to hold the result of the subroutine.

Description

Use this subroutine to return the median of all the values in a float array. The median is defined as follows:

For an odd number of elements in an array, it is the middle value when all elements are sorted by value.

For an even number of elements in an array, the median is the average of the two middle values after all elements in the array are sorted by value.

The MEDIAN( ) subroutine makes a copy of the array to sort it. The memory for the temporary array is allocated from local storage, and if this allocation generates an error, the output parameter is set to negative one (-1.0).

Errors

MEDIAN: memory allocation error; setting value to -1.0.

There is insufficient memory to allocate an array buffer, so the subroutine set MEDIAN_VALUE_FV to -1.0, placed this message in the ESL errorlog, and set errorlevel to 1.0.