PowerLawIntervalForecaster implements IntervalForecaster { @Override public IntervalForecast forecast(MetricData metricData, double pointForecast) { notNull(metricData, "metricData can't be null"); val width = params.getAlpha() * Math.pow(pointForecast, params.getBeta()); val weakWidth = params.getWeakMultiplier() * width; val strongWidth = params.getStrongMultiplier() * width; return new IntervalForecast( pointForecast + strongWidth, pointForecast + weakWidth, pointForecast - weakWidth, pointForecast - strongWidth); }  @Override IntervalForecast forecast(MetricData metricData, double pointForecast);  }
@Test public void testForecast() { val params = forecasterUnderTest.getParams(); val pointForecast = 132.4; val forecastResult = forecasterUnderTest.forecast(metricData, pointForecast); val width = params.getAlpha() * Math.pow(pointForecast, params.getBeta()); val weakWidth = params.getWeakMultiplier() * width; val strongWidth = params.getStrongMultiplier() * width; assertEquals(pointForecast + strongWidth, forecastResult.getUpperStrong(), TOLERANCE); assertEquals(pointForecast + weakWidth, forecastResult.getUpperWeak(), TOLERANCE); assertEquals(pointForecast - weakWidth, forecastResult.getLowerWeak(), TOLERANCE); assertEquals(pointForecast - strongWidth, forecastResult.getLowerStrong(), TOLERANCE); }