public SeasonalTrendLoess buildSmoother(double[] data) { this.sanityCheck(data); if (this.fPeriodic) { this.fSeasonalWidth = (100 * data.Length); this.fSeasonalDegree = 0; } else if (this.fSeasonalDegree == 0) { this.fSeasonalDegree = 1; } var seasonalSettings = buildSettings(this.fSeasonalWidth, this.fSeasonalDegree, this.fSeasonalJump); if (this.fFlatTrend) { this.fTrendWidth = 100 * this.fPeriodLength * data.Length; this.fTrendDegree = 0; } else if (this.fLinearTrend) { this.fTrendWidth = 100 * this.fPeriodLength * data.Length; this.fTrendDegree = 1; } else if (this.fTrendDegree == 0) { this.fTrendDegree = 1; } if ((this.fTrendWidth == 0)) { this.fTrendWidth = SeasonalTrendLoessBuilder.calcDefaultTrendWidth(this.fPeriodLength, this.fSeasonalWidth); } LoessSettings trendSettings = this.buildSettings(this.fTrendWidth, this.fTrendDegree, this.fTrendJump); if ((this.fLowpassWidth == 0)) { this.fLowpassWidth = this.fPeriodLength; } LoessSettings lowpassSettings = this.buildSettings(this.fLowpassWidth, this.fLowpassDegree, this.fLowpassJump); var stl = new SeasonalTrendLoess(data, this.fPeriodLength, this.fInnerIterations, this.fRobustIterations, seasonalSettings, trendSettings, lowpassSettings); return(stl); }
public SeasonalTrendLoess(double[] data, int periodicity, int ni, int no, LoessSettings seasonalSettings, LoessSettings trendSettings, LoessSettings lowpassSettings) { this.fData = data; int size = data.Length; this.fPeriodLength = periodicity; this.fSeasonalSettings = seasonalSettings; this.fTrendSettings = trendSettings; this.fLowpassSettings = lowpassSettings; this.fInnerIterations = ni; this.fRobustIterations = no; this.fLoessSmootherFactory = new LoessBuilder(); this.fLoessSmootherFactory.Width = this.fTrendSettings.Width; this.fLoessSmootherFactory.Degree = this.fTrendSettings.Degree; this.fLoessSmootherFactory.Jump = this.fTrendSettings.Jump; this.fLowpassLoessFactory = new LoessBuilder(); this.fLowpassLoessFactory.Width = this.fLowpassSettings.Width; this.fLowpassLoessFactory.Degree = this.fLowpassSettings.Degree; this.fLowpassLoessFactory.Jump = this.fLowpassSettings.Jump; // var builder = new CyclicSubSeriesSmootherBuilder(); builder.Width = seasonalSettings.Width; builder.Degree = seasonalSettings.Degree; builder.Jump = seasonalSettings.Jump; builder.DataLength = size; builder.extrapolateForwardAndBack(1); builder.Periodicity = periodicity; /// this.fCyclicSubSeriesSmoother = builder.build(); this.fDetrend = new double[size]; this.fExtendedSeasonal = new double[(size + (2 * this.fPeriodLength))]; }