NumberInterpolator extends Interpolator<T> { public DoubleColumn linear() { DoubleColumn result = col.asDoubleColumn(); int last = -1; for (int i = 0; i < col.size(); i++) { if (!col.isMissing(i)) { if (last >= 0 && last != i - 1) { for (int j = last + 1; j < i; j++) { result.set( j, col.getDouble(last) + (col.getDouble(i) - col.getDouble(last)) * (j - last) / (i - last)); } } last = i; } } return result; } NumberInterpolator(NumericColumn<T> col); DoubleColumn linear();  }
@Test public void linear() { DoubleColumn col = DoubleColumn.create( "testCol", new double[] {missing, 1.0, missing, missing, missing, 5.0, missing}) .interpolate() .linear(); assertArrayEquals( new double[] {missing, 1.0, 2.0, 3.0, 4.0, 5.0, missing}, col.asDoubleArray()); }