Mathwords logoMathwords

Weighted Median — Definition, Formula & Example

Weighted median is the middle value of a data set in which some values count more than others. You find it by tracking total weight instead of counting values, and stopping where half the weight is used up.

Let x1<x2<⋯<xnx_1 < x_2 < \dots < x_n have nonnegative weights w1,…,wnw_1, \dots, w_n with total WW. A weighted median is any value mm for which the total weight of values below mm is at most W2\tfrac{W}{2} and the total weight of values above mm is at most W2\tfrac{W}{2}. If the running total equals exactly W2\tfrac{W}{2} at some xkx_k, every number from xkx_k to xk+1x_{k+1} qualifies, and a common convention averages xkx_k and xk+1x_{k+1}. When all weights are equal, the weighted median is the ordinary median.

Key Formula

∑xi<mwi≤W2and∑xi>mwi≤W2,W=∑i=1nwi\sum_{x_i < m} w_i \le \frac{W}{2} \quad \text{and} \quad \sum_{x_i > m} w_i \le \frac{W}{2}, \qquad W = \sum_{i=1}^{n} w_i
Where:
  • mm = the weighted median
  • xix_i = the data values, sorted from least to greatest
  • wiw_i = the nonnegative weight attached to xix_i (a count, share, or importance)
  • WW = the total of all weights

Worked Example

Problem: A food truck sold 100 items on Saturday: 10 items at $2, 30 at $3, 40 at $5, and 20 family meals at $20. Find the weighted median price, using the number sold as the weight.
Step 1: The prices are already sorted. Add the weights to get the total, then take half of it.
W=10+30+40+20=100,W2=50W = 10 + 30 + 40 + 20 = 100, \qquad \frac{W}{2} = 50
Step 2: Keep a running total of the weights. The running total first reaches 50 or more at the $5 price.
$2:10,$3:10+30=40,$5:40+40=80,$20:80+20=100\$2: 10, \quad \$3: 10 + 30 = 40, \quad \$5: 40 + 40 = 80, \quad \$20: 80 + 20 = 100
Step 3: Check both conditions for m=5m = 5. The weight below $5 is 40, and the weight above $5 is 20. Neither is more than 50.
10+30=40≤50,20≤5010 + 30 = 40 \le 50, \qquad 20 \le 50
Answer: The weighted median price is $5. For comparison, the weighted mean is $7.10, which the $20 meals pull upward. The ordinary median of the four menu prices is $4, a price no customer actually paid.

Why It Matters

The US Census Bureau reports median household income from surveys in which each sampled household stands for a different number of households. That makes the published figure a weighted median. The weighted median also minimizes the total weighted distance ∑wi∣xi−m∣\sum w_i |x_i - m|, so it answers location problems such as where along a highway to put a warehouse that serves towns of different sizes.

Common Mistakes

Mistake: Taking the ordinary median of the listed values and ignoring the weights. In the example, this gives the average of $3 and $5, which is $4.
Correction: Each weight tells you how many times a value effectively appears. Use the running total of weights and find where it first reaches half of W. When the weights are counts, this matches the ordinary median of the fully written-out list of 100 sales.

Related Terms