Overview

Purpose

Return the median of a numeric sample after validating that the input is one-dimensional, non-empty, and finite.

Parameters

  • x: sequence or array containing the data.

Returns

A float with the median of x.

Errors and exceptions

  • ValueError if x is empty.

  • ValueError if x is not one-dimensional.

  • ValueError if x contains NaN values or infinities.

Example

from mespy import median

value = median([3.0, 1.0, 2.0])
print(value)  # 2.0

Notes

The function delegates all preliminary validation to _as_float_vector.