standarddeviationcalculator.net

Updated Free · runs in your browser

Statistics

Weighted median calculator

The weighted median is the value with half the total weight on each side. Enter values and their weights in any order; the calculator sorts them, builds the cumulative weight column and shows where it crosses the halfway mark.

Values and weights
Value xWeight wRemove

Weighted median 5
Weighted median5
Total weight100
Half the weight50
Unweighted median8
Weighted mean8.35
x (sorted)wCumulative wCumulative %
3303030%
5255555%
8106565%
12208585%
2015100100%
Σ100
Show the working, step by step
  1. Sort the rows by value, keeping each weight with its value.

    3 (w = 30), 5 (w = 25), 8 (w = 10), 12 (w = 20), 20 (w = 15)

  2. Add up the weights as you go down the list (cumulative weight).

    30, 55, 65, 85, 100

  3. Find half the total weight.

    Σw ÷ 2 = 100 ÷ 2 = 50

  4. The first cumulative weight to reach 50 is 55, at x = 5. Less than half the weight lies below it and less than half above it.

    weighted median = 5

Ignoring the weights, the ordinary median of the values is 8; with equal weights the two agree. The weighted mean, 8.35, is pulled by extreme values in a way the weighted median is not.

The method

1. Sort by value: x₁ ≤ x₂ ≤ … ≤ xₙ, keeping each weight wᵢ with its value 2. Cumulative weight: Cₖ = w₁ + w₂ + … + wₖ 3. Weighted median = the first xₖ with Cₖ ≥ Σw ÷ 2 (if Cₖ = Σw ÷ 2 exactly: the midpoint of xₖ and the next value)

A worked example (the default rows)

Five shops sell the same item at 12, 3, 20, 8 and 5 dollars, and the weights are each shop's share of sales: 20, 30, 15, 10 and 25 (percent).

Price x (sorted)Weight wCumulative w
33030
52555
81065
122085
2015100

The total weight is 100, so half is 50. The cumulative weight is 30 after the $3 shop and 55 after the $5 shop, so it first reaches 50 at x = 5. The weighted median price is $5: at least half of all sales happen at $5 or less, and at least half at $5 or more.

Compare the two other summaries. The ordinary median of the five prices is $8, because it counts each shop once regardless of how much it sells. The weighted mean is (3 × 30 + 5 × 25 + 8 × 10 + 12 × 20 + 20 × 15) ÷ 100 = $8.35, pulled up by the $20 shop.

The exact-half tie

Sometimes the cumulative weight lands exactly on half. Take 10, 20, 30 and 40 with a weight of 5 each: the total is 20, half is 10, and the cumulative weight is exactly 10 at x = 20. Half of the weight is at 20 or below and half is at 30 or above, so any value from 20 to 30 splits the weight evenly. There are three conventions:

  • Midpoint (used here): (20 + 30) ÷ 2 = 25. It matches the ordinary median when all weights are equal, which is why most statistics texts use it.
  • Lower weighted median: 20, the first value that reaches half.
  • Upper weighted median: 30, the first value that goes past half.

Some software (and some algorithm textbooks) returns the lower value, so a different program may report 20 for this data. The calculator warns when a tie occurs, so you know which convention the answer depends on.

Common mistakes

  • Not sorting by value first. The cumulative weight only means something in value order.
  • Looking for the value whose own weight is largest. That is the weighted mode, not the median.
  • Comparing the cumulative weight with half the number of rows instead of half the total weight.

Common questions

What is a weighted median?

The value that splits the total weight in half: sort the values, add up their weights in order, and take the value at which the running total first reaches half of the total weight. With equal weights it is the ordinary median.

What happens when the cumulative weight is exactly half?

Then half the weight lies at or below one value and half at or above the next, and every number between them splits the weight evenly. The usual convention, and the one used here, is to take the midpoint of the two values. For 10, 20, 30, 40 with equal weights of 5 the cumulative weight reaches exactly 10 of 20 at x = 20, so the weighted median is (20 + 30) ÷ 2 = 25, the same as the ordinary median.

Is the weighted median the same as the median of a frequency table?

Yes, when the weights are counts. A discrete series with values x and frequencies f is a list of weighted values, and its median is the weighted median. Weights can also be fractions or percentages, such as population shares, which a frequency table cannot hold.

Why use a weighted median instead of a weighted mean?

It resists outliers. One very large value with a small weight can move the weighted mean a long way but hardly moves the weighted median. That is why median household income across regions, or a typical price across shops of different sizes, is often a weighted median.

Do the rows have to be in order?

No. The calculator sorts them by value and keeps each weight with its value. Sorting is the step most often skipped by hand, and it changes the answer.