AutoregressiveTimeSeriesModel { public LocalDateDoubleTimeSeries getSeries(final double[] phi, final int p, final LocalDate[] dates) { Validate.notNull(phi, "phi"); if (p < 1) { throw new IllegalArgumentException("Order must be greater than zero"); } if (phi.length < p + 1) { throw new IllegalArgumentException("Coefficient array must contain at least " + (p + 1) + " elements"); } Validate.notNull(dates, "dates"); if (dates.length == 0) { throw new IllegalArgumentException("Dates array was empty"); } final int n = dates.length; final double[] data = new double[n]; data[0] = phi[0] + _random.nextRandom(); double sum; for (int i = 1; i < n; i++) { sum = phi[0] + _random.nextRandom(); for (int j = 1; j < (i < p ? i : p + 1); j++) { sum += phi[j] * data[i - j]; } data[i] = sum; } return ImmutableLocalDateDoubleTimeSeries.of(dates, data); } AutoregressiveTimeSeriesModel(final ProbabilityDistribution<Double> random); LocalDateDoubleTimeSeries getSeries(final double[] phi, final int p, final LocalDate[] dates);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullPhis() { MODEL.getSeries(null, 2, new LocalDate[] { LocalDate.ofEpochDay(1) }); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmptyPhis() { MODEL.getSeries(new double[0], 2, new LocalDate[] { LocalDate.ofEpochDay(1) }); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeOrder() { MODEL.getSeries(new double[] {0.2}, -3, new LocalDate[] { LocalDate.ofEpochDay(1) }); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInsufficientPhis() { MODEL.getSeries(new double[] {0.2}, 4, new LocalDate[] { LocalDate.ofEpochDay(1) }); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDates() { MODEL.getSeries(new double[] {0.3, 0.4}, 1, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmptyDates() { MODEL.getSeries(new double[] {0.3, 0.4}, 1, new LocalDate[0]); }