Median Calculator

Enter a list of numbers in one field. The median is the middle value after sorting. 12 7 9 3 18 sorts to 3, 7, 9, 12, 18, so the middle is 9. For the even list 4 10 2 8 the middle pair is 4 and 8, and their average is 6.

Input

Result

Enter a list of numbers to see the median.

One list field of any length. For even n the calculator averages the two middle values. Five separate fields live on the five-number median page.

How it works

How the median is computed for 12 7 9 3 18
list12 7 9 3 18
sort3, 7, 9, 12, 18
n5 (odd)
Me9

The median of a finite list of real numbers is the middle value after ascending order. For odd n take one central observation; for even n average the two central ones. The list 12 7 9 3 18 sorts to 3, 7, 9, 12, 18, so the median is 9. The list 4 10 2 8 sorts to 2, 4, 8, 10; the middle pair is 4 and 8, and the median is 6.

In descriptive statistics the median is the 50% quantile (second quartile). It is more resistant to outliers than the arithmetic mean: for 10 12 11 1000 the median is 11.5 and the mean is 258.25. Mathematical model: sample median as an order statistic x₍k₎ — NIST/SEMATECH e-Handbook; Wikipedia — Median.

The calculator uses the numbers you enter in the Numbers field (mediana-liczb-list). Separate them with spaces, semicolons, or commas. Write decimal 3.5 with one period or comma. Input order does not matter — the list is sorted. The neighboring five-field median page has fixed n = 5; here list length is free.

The result panel shows the median, n, parity, the sorted list, the middle value(s), the arithmetic mean of the same list, and min/max. The number line marks the points and the median location. An empty list produces no result.

Worked examples: 12 7 9 3 18 → 9; 4 10 2 8 → 6; 10 12 11 1000 → 11.5; 2 5 9 11 20 → 9; 1 1 2 3 100 → 2; 10 10 10 10 50 → 10; 3 6 9 12 → 7.5; −2 0 4 8 10 → 4.

Formula

Odd n = 2k+1: Me = x₍k+1₎ (middle order statistic). Even n = 2k: Me = (x₍k₎ + x₍k+1₎) / 2.

x₍1₎ ≤ … ≤ x₍n₎ are the list values after ascending sort. Index (zero-based): for odd n the middle index is (n−1)/2; for even n the pair is (n/2−1) and n/2.

Mathematical model: sample median as the 50% quantile / order statistic (descriptive statistics; NIST/SEMATECH e-Handbook; Wikipedia — Median).

Theory, domain, and limits

Definition

Let x₁, …, xₙ be a finite sample of real numbers, and let x₍₁₎ ≤ x₍₂₎ ≤ … ≤ x₍ₙ₎ be their ordered values (order statistics). The sample median Me is defined in two branches: when n = 2k+1 is odd, Me = x₍k+1₎; when n = 2k is even, Me = (x₍k₎ + x₍k+1₎)/2. That is the average-of-two-middles convention used in descriptive-statistics textbooks and in the NIST/SEMATECH e-Handbook of Statistical Methods. The median is the empirical ½-quantile (second quartile Q₂).

This page’s calculator accepts a list of any length in one text field, parses numbers (space, semicolon, comma as separator or decimal), sorts ascending, and applies the definition above. Computation: numeric sort, then either the middle element or the average of the central pair. It is not a density estimator or a weighted median — every successfully parsed value has weight 1.

In teaching practice it helps to separate the mathematical formula from floating-point limits: this calculator shows the browser’s floating-point computation (about 15–16 significant digits), not a paper proof of symbolic identities. When inputs are extreme, check the domain first, then the floating-point range.

Historical and conceptual context

The median as a “middle value” appears in nineteenth-century descriptive statistics beside the mean and the mode (measures of location). Francis Galton and later authors stressed resistance to extremes when describing incomes, heights, or test scores. In estimation theory the sample median estimates the population median; under a Laplace distribution it is more efficient than the mean. In robust statistics the median is an M-estimator with a high breakdown point (50%).

Conceptually the median is not the arithmetic, geometric, or harmonic mean. It is also not the midrange (average of min and max). It does not sort “by eye” — it needs a full ordering or an equivalent selection algorithm. This calculator does not compute confidence intervals or sign tests; it shows the point median of the entered list.

The sibling “median of five numbers” page has fixed n = 5 and five fields. Here n is free: a school list, grades, measurements. For the mean of the same list use the arithmetic-mean page.

Formal properties

Input: n ≥ 1 finite real numbers. Output: Me ∈ ℝ. Monotonicity: if every xᵢ rises (or does not fall), the median does not fall. Translation: Me(xᵢ + c) = Me(xᵢ) + c. Positive scaling λ > 0: Me(λx) = λ Me(x). For λ < 0 the order reverses and the median scales by λ (after sorting the scaled values).

Robustness: changing fewer than half the observations cannot move the median outside the range of the remaining values (breakdown point 50% for odd n in the classical sense). The mean has breakdown 0% — one infinite observation destroys the result. For 1 1 2 3 100 the median is 2 and the mean is 21.4.

Link to quantiles: Me = Q₀.₅. For odd n the median coincides with the middle element. For even n averaging the two middles is one of several software conventions; this calculator uses that classical average.

Full derivation

Step 1. Collect tokens from the list field and parse finite numbers into L = [y₁, …, yₙ], n ≥ 1.

Step 2. Order them: x₍₁₎ ≤ … ≤ x₍ₙ₎ (comparison sort on the number).

Step 3. If n is odd, let k = (n−1)/2 (zero-based). Then Me = x₍k+1₎ = L_sorted[k]. Example: n = 5, list 12 7 9 3 18 → 3, 7, 9, 12, 18 → Me = 9.

Step 4. If n is even, let i = n/2 − 1 and j = n/2. Then Me = (x₍i+1₎ + x₍j+1₎)/2. Example: n = 4, list 4 10 2 8 → 2, 4, 8, 10 → Me = (4+8)/2 = 6.

Step 5. Existence of the ordering follows from the total order on ℝ. The average of two middles is well-defined in ℝ. The browser result is a floating-point number.

Special cases

Examples: 12 7 9 3 18 → 9; 4 10 2 8 → 6; 10 12 11 1000 → 11.5; 2 5 9 11 20 → 9; 1 1 2 3 100 → 2; 10 10 10 10 50 → 10; 3 6 9 12 → 7.5; −2 0 4 8 10 → 4. Singleton: one number is its own median. All equal: Me equals that value.

Empty list: no result. Non-numeric tokens are skipped. Decimals with a period or a comma are equivalent. Zeros and negatives enter the sort like any other value.

When n = 2, the median is the average of both elements — the same as the midrange for a two-point sample. For larger n midrange and median diverge.

Numerical and computational notes

The calculator sorts the values as numbers, not as text. The sum of two middles divided by 2 is exact for typical school data; at extreme values remember the limited floating-point precision. Display formatting (en-US / pl-PL) does not change the internal value.

Parser: spaces and semicolons always separate; several commas without spaces treat the comma as a separator; a single comma inside a token is the decimal mark. The axis diagram marks the points and the median.

The calculator does not weight observations, does not auto-drop outliers, and does not compute an interquartile range — those belong to other tools.

Related notions and sources

Related: arithmetic mean, five-field median, min/max and range, quartiles, percentiles, mode. In estimation theory — efficiency of the median versus the mean under different distributions.

Sources: NIST/SEMATECH e-Handbook — Percentiles / measures of location; Wikipedia — Median; MathWorld — Statistical Median; intro-stats textbooks (order statistics). Educational tool — not a textbook substitute or a full research-sample analysis.

How to use

  1. Enter numbers in Numbers, separated by spaces, semicolons, or commas, for example 12 7 9 3 18.
  2. Write a decimal with one comma or one period, for example 3.5.
  3. Click Calculate or wait for the live result. Five numbers 12 7 9 3 18 give 9. Four numbers 4 10 2 8 give 6.
  4. Check the panel: median, n, parity, middle values, the mean of the same list, and the number line.
  5. The mean of the same list lives on arithmetic mean. Five separate fields — on the five-number median page.

Symbol glossary

For 12 7 9 3 18 the median is 9. For 4 10 2 8 the median is 6.

Me
Median after sorting. 12 7 9 3 18 gives 9. 10 10 10 10 50 stays at 10.
n
Count of successfully parsed values. Odd n → one middle; even n → average of two.
x₍k₎
k-th order statistic (k-th element of the sorted list).
list
Field mediana-liczb-list. Input order does not change the 9: 18 3 9 7 12 is the same five.
mean
Sum divided by n — in the panel for comparison and on the neighboring calculator. For 10 12 11 1000 median 11.5, mean 258.25.

Examples

Example 1

  • List: 12 7 9 3 18

9

What is the median of 12, 7, 9, 3 and 18? 9.

Example 2

  • List: 4 10 2 8

6

What is the median of 4, 10, 2 and 8? 6.

Example 3

  • List: 10 12 11 1000

11.5

What is the median of 10, 12, 11 and 1000? 11.5 (mean 258.25).

Example 4

  • List: 2 5 9 11 20

9

What is the median of scores 2, 5, 9, 11 and 20? 9.

Example 5

  • List: 1 1 2 3 100

2

What is the median of 1, 1, 2, 3 and 100? 2 (mean 21.4).

Example 6

  • List: 10 10 10 10 50

10

What is the median of 10, 10, 10, 10 and 50? 10.

Example 7

  • List: 3 6 9 12

7.5

What is the median of 3, 6, 9 and 12? 7.5.

Example 8

  • List: −2 0 4 8 10

4

What is the median of −2, 0, 4, 8 and 10? 4.

Related calculators

FAQ

What does this calculator compute?

It computes the median (middle value) of a list of numbers in one field. After ascending sort, an odd count takes the single middle value; an even count averages the two middle values. Example: 12 7 9 3 18 gives 9; 4 10 2 8 gives 6.

How does the median work for odd n?

The list is sorted ascending. The middle index is (n−1)/2 in zero-based indexing (or position (n+1)/2 from one). Three numbers 2, 3 and 7 give median 3 — with no averaging.

How does the median work for even n?

After sorting, take the two central values and average them. For 1, 4, 6, 10 the middle pair is 4 and 6, so the median is (4+6)/2 = 5. For 4 10 2 8 the middle pair is 4 and 8, result 6.

How is the median different from the arithmetic mean?

The mean divides the sum by n and feels every outlier. The median looks at order and the center. For 1 1 2 3 100 the median is 2 and the mean is 21.4. For 10 12 11 1000 the median is 11.5 and the mean is 258.25.

Does input order change the result?

No. The calculator sorts the list before choosing the middle. 18 3 9 7 12 gives the same median 9 as 12 7 9 3 18.

How do I separate numbers in the field?

Use spaces, semicolons, or commas between values. 3.5 (or 3,5) is one decimal, not two entries 3 and 5. With several commas and no spaces (e.g. 12,7,9) commas act as separators.

How is this different from the five-field median?

The neighboring five-number median page always has five separate fields and one middle (n = 5). Here one list field accepts any length — including even n and the average of two middles.

What if all values are equal?

The median equals that common value. Four tens and a fifty (10 10 10 10 50) give median 10, because after sorting the middle still sits on ten.

Does an empty list produce a result?

No. Without a valid number the panel returns to the placeholder. Tokens that are not numbers are skipped; if nothing parses, an error message appears.

Do the currency and unit settings in the page header affect the result?

No. The median depends only on the parsed numbers. The currency and unit settings in the page header do not affect this result.

How do I calculate the median?

Sort the numbers ascending. For odd n take the middle value; for even n average the two middle values. For 12 7 9 3 18: sort 3, 7, 9, 12, 18 → median 9. For 4 10 2 8: sort 2, 4, 8, 10 → (4+8)/2 = 6.

What is the median of 3, 7, 12, 20, 60 and 100?

After sorting the list is already ordered (n = 6). The middle pair is 12 and 20, so the median is (12+20)/2 = 16. Enter 3 7 12 20 60 100 in the list field.

What is the median of 12, 7, 9, 3 and 18?

9. After sorting: 3, 7, 9, 12, 18 — the middle is 9. That is the first example on the page; the same result after “Fill this example”.

Is the median resistant to outliers?

Yes, more than the arithmetic mean. For 1 1 2 3 100 the median is 2 and the mean is 21.4. For 10 12 11 1000 the median is 11.5 and the mean is 258.25. One extreme value does not move the ordered middle.

What is the middle value of a data set?

That is the everyday name for the median: after ordering the list, half the values lie below and half above the center. For odd n it is one element; for even n it is the average of the two middle values.

The result is the median after sorting: for 12 7 9 3 18 it is 9; for 4 10 2 8 it is 6. Five separate fields live on the five-number median page.

Knowledge sources

The median definition and examples below come from established sources.

Page Updated November 2, 2026.