### Question:
IMSLinearRegression { public static double average(List<Long> input, int numberOfLastItems) { double sum = 0; for (int i = input.size() - numberOfLastItems; i < input.size(); i++) { sum += input.get(i); } return sum / numberOfLastItems; } private  IMSLinearRegression(); static double predict(List<Long> input, int numberOfLastItems); static double predict(double[] input); static double average(List<Long> input, int numberOfLastItems);  }### Answer:
@Test public void average() { List<Long> input = new ArrayList(); input.add(123L); input.add(456L); input.add(1L); input.add(10L); input.add(1000000L); int num = 3; double res = IMSLinearRegression.average(input, num); double exp = 1000011 / 3; assertEquals(exp, res, 0); }