standarddeviationcalculator.net SD Calculator

Weighted standard deviation calculator

Share this page

Favorites

    No favorites yet. Press Favorite on any page to keep it here.

    Methodology

    Enter each value with the weight it should carry. Weights can be any positive numbers (counts, allocations, or measures of confidence) and do not need to sum to 1. The result is the standard deviation around the weighted average, alongside that weighted mean.

    Value (x)Weight (w)Remove

    Weights may be counts, portfolio allocations, or any positive measure of importance. They do not need to sum to 1.

    Treat the data as

    The weighted standard deviation formula

    The weighted mean puts each value in proportion to its weight:

    μw = Σ(w·x) / Σw

    The weighted variance measures squared deviations from that mean, again weighted:

    Population: σ²w = Σw(x − μw)² / V₁ Sample: s²w = Σw(x − μw)² / (V₁ − V₂/V₁) where V₁ = Σw and V₂ = Σw²

    The sample denominator is the weighted analogue of Bessel's correction. Setting every weight to 1 makes V₁ = n and V₂ = n, so V₁ − V₂/V₁ becomes n − 1. The ordinary formula falls out as the special case, which is the sign that the generalisation is the right one.

    How to calculate a weighted mean and standard deviation: worked example

    The calculator starts with four values and their weights. By hand, the weighted SD takes five steps.

    Value (x)Weight (w)w·xx − μww(x − μw)²
    8.2541.0−0.49661.2328
    9.112109.20.40341.9532
    7.6322.8−1.09663.6073
    8.8979.20.10340.0963
    Total29252.26.8897
    1. Multiply each value by its weight and add. Σ(w·x) = 252.2. Add the weights: Σw = 29.
    2. Weighted mean (weighted average): μw = 252.2 ÷ 29 = 8.6966.
    3. Subtract the weighted mean from each value, square it and multiply by the weight. The total is 6.8897.
    4. Population weighted variance: 6.8897 ÷ 29 = 0.2376. Population weighted SD: √0.2376 = 0.4874.
    5. Sample form: Σw² = 259, so the denominator is 29 − 259 ÷ 29 = 20.069. Variance 6.8897 ÷ 20.069 = 0.3433, and the sample weighted SD is 0.5859, the figure the calculator shows when it loads in Sample mode. This is the reliability-weight denominator. If the weights were repeat counts, divide by Σw − 1 = 28 instead, which gives 0.4960.

    If you only need the weighted average, the weighted mean calculator stops at step 2.

    Two kinds of weight

    The distinction matters for which denominator is correct, and it is glossed over often enough to cause real disagreements between software packages.

    Frequency weightsReliability weights
    A weight of 5 meansThis value occurred 5 timesTrust this value 5× as much
    Effective nΣwV₁²/V₂ (Kish)
    Sample denominatorΣw − 1V₁ − V₂/V₁
    Typical useFrequency tables, talliesPortfolios, survey weights, meta-analysis

    This calculator uses the reliability-weight convention, which is what NIST and most statistical software implement. For frequency data (where a weight is genuinely a repeat count), the grouped data calculator is the better fit and uses Σf − 1.

    Where weighted spread is the honest measure

    • Portfolio risk. Holdings are weighted by allocation. A 40% position's volatility should count more than a 2% position's. (A full portfolio calculation also needs the covariances between holdings, this formula treats the values as independent.)
    • Survey data. Respondents carry design weights so the sample matches the population. Ignoring them biases both the mean and the spread.
    • Meta-analysis. Studies are weighted by precision, typically the inverse of their variance, so larger and tighter studies drive the pooled result.
    • Grades. A final exam worth 50% and a quiz worth 5% should not contribute equally to the spread of a student's performance.

    Weighted standard deviation in Excel

    Excel has no built-in weighted SD, so build it from array formulas:

    Weighted mean: =SUMPRODUCT(A2:A10, B2:B10) / SUM(B2:B10) Weighted var: =SUMPRODUCT(B2:B10, (A2:A10 - [mean])^2) / SUM(B2:B10) Weighted SD: =SQRT( [the above] )

    With values in column A and weights in column B. That gives the population form. For the sample form divide by SUM(B2:B10) - SUMSQ(B2:B10)/SUM(B2:B10) instead. The unweighted functions (STDEV.S, STDEV.P) are covered in the guide to standard deviation in Excel.

    Weighted standard deviation in Python and R

    Python (NumPy): import numpy as np x, w = np.array([8.2, 9.1, 7.6, 8.8]), np.array([5, 12, 3, 9]) m = np.average(x, weights=w) sd = np.sqrt(np.average((x - m)**2, weights=w)) R: m <- weighted.mean(x, w) sd <- sqrt(sum(w * (x - m)^2) / sum(w))

    Both give the population form (0.4874 for the example above). For the sample form, divide the weighted sum of squares by sum(w) - sum(w**2)/sum(w) instead of sum(w). See also standard deviation in Python and in R.

    Weighted standard deviation: the worked example on this page, with its result and chart
    Weighted standard deviation: the worked example above, at a glance.

    Common questions

    What is a weighted standard deviation?

    A standard deviation in which each value counts in proportion to a weight rather than counting once. It is used when observations differ in importance, reliability or size. For example a portfolio where each holding carries a different allocation.

    Do the weights need to add up to 1?

    No. The formula divides by the total weight, so any consistent positive scale works identically. Weights of 2, 3, 5 give exactly the same answer as 0.2, 0.3, 0.5.

    What is the n − 1 equivalent for weighted data?

    With reliability weights the bias-corrected denominator is V₁ − V₂/V₁, where V₁ = Σw and V₂ = Σw². When every weight equals 1 this reduces to n − 1, which is the check that it is the right generalisation.

    This is the "Sample" mode above. If your weights are frequency counts rather than reliabilities, the plain Σw − 1 is the more conventional denominator.

    When should I use frequency weighting instead?

    If a weight means "this value occurred w times", you are describing a frequency table, and the grouped data calculator matches that intent more directly. Reliability weights (where a weight means "trust this value more") belong here.