Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

For our application, I'm trying to find a memory-efficient, incremental algorithm to maintain variance of geometric mean.

This "online algorithm" on Wikipedia seems excellent,

http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

however, I'm not sure if / how I can apply the same idea to geometric mean / variance.

Numerical stability is preferred, but probably not strictly necessary as our samples have limited precision - the range is between 1ms and 30,000ms (timeout - trim value) as integer, in lognormal distribution. Sample data are actually web site response time observed periodically BTW.

share|improve this question
    
I'm not I understand the question correctly. You've already linked to an algorithm that allows memory-efficient computation of the variance. This is a general algorithm for the variance of any data, so in particular you can apply it to the geometric mean. Are you looking for a memory-efficient algorithm to calculate the geometric mean itself? If so, just update the sum $S$ of the logarithms of the values in each step by adding the $k$-th logarithm, and obtain the geometric mean as $\exp(S/k)$. –  joriki Oct 4 '12 at 22:10
    
Ah, so I should store logarithm of everything (not exp()ing back), and I can use the same calculation? IOW, (log of n-th mean) = log of (n-1)-th mean + (log of n-th value + log of (n-1)-th mean) / n to keep track of geometric mean and so on? –  kenn Oct 4 '12 at 22:43
    
I'm not sure about M(2,n) though. sum of squares of differences will be log(x / geometric mean)^2 rather than (x - mean)^2 correct? No idea what the new recurrence equation for M(2,n) will be... –  kenn Oct 4 '12 at 22:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.