0

I only get one value at a time in the system that I am developing. However whenever I get my first value I should already be able to calculate a variance. Every time I get a new value I should recalculate the variance. One important note is that I can't save any previous values, I should thus be able to calculate variances "on the fly".

Something like this is what I would need but for variances.

Thank you

traducerad
  • 101
  • 1
  • Please see http://stats.stackexchange.com/search?q=online+variance. – whuber Apr 04 '17 at 19:44
  • You could update the estimate using a recursive formula. However I don't follow your premise that you can estimate a variance based on only the first value. – Michael R. Chernick Apr 04 '17 at 19:45
  • 1
    @Michael Use the Normal MLE for variance: it works even with one value (and is zero, but so what?). – whuber Apr 04 '17 at 19:46
  • @whuber I guess that is fine for the algorithm as long as you don't take the first estimate seriously. – Michael R. Chernick Apr 04 '17 at 19:54
  • @whuber that looks very complicated.... – traducerad Apr 04 '17 at 20:08
  • @whuber the solution described at the other question didn't work for me. I exactly implemented that code and it didn't work. I guess it is because in my case n is always equal to 1. – traducerad Apr 04 '17 at 20:13
  • 1
    This brings us back to @Michael Chernick's comment: your situation makes little sense in that case. Exactly what do you mean by "n is always equal to 1"? After you have obtained a second value, you have *two* values. When the third comes in, you have *three*--and so on. The whole point of the duplicate is that to update the variance, as you request, you don't need to save the previous $n-1$ values. But you do need to save a little bit of information! – whuber Apr 04 '17 at 20:37
  • @whuber no because when the second value comes in I have to "throw away" the first value. I can only keep one value at a time (i.e. the current value) and the result of my calculation. – traducerad Apr 06 '17 at 03:48
  • And that is *precisely* what any "online" algorithm does, such as the one in the duplicate. In fact, you don't need to keep the current data value--you only need to keep (a) the current variance, (b) the current mean, and (c) the current count. That's all. – whuber Apr 06 '17 at 14:29

0 Answers0