Utils { public static double[] interp(double[] x, double[] xp, double[] yp) { double[] y = new double[x.length]; int i = 0; int ip = 0; while (i < x.length && x[i] < xp[0]) i++; while (ip < xp.length && i < x.length) { while (ip < xp.length && xp[ip] < x[i]) ip++; if (ip >= xp.length) break; if (xp[ip] == x[i]) { y[i] = yp[ip]; } else { double dy = yp[ip] - yp[ip-1]; double dx = xp[ip] - xp[ip-1]; y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); } i++; } return y; }  static double median(ArrayList<Double> arrList); static double mean(double[] x); static double[] interp(double[] x, double[] xp, double[] yp); static double stdev(double[] a); static double[] extract(int[] indicator, int value, double[] arr); static String array2string(double[] a, String format); static int argmax(double[] a); static int argmin(double[] a); static double findBestShift(double[] laserT, double[] touchT, double[] touchY);  }
@Test public void testInterp_singleNumber() { assertThat(Utils.interp(new double[]{5}, new double[]{0, 10}, new double[]{35, 50}), is(new double[]{42.5})); }
@Test public void testInterp_twoNumbers() { assertThat(Utils.interp(new double[]{0}, new double[]{0, 10}, new double[]{35, 50}), is(new double[]{35})); }
@Test public void testInterp_numberContained() { assertThat(Utils.interp(new double[]{5, 10}, new double[]{0, 5, 10}, new double[]{35, 19, 50}), is(new double[]{19, 50})); }
@Test public void testInterp() { assertThat(Utils.interp(new double[]{5,6,16,17}, new double[]{0, 10, 12, 18}, new double[]{35, 50, 75, 93}), is(new double[]{42.5, 44, 87, 90})); }