Median()

Summary

Computes the median of the elements of an array.

Syntax

avg_value = Median(array data_values)

Argument Contents
data_values An array of numbers

Returns

A real number equal to the median of the elements of data_values.

Notes

  • The array must contain numbers only. Other types, including null, are not allowed.

  • If there is an odd number of array elements, Median() returns the middle number in sorted order.

  • If there is an even number of array elements, Median() returns the average of the middle numbers in sorted order.

Examples

x = Median({1,3,5}) // x = 3.0
y = Median({4,1,3,5}) // y = (3+4)/2 = 3.5
z = Median({5,5,3,1}) // z = (3+5)/2 = 4.0

Error Codes

Error Type Meaning
Error The array contains values that are null or are not numbers

See Also

Function Summary
Mean() Returns the mean (average) of the elements of an array