Talk:Algorithms for calculating variance: Difference between revisions

Content deleted Content added
m Algorithm IV: Added comment about correct variance formula
m Online algorithm: Suggestion for alteration of algorithm IV
Line 132:
[[User:Shauncutts|Shauncutts]] ([[User talk:Shauncutts|talk]]) 06:15, 29 January 2008 (UTC)
 
:Actually, I'm pretty sure the last line should be: Variance = S * n / ((n-1) * sumweight)
 
:(I just implemented this algorithm based on the original paper, and have been manually checking results - I'm going to edit the main page to reflect this)
 
:[[User:Anders gorm|Gorm]] ([[User talk:Anders gorm|talk]]) 12:28, 19 February 2008 (UTC)
 
 
Incidentally, would it not make sense to alter algorithm 4 by adding the temporary variables used in the original paper. This will save at least three operations per loop, at the cost of making it less readable. Specifically the algorith would then look like this:
 
n = 0
foreach x in the data:
if n=0 then
n = 1
mean = x
S = 0
sumweight = weight
else
n = n + 1
temp = weight + sumweight
Q = x-mean
R = Q*weight/temp
S = S + sumweight*R*Q
mean = mean + R
sumweight = temp
end if
end for
Variance = S * n / ((n-1) * sumweight) // if sample is the population, omit n/(n-1)
 
[[User:Anders gorm|Gorm]] ([[User talk:Anders gorm|talk]]) 12:28, 19 February 2008 (UTC)
 
===Minor spelling and grammar fixes===