private void SmoothedCycleSubseriesDetrending(double[] c, FastLoess lowPass, double[] s) { for (int i = 0; i < s.Length; i++) { s[i] = c[i] - lowPass.Y[i]; } }
private void TrendSmooth(double[] deseasonSeries, int np, double[] t) { List <double> virtualDeseasonSeries = VirtualXValuesProvider.GetXValues(deseasonSeries.Length); FastLoess trender = new FastLoess(virtualDeseasonSeries, deseasonSeries, _isTemporal, Nt(np)); trender.Estimate(); for (int i = 0; i < deseasonSeries.Length; i++) { t[i] = trender.Y[i]; } }
private FastLoess LowPassFiltering(double[] c, int np) { List <double> c1 = MovingAverage(c, np); List <double> c2 = MovingAverage(c1, np); List <double> c3 = MovingAverage(c2, 3); List <double> virtualC3XValues = VirtualXValuesProvider.GetXValues(c3.Count); FastLoess lowPass = new FastLoess(virtualC3XValues, c3, _isTemporal, Nl(np)); lowPass.Estimate(); return(lowPass); }
private bool CycleSubseriesSmooth(double[] detrendedY, int np, double[] c) { for (int i = 0; i < np; i++) { _cycleSubSeries[i] = new List <double>(); _smoothedSubseries[i] = new List <double>(); } // obtain all the subseries for (int i = 0; i < detrendedY.Length; i++) { int cycleIndex = i % np; _cycleSubSeries[cycleIndex].Add(detrendedY[i]); } // smoothing on each subseries for (int i = 0; i < _cycleSubSeries.Length; i++) { List <double> virtualXValues = VirtualXValuesProvider.GetXValues(_cycleSubSeries[i].Count); FastLoess model = new FastLoess(virtualXValues, _cycleSubSeries[i], _isTemporal, Ns); model.Estimate(); // add a prior point _smoothedSubseries[i].Add(model.EstimateY(-1.0)); _smoothedSubseries[i].AddRange(model.Y); // add a after point _smoothedSubseries[i].Add(model.EstimateY(_cycleSubSeries[i].Count * 1.0)); } // c is the smoothed series, with _length + 2Np points. int index = 0; for (int i = 0; i < _smoothedSubseries[0].Count; i++) { for (int j = 0; j < _smoothedSubseries.Length; j++) { if (_smoothedSubseries[j].Count <= i) { break; } if (_smoothedSubseries[j][i].Equals(double.NaN)) { return(false); } c[index] = (_smoothedSubseries[j][i]); ++index; } } return(true); }