DoubleExponentialSmoothing extends AbstractExponentialSmoothing { public static DoubleExOptimizer optimizer() { return new DoubleExOptimizer(new ImmutableMetricContext(null, null, 1L)); } private  DoubleExponentialSmoothing(double levelSmoothing, double trendSmoothing, MetricContext metricContext); static DoubleExponentialSmoothing createDefault(); static DoubleExponentialSmoothing createWithMetric(MetricContext metricContext); static DoubleExponentialSmoothing createWithSmoothingParams(double levelSmoothing, double trendSmoothing); static DoubleExponentialSmoothing createCustom(double levelSmoothing, double trendSmoothing,
                                                          MetricContext metricContext); @Override String name(); @Override int numberOfParams(); @Override int minimumInitSize(); static DoubleExOptimizer optimizer(); static DoubleExOptimizer optimizer(MetricContext metricContext); @Override String toString(); static final double DEFAULT_LEVEL_SMOOTHING; static final double DEFAULT_TREND_SMOOTHING; static final double MIN_LEVEL_TREND_SMOOTHING; static final double MAX_LEVEL_TREND_SMOOTHING; }
@Test public void testMinimalPoints() throws IOException { int minimalPoints = 2; ModelData rModel = ModelReader.read("trendStatUpwardLowVar"); DoubleExponentialSmoothing.DoubleExOptimizer optimizer = DoubleExponentialSmoothing.optimizer(); try { TimeSeriesModel model = optimizer.minimizedMSE(rModel.getData().subList(0, minimalPoints)); Assert.assertTrue(model != null); } catch (IllegalArgumentException ex) { Assert.fail(); } }
@Test public void testEmpty() { try { TimeSeriesModel model = DoubleExponentialSmoothing.optimizer().minimizedMSE(Collections.EMPTY_LIST); } catch (Throwable ex) { Assert.fail(); } }
@Test public void testTrend() throws IOException { double ACCURACY_LOW = 0.95; double ACCURACY_HIGH = 1.05; ModelData rModel = ModelReader.read("trendStatUpwardLowVar"); DoubleExponentialSmoothing.DoubleExOptimizer optimizer = DoubleExponentialSmoothing.optimizer(); TimeSeriesModel model = optimizer.minimizedMSE(rModel.getData()); AccuracyStatistics initStatistics = model.initStatistics(); assertThat(initStatistics.getMse()).withFailMessage("rModel: %s\nMy: %s\n%s", rModel, model, initStatistics) .isBetween(rModel.getMse()*ACCURACY_LOW,rModel.getMse()*ACCURACY_HIGH); }
@Test public void testStationary() throws IOException { double ACCURACY_LOW = 0.95; double ACCURACY_HIGH = 1.05; ModelData rModel = ModelReader.read("wnHighVariance"); DoubleExponentialSmoothing.DoubleExOptimizer optimizer = DoubleExponentialSmoothing.optimizer(); TimeSeriesModel model = optimizer.minimizedMSE(rModel.getData()); AccuracyStatistics initStatistics = model.initStatistics(); assertThat(initStatistics.getMse()).withFailMessage("rModel: %s\nMy: %s\n%s", rModel, model, initStatistics) .isBetween(rModel.getMse()*ACCURACY_LOW,rModel.getMse()*ACCURACY_HIGH); }