16 using System.Collections.Generic;
51 public static double[]
DifferenceSeries(
int d,
double[] series, out
double[] diffHeads)
53 diffHeads =
new double[d];
59 var localSeries = series;
60 for (var j = 1; j <= d; j++)
62 var result =
new double[localSeries.Length - 1];
63 diffHeads[j - 1] = localSeries.Last();
65 for (var i = 0; i <= localSeries.Length - 2; i++)
67 result[i] = localSeries[i] - localSeries[i + 1];
84 var localDiffs =
new Stack<double>(diffHeads.Reverse());
85 var localSeries = series.ToList();
86 while (localDiffs.Count > 0)
88 var first = localDiffs.Pop();
89 localSeries.Add(first);
93 return localSeries.ToArray();
103 public static double[][]
LaggedSeries(
int p,
double[] series,
bool includeT =
false)
106 var toArray =
new List<double[]>();
107 for (var t = p; t < series.Length; t++)
109 var localLag =
new List<double>();
110 for (var j = includeT ? 0 : 1; j <= p; j++)
112 localLag.Add(series[t - j]);
115 toArray.Add(localLag.ToArray());
118 return toArray.ToArray();
128 public static List<double>
CumulativeSum(List<double> series,
bool reverse =
false)
130 var localSeries = series;
133 localSeries.Reverse();
137 var outSeries =
new List<double>();
138 foreach (var val
in localSeries)