MillerUpdatingRegression implements UpdatingMultipleLinearRegression { public void addObservation(final double[] x, final double y) throws ModelSpecificationException { if ((!this.hasIntercept && x.length != nvars) || (this.hasIntercept && x.length + 1 != nvars)) { throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION, x.length, nvars); } if (!this.hasIntercept) { include(MathArrays.copyOf(x, x.length), 1.0, y); } else { final double[] tmp = new double[x.length + 1]; System.arraycopy(x, 0, tmp, 1, x.length); tmp[0] = 1.0; include(tmp, 1.0, y); } ++nobs; } @SuppressWarnings("unused") private  MillerUpdatingRegression();  MillerUpdatingRegression(int numberOfVariables, boolean includeConstant, double errorTolerance);  MillerUpdatingRegression(int numberOfVariables, boolean includeConstant); boolean hasIntercept(); long getN(); void addObservation(final double[] x, final double y); void addObservations(double[][] x, double[] y); void clear(); double[] getPartialCorrelations(int in); double getDiagonalOfHatMatrix(double[] row_data); int[] getOrderOfRegressors(); RegressionResults regress(); RegressionResults regress(int numberOfRegressors); RegressionResults regress(int[] variablesToInclude);  }
@Test public void testNegativeTestAddObs() { MillerUpdatingRegression instance = new MillerUpdatingRegression(3, true); try { instance.addObservation(new double[]{1.0}, 0.0); Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0); Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0); } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException"); } instance = new MillerUpdatingRegression(3, false); try { instance.addObservation(new double[]{1.0}, 0.0); Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0); Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0); } catch (Exception e) { Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } }