EwmaPointForecaster implements PointForecaster { @Override public PointForecast forecast(MetricData metricData) { notNull(metricData, "metricData can't be null"); val observed = metricData.getValue(); updateMeanEstimate(observed); return new PointForecast(mean, false); } EwmaPointForecaster();  EwmaPointForecaster(EwmaPointForecasterParams params); @Override PointForecast forecast(MetricData metricData);  }
@Test public void classify() { val testRows = data.listIterator(); val testRow0 = testRows.next(); val observed0 = testRow0.getObserved(); val params = new EwmaPointForecasterParams() .setAlpha(0.05) .setInitMeanEstimate(observed0); val forecaster = new EwmaPointForecaster(params); assertEquals(params, forecaster.getParams()); assertEquals(observed0, forecaster.getMean(), TOLERANCE); while (testRows.hasNext()) { val testRow = testRows.next(); val observed = testRow.getObserved(); val metricData = new MetricData(metricDef, observed, epochSecond); forecaster.forecast(metricData); assertEquals(testRow.getKnownMean(), forecaster.getMean(), TOLERANCE); } }
@Test(expected = IllegalArgumentException.class) public void testForecast_nullMetricData() { val forecaster = new EwmaPointForecaster(); forecaster.forecast(null); }