public static IEnumerable<double> ExponentialMovingAverage(this IEnumerable<double> source, double alpha) { double? last = null; return source.Select( value => { var average = last != null ? alpha*value + (1 - alpha)*last.Value : value; last = average; return average; }); }