Skip to main content
Viva Calculator

Median Calculator

Calculate the median and quartiles of your dataset

Calculate Median

Enter your data values (minimum 2 numbers required) Use a dot for decimals (1.5); commas separate values, not decimal digits.

Method and source check

Last checked:

Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.

Method

Sort finite values, average the two middle values for even count, and compute Q1 and Q3 by linear interpolation at zero-based position (n−1)p for p=.25 and .75; IQR is Q3−Q1.

median = middle sorted value (odd n) or average of two middle values (even n)

Q(p) = linear interpolation at position (n−1)p

IQR = Q3−Q1

Variables and units

n
number of values
p
quantile proportion (.25 or .75)
Q1,Q3
first and third quartiles

Worked example

For sorted data 1,2,3,4, median is 2.5, Q1 is 1.75, Q3 is 3.25, and IQR is 1.5.

Limitations

Median, quartiles, IQR, and listed values are shown to four decimal places. Math.round retains the existing half-tie convention; if scaling for four-place rounding would overflow, the finite representable value is retained. Locale formatting is applied after numerical calculation.

  • Quartile methods vary between references and software; values can differ for small data sets.
  • This page uses (n−1)p interpolation, not the median-of-halves method.
  • Derived values outside the supported finite numerical range are rejected with a localized input-field error.
  • At least two finite values are required.
  • For 1,2,3,4,5 the median is 3, Q1 is 2, Q3 is 4.

Sources

How to Use

  1. Enter your data values separated by spaces, commas, or semicolons
  2. Ensure you have at least 2 numerical values
  3. Review the complete statistical analysis including IQR
  4. Use the results to understand data distribution and identify outliers

Calculate the median and quartiles of your dataset

Calculate the median of a dataset along with quartiles and interquartile range. Method: Sort finite values, average the two middle values for even count, and compute Q1 and Q3 by linear interpolation at zero-based position (n−1)p for p=.25 and .75; IQR is Q3−Q1.

For datasets with an odd number of values, the median is the middle value. For even-numbered datasets, it's the average of the two middle values. This makes the median particularly useful for understanding typical values in skewed distributions.

Understanding Quartiles

Quartiles divide your data into four equal parts:

  • Q1 = 1.75 (1,2,3,4; p=0.25)
  • Q2 = 2.5 (1,2,3,4; p=0.50)
  • Q3 = 3.25 (1,2,3,4; p=0.75)

Quartiles help understand the spread and distribution of your data, making them essential for statistical analysis and data visualization.

Interquartile Range (IQR)

The Interquartile Range (IQR) is the difference between the third and first quartiles (IQR = Q3 - Q1). It represents the middle 50% of your data and is a robust measure of variability.

The IQR often changes less than the range when one extreme value changes, but it is not immune, especially in small datasets. With this calculator, [1,100] gives IQR 49.5; changing 100 to 1000 gives IQR 499.5.

Outlier Detection Using IQR

The IQR method is a standard way to identify outliers:

  • Lower fence: Q1 - 1.5 × IQR
  • Upper fence: Q3 + 1.5 × IQR
  • Values below the lower fence or above the upper fence are considered outliers

This method helps identify unusual values that might represent measurement errors, special cases, or genuinely rare events in your data.

When to Use Median vs. Mean

Choose between median and mean based on your data characteristics:

SituationUse MedianUse Mean
Skewed data✓✗
Outliers present✓✗
Symmetric dataEither✓
Need mathematical properties✗✓
Income/wealth data✓✗
Temperature averagesEither✓

Worked scenario

Apply the result to the stated units and check the method limit.

  • Four measurements: 1,2,3,4 → median=2.5; Q1=1.75; Q3=3.25; IQR=1.5.

Method, example, rounding, and limits

Method: Sort finite values, average the two middle values for even count, and compute Q1 and Q3 by linear interpolation at zero-based position (n−1)p for p=.25 and .75; IQR is Q3−Q1.

Worked example: 1,2,3,4 → median=2.5; Q1=1.75; Q3=3.25; IQR=1.5.

Rounding: 4 decimal places. Displayed values are rounded as stated beside the result.

Limit: Quartile methods vary between references and software; values can differ for small data sets. Combinations outside the supported numeric range are rejected.

Reference: NIST. https://itl.nist.gov/div898/handbook/prc/section2/prc262.htm

Frequently Asked Questions

What's the difference between median and mean?
The median is the middle value when data is sorted, while the mean is the average of all values. The median is less affected by extreme outliers, making it better for skewed data like income distributions.
How do you calculate quartiles?
Method: Sort finite values, average the two middle values for even count, and compute Q1 and Q3 by linear interpolation at zero-based position (n−1)p for p=.25 and .75; IQR is Q3−Q1. 1,2,3,4 → median=2.5; Q1=1.75; Q3=3.25; IQR=1.5. Limit: Quartile methods vary between references and software; values can differ for small data sets.
What makes a good sample size for median calculation?
The calculator needs at least two finite values. Whether a sample is adequate for a broader conclusion depends on how it was collected and the question being asked; no universal count guarantees reliability.
How do I interpret the interquartile range?
Method: Sort finite values, average the two middle values for even count, and compute Q1 and Q3 by linear interpolation at zero-based position (n−1)p for p=.25 and .75; IQR is Q3−Q1. 1,2,3,4 → median=2.5; Q1=1.75; Q3=3.25; IQR=1.5. Limit: Quartile methods vary between references and software; values can differ for small data sets.
Can the median be the same as the mean?
Yes. Symmetric data can have the same mean and median, but equality alone does not prove symmetry: [0,0,3,4,8] has mean and median 3 despite being asymmetric.
How are outliers identified using the IQR method?
Values below Q1 - 1.5×IQR or above Q3 + 1.5×IQR are flagged as possible outliers. These fences do not identify a fixed percentage of observations or prove that a value is an error.
Should I remove outliers from my data?
Not automatically. First investigate whether outliers are data errors, special cases, or legitimate extreme values. The decision depends on your analysis goals and the context of your data.
Can negative numbers have a median?
Absolutely. The median calculation works with any real numbers, positive or negative. The median simply represents the middle value regardless of sign.