### Question:
LeastSquaresRegressionResult { public double getPredictedValue(double[] x) { ArgChecker.notNull(x, "x"); double[] betas = getBetas(); if (hasIntercept()) { if (x.length != betas.length - 1) { throw new IllegalArgumentException("Number of variables did not match number used in regression"); } } else { if (x.length != betas.length) { throw new IllegalArgumentException("Number of variables did not match number used in regression"); } } double sum = 0; for (int i = 0; i < (hasIntercept() ? x.length + 1 : x.length); i++) { if (hasIntercept()) { if (i == 0) { sum += betas[0]; } else { sum += betas[i] * x[i - 1]; } } else { sum += x[i] * betas[i]; } } return sum; } LeastSquaresRegressionResult(LeastSquaresRegressionResult result);  LeastSquaresRegressionResult(
      double[] betas,
      double[] residuals,
      double meanSquareError,
      double[] standardErrorOfBeta,
      double rSquared,
      double rSquaredAdjusted,
      double[] tStats,
      double[] pValues,
      boolean hasIntercept); double[] getBetas(); double[] getResiduals(); double getMeanSquareError(); double[] getStandardErrorOfBetas(); double getRSquared(); double getAdjustedRSquared(); double[] getTStatistics(); double[] getPValues(); boolean hasIntercept(); double getPredictedValue(double[] x); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testNullArray() { assertThatIllegalArgumentException() .isThrownBy(() -> NO_INTERCEPT.getPredictedValue(null)); }
@Test public void testLongArray() { assertThatIllegalArgumentException() .isThrownBy(() -> NO_INTERCEPT.getPredictedValue(new double[] {2.4, 2.5, 3.4})); }
@Test public void testShortArray() { assertThatIllegalArgumentException() .isThrownBy(() -> NO_INTERCEPT.getPredictedValue(new double[] {2.4})); }
@Test public void testPredictedValue() { double[] z; for (int i = 0; i < 10; i++) { z = new double[] {RANDOM.nextDouble(), RANDOM.nextDouble()}; assertThat(F1.applyAsDouble(z[0], z[1])).isCloseTo(NO_INTERCEPT.getPredictedValue(z), offset(EPS)); assertThat(F2.applyAsDouble(z[0], z[1])).isCloseTo(INTERCEPT.getPredictedValue(z), offset(EPS)); } }