HTBasic Help
×
Menu
Index
Median
Median of values in an array.
 
Loading        LOADSUB ALL FROM "MEAN.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB FNMedian FROM "MATHLIB.HTS"
 
Usage                REAL A(*),X
X=FNMedian(A(*))
 
Description                
FNMedian returns the median value or values of the elements in the array A. The median is the value which half the points in A are less than and half the points in A are greater than.
 
FNMedian computes the median by sorting the elements in the array A. If A has an even number of points, there are two central values in the return value in A. In this case, FNMedian returns the average of the two central values.
 
When it executes, FNMedian creates a temporary integer array to hold values used in sorting. This requires 2 bytes of memory per point in the array A. FNMedian causes an error if this amount is memory is not available.
Errors                
FNMedian causes an HTBasic error if its arguments is not a REAL array.
 
See Also
Mean, MAT SORT (in the HTBasic Reference Manual)