@Override public List<ITimeSeriesPoint<T>> appendAll(final T[] values) { final List<ITimeSeriesPoint<T>> retVals = new ArrayList<ITimeSeriesPoint<T>>(values.length); for (final T value : values) { retVals.add(this.append(value)); } return retVals; }
@Override public List<ITimeSeriesPoint<T>> appendAll(final T[] values) { final List<ITimeSeriesPoint<T>> retVals = new ArrayList<>(values.length); for (final T value : values) { retVals.add(this.append(value)); } return retVals; }
/** * Initiation of the test, setting up the test time series. * * @param timeUnit * Used time unit */ private void initForecastWithTimeUnit(final TimeUnit tu) { this.ts = new TimeSeries<Double>(this.startTime, TimeUnit.MILLISECONDS, this.deltaTime, tu); this.steps = 1; this.mean = Double.valueOf(2.0); this.ts.append(this.mean - 2); this.ts.append(this.mean - 1); this.ts.append(this.mean); this.ts.append(this.mean + 1); this.ts.append(this.mean + 2); this.forecaster = new MeanForecaster(this.ts, MeanForecasterTest.CONFIDENCE_LEVEL); this.forecast = this.forecaster.forecast(this.steps); this.forecastSeries = this.forecast.getForecast(); this.upperSeries = this.forecast.getUpper(); this.lowerSeries = this.forecast.getLower(); }
/** * Test of the SESRForecaster via Rserve. */ @Test public void test() { final int deltaTime = 1000; final TimeUnit timeUnit = TimeUnit.MILLISECONDS; final long startTime = System.currentTimeMillis() - (deltaTime * 10); final TimeSeries<Double> ts = new TimeSeries<Double>(startTime, TimeUnit.NANOSECONDS, deltaTime, timeUnit); ts.append(1.0); ts.append(2.0); ts.append(3.0); ts.append(1.0); ts.append(2.0); ts.append(3.0); final SESRForecaster forecaster = new SESRForecaster(ts); final IForecastResult forecast = forecaster.forecast(1); final ITimeSeries<Double> forecastSeries = forecast.getForecast(); // final ITimeSeriesPoint<Double> stepFC = forecastSeries.getPoints().get(0); Assert.assertEquals(2.000054d, AbstractKiekerRTest.getTsPoint(forecastSeries), 0.001d); } }
/** * Test if values are collected in the correct order. */ @Test public void testValueSort() { final int count = 30; for (int i = 0; i < count; i++) { this.unboundTS.append(Double.valueOf(i)); } for (int i = 0; i < count; i++) { Assert.assertEquals(Double.valueOf(i), this.unboundTS.getPoints().get(i).getValue()); } Assert.assertEquals(count, this.unboundTS.size()); }
/** * Test if newer values are stored in FIFO order. */ @Test public void testKeepNewerValuesInCapacity() { Assert.assertEquals(0, this.boundedTS.size()); int i; final int lastNumber = this.bounds * 2; for (i = 0; i <= lastNumber; i++) { this.boundedTS.append(i); } Assert.assertEquals(Integer.valueOf(lastNumber), this.boundedTS.getPoints().get(this.bounds - 1).getValue()); }
/** * Test of the getter and appends methods. */ @Test public void testGettersAndAppendingValues() { Assert.assertEquals(this.timeUnit, this.unboundTS.getDeltaTimeUnit()); Assert.assertEquals(this.startTime, this.unboundTS.getStartTime()); Assert.assertEquals(0, this.unboundTS.size()); this.unboundTS.append(666.0); this.unboundTS.append(666.0); Assert.assertEquals(2, this.unboundTS.size()); }
/** * Test of the buffer capacity. */ @Test public void testCapacityRestriction() { Assert.assertEquals(0, this.boundedTS.size()); Assert.assertEquals(this.bounds, this.boundedTS.getCapacity()); for (int i = 0; i < (this.bounds + 1); i++) { this.boundedTS.append(10 * i); } Assert.assertEquals(this.bounds, this.boundedTS.size()); }
@Test public void testTimeUnitPropagation() { final TimeSeries<Double> testTS = new TimeSeries<Double>(1L, TimeUnit.NANOSECONDS, 10L, TimeUnit.MILLISECONDS); testTS.append(1.0); Assert.assertEquals(TimeUnit.NANOSECONDS, testTS.getTimeSeriesTimeUnit()); Assert.assertEquals(TimeUnit.MILLISECONDS, testTS.getDeltaTimeUnit()); Assert.assertEquals(1L, testTS.getStartTime()); Assert.assertEquals(1L, testTS.getEndTime()); Assert.assertEquals(10000000L, testTS.getStepSize()); testTS.append(1.0); Assert.assertEquals(10000001L, testTS.getEndTime()); } }