How to calculate simple moving average faster in C#?

后端 未结 14 2507
囚心锁ツ
囚心锁ツ 2020-12-15 06:42

What is the fastest library/algorithm for calculating simple moving average? I wrote my own, but it takes too long on 330 000 items decimal dataset.

  • period /
14条回答
  •  囚心锁ツ
    2020-12-15 07:01

    These days, the Math DotNet library has a class called RunningStatistics that will do this for you. If you want to do it over the last "X" items only, use MovingStatistics instead.

    Both will calculate running averages, variance, and standard deviation, on the fly with one-pass only and without storing extra copies of the data.

提交回复
热议问题