What is the correction factor for weighted variance

Hi all,

What is the formula for the correction factor for a weighted variance?

Example:

using StatsBase 

v = [1,2,3]
p = [.3,.5,.2]
std(v, ProbabilityWeights(p); corrected=true)

Thanks!

I think that refers to Bessel’s correction.

3 Likes

It is still n/(n-1) .

The reason for the correction is the constraint by the sample mean which ‘reduces’ a degree of freedom.

2 Likes

Thanks, and sorry for the noise. I must have made an error when initially checking to see if it was n/(n-1). When I looked into the issue more, it seemed like there was disagreement on how it should be calculated for unequal weights. The example below demonstrates the factor is n/(n-1).

Thanks again!

using StatsBase
n = 10
f = n /(n - 1)

v = rand(n)
p = v ./ sum(v)
varc = var(v, ProbabilityWeights(p); corrected=true)
varu = var(v, ProbabilityWeights(p); corrected=false)

varc / varu