@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_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); }