Weighted statistics

Row 1
Row 2

TSV: tabs between columns, newlines between rows. Blank cells are errors.

Every value needs a weight. Zero weights stay in the physical row count but are excluded from statistics. Frequency quartiles use type 7; relative/probability quartiles use inverse CDF. Sample denominators: frequency W − 1; relative W − sum(weight²)/W; no probability sample correction.

Give the weights a meaning before calculating

Frequency weights are exact nonnegative repetition counts. Relative weights express relative importance or reliability. Probability weights are masses whose stored values must sum exactly to 1; use exact fractions when needed. Every value needs a matching weight. Zero-weight rows remain in the physical row count but are excluded from the effective observations.

Let W be the sum of positive weights. The weighted mean is sum(weight × value)/W. Population variance divides the weighted squared-deviation sum by W. Sample variance uses W − 1 for frequency weights and W − sum(weight²)/W for relative weights. The latter correction assumes suitable independent observations and reliability weights. Probability weights do not offer a sample correction.

Frequency quantiles use type-7 interpolation over the repeated observations, without expanding the rows. Relative and probability quantiles use the weighted inverse CDF: sort by value and select the first value whose cumulative weight reaches p × W. These conventions can produce different quartiles from the same value/weight pairs.

Worked example: values 10 and 20, weights 1 and 3

With frequency weights, there are two physical rows representing four observations. W = 4, the weighted sum is 1×10 + 3×20 = 70, and the mean is 35/2. The weighted squared-deviation sum is 75: population variance is 75/4 and sample variance is 75/(4 − 1) = 25. Type-7 Q1 is 35/2.

With relative weights, sum(weight²) = 10, so the sample denominator is 4 − 10/4 = 3/2 and sample variance is 50. The inverse-CDF Q1 is 10 because its weight reaches (1/4)×4 = 1. The median is 20. Probability weights 1/4 and 3/4 give the same mean and population variance, with no sample correction.

Load example fills the form without calculating. Choose its primary action to work it out.

Sources and related calculators

The method and worked example here are original. Sources describe the underlying mathematics or notation; calculation choices and limits are in the precision and syntax guide.