コード例 #1
0
        public static IEnumerable <DataPoint> MovingAverage(this IEnumerable <DataPoint> data, int windowWidth)
        {
            var windowValues = new WindowValues <double>(windowWidth);
            var windowsSum   = 0.0;

            foreach (var dataPoint in data)
            {
                var tailY = windowValues.Length == windowWidth ? windowValues.Tail.Value : 0;
                windowValues.Append(dataPoint.OriginalY);
                windowsSum -= tailY;
                windowsSum += dataPoint.OriginalY;

                yield return(CreateDataPoint(dataPoint, windowsSum / windowValues.Length));
            }
        }
コード例 #2
0
 public WindowElementEnumerator(WindowValues <T> window)
 {
     this.window    = window;
     currentElement = null;
 }