/** * Checks whether the requirements for the input TS are met. * This default implementation checks whether the length of the time series is greater or equal to {@value #MIN_TS_SIZE_DEFAULT}. * This method can be overridden by any forecaster if more specific requirements are needed. */ protected boolean satisfiesInputTSRequirements(final ITimeSeries<Double> timeSeries) { return timeSeries.size() >= MIN_TS_SIZE_DEFAULT; }
/** * Checks whether the requirements for the input TS are met. * This default implementation checks whether the length of the time series is greater or equal to {@value #MIN_TS_SIZE_DEFAULT}. * This method can be overridden by any forecaster if more specific requirements are needed. * * @param timeSeries time series * * @return returns true when requirements are met */ protected boolean satisfiesInputTSRequirements(final ITimeSeries<Double> timeSeries) { return timeSeries.size() >= MIN_TS_SIZE_DEFAULT; }
/** * Returns a new time series object shortened to the last x values. * * @param ts * timeseries * @param x * last x value * @return new time series object */ private static ITimeSeries<Double> getLastXofTS(final ITimeSeries<Double> ts, final int x) { if (ts.size() >= x) { Double[] a = new Double[ts.size()]; a = ts.getValues().toArray(a); final Double[] b = new Double[x]; for (int i = 0; i < x; i++) { b[i] = a[(ts.size() - x) + i]; } long newStartTime = ts.getStartTime(); newStartTime += (ts.size() - x) * ts.getDeltaTimeUnit().toMillis(ts.getDeltaTime()); final ITimeSeries<Double> tsLastX = new TimeSeries<Double>(newStartTime, ts.getTimeSeriesTimeUnit(), ts.getDeltaTime(), ts.getDeltaTimeUnit(), ts.getCapacity()); tsLastX.appendAll(b); return tsLastX; } else { return ts; } } }
/** * Returns a new time series object shortened to the last x values. * * @param ts * timeseries * @param x * last x value * @return new time series object */ private static ITimeSeries<Double> getLastXofTS(final ITimeSeries<Double> ts, final int x) { if (ts.size() >= x) { Double[] a = new Double[ts.size()]; a = ts.getValues().toArray(a); final Double[] b = new Double[x]; for (int i = 0; i < x; i++) { b[i] = a[(ts.size() - x) + i]; } long newStartTime = ts.getStartTime(); newStartTime += (ts.size() - x) * ts.getDeltaTimeUnit().toMillis(ts.getDeltaTime()); final ITimeSeries<Double> tsLastX = new TimeSeries<Double>(newStartTime, ts.getTimeSeriesTimeUnit(), ts.getDeltaTime(), ts.getDeltaTimeUnit(), ts.getCapacity()); tsLastX.appendAll(b); return tsLastX; } else { return ts; } } }
/** * One step of a mean calculation. */ @Test public void testMeanCalculationOneStep() { Assert.assertEquals(this.steps, this.forecastSeries.size()); final ITimeSeriesPoint<Double> stepFC = this.forecast.getForecast().getPoints().get(0); Assert.assertEquals(this.mean, stepFC.getValue()); }
/** * Test if the correct calculation is done. In this case mean is bigger than the lower bounds. */ @Test public void testLowerCalculationOneStep() { Assert.assertEquals(this.steps, this.lowerSeries.size()); final ITimeSeriesPoint<Double> stepFC = this.forecast.getLower().getPoints().get(0); Assert.assertTrue(this.mean > stepFC.getValue()); }
/** * Test if the correct calculation is done. In this case mean is smaller than the upper bounds. */ @Test public void testUpperCalculationOneStep() { Assert.assertEquals(this.steps, this.upperSeries.size()); final ITimeSeriesPoint<Double> stepFC = this.forecast.getUpper().getPoints().get(0); Assert.assertTrue(this.mean < stepFC.getValue()); } }