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
- NumPy covariance: frequency weights, relative weights and normalization — checked 1 November 2026.
- NumPy quantiles: weighted inverse CDF — checked 1 November 2026.
- R stats: type 7 sample quantiles — checked 1 November 2026.
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.