Statistics Functions

statistics.median_grouped()

Estimate a median from grouped observations represented by bin midpoints. The supplied interval is the common bin width; the caller must ensure valid equally spaced bins.

Formal Syntax & Structure

python syntaxpython
statistics.median_grouped(data, interval=1.0)

Parameters & Attributes

NameTypeDescription
dataiterable of numbersObservations used by the statistic.
intervalfloatCommon positive bin width.

Return Value

float

Floating-point result; finite precision and domain restrictions apply.

Working Example

Example Snippetpython
import statisticsprint(statistics.median_grouped([10, 10, 20, 20, 20], interval=10))
Python Reference