Median

Median[list]

gives the median of the elements in list.

Median[dist]

gives the median of the distribution dist.

Details

  • Median is a robust location estimator.
  • Median[list] gives the center element in the sorted version of list, or the average of the two center elements if list is of even length.
  • Median[{{x1,y1,},{x2,y2,},}] gives {Median[{x1,x2,}],Median[{y1,y2,}],}.
  • Median[dist] is the minimum of the set of number(s) m such that Probability[xm,xdist]1/2 and Probability[xm,xdist]1/2.

Examples

open allclose all

Basic Examples  (3)

Find the middle value in the list:

Average the two middle values:

Median of a parametric distribution:

Scope  (15)

Data  (11)

Exact input yields exact output:

Approximate input yields approximate output:

Median for a matrix gives column-wise medians:

Median for a tensor gives column-wise medians at the first level:

Works with large arrays:

SparseArray data can be used just like dense arrays:

Find the median of WeightedData:

Find the median of EventData:

Find the median of TemporalData:

Find the median of a TimeSeries:

The median depends only on the values:

Find a three-element moving median:

Find the median of data involving quantities:

Distributions and Processes  (4)

Find the median for a parametric distribution:

Median for a derived distribution:

Data distribution:

Median for distributions with quantities:

Median function for a time slice of a random process:

Applications  (7)

The median represents the center of a distribution:

The median for a distribution without a single mode:

Find the median length, in miles, for 141 major rivers in North America:

Plot a Histogram for the data:

Probability that the length exceeds 90% of the median:

Smooth an irregularly spaced time series using a moving median:

A 90-day moving median:

Obtain a robust estimate of location when outliers are present:

Extreme values have a large influence on the Mean:

Compute medians for slices of a collection of paths of a random process:

Choose a few slice times:

Plot medians over these paths:

Find the median height for the children in a class:

Properties & Relations  (7)

Median is equivalent to a parametrized Quantile:

For nearly symmetric samples, Median and Mean are nearly the same:

For univariate data, Median coincides with SpatialMedian:

The Median of absolute deviations from the Median is MedianDeviation:

MovingMedian is a sequence of medians:

For any distribution, there is InverseCDF[dist,1/2]=Median[dist]:

Similarly for InverseSurvivalFunction:

For a continuous distribution, there is CDF[dist,Median[dist]]=1/2:

Similarly for SurvivalFunction:

For discrete distributions, the identity does not hold:

Possible Issues  (1)

Median requires numeric values:

Neat Examples  (1)

The distribution of Median estimates for 20, 100, and 300 samples:

Introduced in 2003
 (5.0)
 |
Updated in 2008
 (7.0)
2016
 (11.0)