Is there a way to calculate a running standard deviation without storing all previous items? For instance, a running average can be kept by storing the sum of all previous items and item count. Is there a way to keep a running standard deviation by storing less data than all the previous items? I can't think of a way to do it.

6 Comments

the Pirate said:

You could proably do it with a Visual Basic Macro and run in in Excel. I've used it for some runge-kutta approximations of DO depletion and regeneration on 15 minute intervals set it up to only output the value at the hour plus the minimum DO is it did not occur on the hour.

Ben Bateman said:

Yes, I think you can. Look at the method at the bottom of this page:
http://www.med.umkc.edu/tlwbiostats/variability.html

With this method, it seems that all you need is a count, a running sum, and a running sum of squares. Your SD is: square root of[(sum of Xsquared -((sum of X)*(sum of X)/N))/ (N-1))]

I'm not sure how that would work if your scores included negative numbers. You would probably need to add a minus sign to that entry in your sum of squares.

tP: I don't want to use Excel though. It's easy to do if you store every previous value, but that can take a lot of space.

BB: Looks good, I'll have to try it with real data. Thanks!

the Pirate said:

The space issue is addressed when you write a visual basic macro to do the work and set the output to only be the result. You could do it with a loop function.

jez said:

i can confirm bateman's method, no need to worry about signs.

tP: No, the "space" is still used in memory :)

jez: Thanks, I didn't think the signs would be an issue, glad you check it.

Leave a comment

The comment login system is acting strange. If you get an error message saying you aren't logged in when you are, just reload the comment page and try again. I'm trying to track this bug down, but it's not easy.

Supporters

Email plasticATgmailDOTcom for text link and key word rates.

Site Info

Support