} else { final TrendLine bg_to_raw = new PolyTrendLine(1);
} else { final TrendLine bg_to_raw = new PolyTrendLine(1);
} else { final TrendLine bg_to_raw = new PolyTrendLine(1);
TrendLine[] polys = new TrendLine[5]; polys[0] = new PolyTrendLine(1); noisePoly = new PolyTrendLine(2); final double[] noise_polyys = PolyTrendLine.toPrimitiveFromList(noise_polyyList); final double[] noise_polyxs = PolyTrendLine.toPrimitiveFromList(noise_polyxList);
TrendLine[] polys = new TrendLine[5]; polys[0] = new PolyTrendLine(1); noisePoly = new PolyTrendLine(2); final double[] noise_polyys = PolyTrendLine.toPrimitiveFromList(noise_polyyList); final double[] noise_polyxs = PolyTrendLine.toPrimitiveFromList(noise_polyxList);
} else { final TrendLine bg_to_raw = new Forecast.PolyTrendLine(1);
} else { final TrendLine bg_to_raw = new Forecast.PolyTrendLine(1);
} else { final TrendLine bg_to_raw = new Forecast.PolyTrendLine(1);
@Test public void polyTrendLine_AdvancedForecast_SecondDegree() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); // Data set as y=x^2 trendLine.setValues(new double[]{1, 4, 9, 16}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(5); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(25); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test public void polyTrendLine_SimpleForecast_SecondDegree() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); trendLine.setValues(new double[]{1, 2, 3, 4}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(10); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(10); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test public void polyTrendLine_SimpleForecast() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(1); trendLine.setValues(new double[]{1, 2, 3, 4}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(10); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(10); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test public void polyTrendLine_AdvancedForecast_SecondDegree() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); // Data set as y=x^2 trendLine.setValues(new double[]{1, 4, 9, 16}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(5); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(25); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test public void polyTrendLine_SimpleForecast_SecondDegree() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); trendLine.setValues(new double[]{1, 2, 3, 4}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(10); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(10); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test public void polyTrendLine_SimpleForecast() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(1); trendLine.setValues(new double[]{1, 2, 3, 4}, new double[]{1, 2, 3, 4}); // :: Act double errorVarience = trendLine.errorVarience(); double prediction = trendLine.predict(10); // :: Verify Truth.assertThat(prediction) .isWithin(0.01) .of(10); Truth.assertThat(errorVarience) .isWithin(0.01) .of(0); }
@Test(expected = IllegalArgumentException.class) public void setValuesWithDifferentLengthXandY() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); // :: Act trendLine.setValues(new double[]{1, 2, 3}, new double[]{1, 2}); }
@Test(expected = IllegalArgumentException.class) public void setValuesWithDifferentLengthXandY() { // :: Setup Forecast.PolyTrendLine trendLine = new Forecast.PolyTrendLine(2); // :: Act trendLine.setValues(new double[]{1, 2, 3}, new double[]{1, 2}); }