Skip to content

Instantly share code, notes, and snippets.

View no-longer-on-githu-b's full-sized avatar

no longer on github no-longer-on-githu-b

View GitHub Profile
public static unsafe IEnumerable<double> MovingAverage(IList<double> list, int period)
{
double* doubles = stackalloc double[period];
double fraction = 1.0 / period;
double sum = 0;
for (int i = 0; i < period; i++)
{
double @double = list[i] * fraction;
doubles[i] = @double;
sum += @double;