How to Calculate a Weighted Mean, Variance and Standard Deviation
Weighted statistics explained: frequency versus reliability weights, the right variance denominator, effective sample size and a full worked example.

How to Calculate a Weighted Mean, Variance and Standard Deviation
A plain average treats every value as equally important. Real data rarely works that way. A course grade counts more when it carries more credits, a survey answer counts more when it stands for more people, and a lab measurement counts more when its error is small. Weighting handles all of these, but the variance and standard deviation need care, because the right denominator depends on what the weights mean. This guide walks through the method and a full example, which you can reproduce in the weighted mean, variance and standard deviation calculator.
The weighted mean
Write the values as x₁ ... xₙ and the weights as w₁ ... wₙ, all positive. Let V₁ be the sum of the weights. The weighted mean is
x̄w = Σ wᵢ xᵢ / V₁.
Only the relative size of the weights matters for the mean. Weights of 3, 4 and 3 give the same mean as 30, 40 and 30 or 0.3, 0.4 and 0.3.
Two kinds of weights
For the variance, the meaning of the weights matters.
Frequency weights are whole-number counts: the value 70 appeared 3 times. The data are really a longer list written compactly, so the sample has V₁ observations and the usual n − 1 correction becomes V₁ − 1.
Reliability weights (also called importance or analytic weights) describe how much each value should count, not how many times it occurred. Rescaling them must not change the answer, so the correction uses V₂, the sum of the squared weights: the denominator is V₁ − V₂/V₁. This is the unbiased weighted variance given in the GNU Scientific Library manual and most statistics references.
In both cases the numerator is the weighted sum of squares, SS = Σ wᵢ (xᵢ − x̄w)². The population variance divides SS by V₁ alone.
Worked example
A student has three module scores: 80 with weight 3, 90 with weight 4 and 70 with weight 3.
- V₁ = 3 + 4 + 3 = 10.
- Σ wx = 240 + 360 + 210 = 810, so the weighted mean is 81.
- Deviations from 81 are −1, 9 and −11. SS = 3 × 1 + 4 × 81 + 3 × 121 = 690.
- Population variance: 690 / 10 = 69, standard deviation about 8.31.
- As frequency weights (ten scores in total): 690 / 9 ≈ 76.67, standard deviation about 8.76.
- As reliability weights: V₂ = 9 + 16 + 9 = 34, the denominator is 10 − 3.4 = 6.6, the variance is 690 / 6.6 ≈ 104.55 and the standard deviation about 10.22.
The same numbers give three different spreads, which is why you must decide what the weights mean before you report anything.
Effective sample size
With reliability weights you do not really have V₁ observations. The effective sample size n_eff = V₁² / V₂ measures how many equally weighted values the data are worth. Here it is 100 / 34 ≈ 2.94, close to the three actual values. If one weight dominates, n_eff drops towards 1 and any standard error grows accordingly. The calculator reports n_eff and uses it for the standard error of the weighted mean.
Weighted percentiles and the median
A weighted median is the value where the cumulative weight first reaches half the total. With the step method, sort the values, add up the weights and stop at 50 %. The midpoint method interpolates between the centres of the weight blocks and gives a smoother answer for continuous data. For the scores above, sorted as 70 (3), 80 (3), 90 (4), the cumulative shares are 30 %, 60 % and 100 %, so the step median is 80.
Common mistakes
- Dividing by n − 1 where n is the number of rows rather than the total weight.
- Using percentages as frequency weights. Percentages are reliability weights; treat them as such.
- Including zero or negative weights. Zero weights drop out; negative weights have no meaning here.
- Reporting a weighted standard deviation without saying which denominator you used.
Practising and saving
Type or paste values and weights into the table, choose the weight type and the worked steps update as you edit. The practice tab generates new data sets to try by hand, and the history keeps results you want to compare later. Export the table as CSV or print the working for an assignment.
Limits
The calculator handles one variable with positive weights. It does not perform weighted regression, survey-design variance estimation with strata and clusters, or inverse-variance meta-analysis with heterogeneity tests. For complex survey data, use software that knows the sampling design, because the formulas here are not a replacement for that.


