8
votes

I have several weighted values for which I am taking a weighted average. I want to calculate a weighted standard deviation using the weighted values and weighted average. How would I modify the typical standard deviation to include weights on each measurement?

This is the standard deviation formula I am using.

enter image description here

When I simply use each weighted value for 'x' and the weighted average for '\bar{x}', the result seems smaller than it should be.

1
How is this question related to this site? Isn't this belongs to Mathematics SEDavid Arenburg
@DavidArenburg This is something I am trying to program and likely others have/will also use in the future. I just added more to the answer I posted to identify how to efficiently code this.Steven C. Howell

1 Answers

13
votes

I just found this wikipedia page discussing data of equal significance vs weighted data. The correct way to calculate the biased weighted estimator of variance is

,

though the following, on-the-fly implementation, is more efficient computationally as it does not require calculating the weighted average before looping over the sum on the weighted differences squared

.

Despite my skepticism, I tried both and got the exact same results.

Note, be sure to use the weighted average

.