@Test public void testCompressIncreasingFunction() { StepFunction<TestImpurityMeasure> function = new StepFunction<>( new double[]{1, 2, 3, 4, 5}, TestImpurityMeasure.asTestImpurityMeasures(1, 2, 3, 4, 5) ); SimpleStepFunctionCompressor<TestImpurityMeasure> compressor = new SimpleStepFunctionCompressor<>(1, 0.4, 0); StepFunction<TestImpurityMeasure> resFunction = compressor.compress(function); assertArrayEquals(new double[]{1, 3, 5}, resFunction.getX(), 1e-10); assertArrayEquals(TestImpurityMeasure.asTestImpurityMeasures(1, 3, 5), resFunction.getY()); }
@Override public StepFunction<T> compress(StepFunction<T> function) { double[] arguments = function.getX(); T[] values = function.getY(); if (arguments.length >= minSizeToBeCompressed) { List<StepFunctionPoint> points = new ArrayList<>(); for (int i = 0; i < arguments.length; i++) points.add(new StepFunctionPoint(arguments[i], values[i])); points = compress(points); double[] resX = new double[points.size()]; T[] resY = Arrays.copyOf(values, points.size()); for (int i = 0; i < points.size(); i++) { StepFunctionPoint pnt = points.get(i); resX[i] = pnt.x; resY[i] = pnt.y; } return new StepFunction<>(resX, resY); } return function; }
SimpleStepFunctionCompressor implements StepFunctionCompressor<T> { @Override public StepFunction<T> compress(StepFunction<T> function) { double[] arguments = function.getX(); T[] values = function.getY(); if (arguments.length >= minSizeToBeCompressed) { List<StepFunctionPoint> points = new ArrayList<>(); for (int i = 0; i < arguments.length; i++) points.add(new StepFunctionPoint(arguments[i], values[i])); points = compress(points); double[] resX = new double[points.size()]; T[] resY = Arrays.copyOf(values, points.size()); for (int i = 0; i < points.size(); i++) { StepFunctionPoint pnt = points.get(i); resX[i] = pnt.x; resY[i] = pnt.y; } return new StepFunction<>(resX, resY); } return function; } }
SimpleStepFunctionCompressor implements StepFunctionCompressor<T> { @Override public StepFunction<T> compress(StepFunction<T> function) { double[] arguments = function.getX(); T[] values = function.getY(); if (arguments.length >= minSizeToBeCompressed) { List<StepFunctionPoint> points = new ArrayList<>(); for (int i = 0; i < arguments.length; i++) points.add(new StepFunctionPoint(arguments[i], values[i])); points = compress(points); double[] resX = new double[points.size()]; T[] resY = Arrays.copyOf(values, points.size()); for (int i = 0; i < points.size(); i++) { StepFunctionPoint pnt = points.get(i); resX[i] = pnt.x; resY[i] = pnt.y; } return new StepFunction<>(resX, resY); } return function; } SimpleStepFunctionCompressor();  SimpleStepFunctionCompressor(int minSizeToBeCompressed, double minImpurityIncreaseForRecord,
        double minImpurityDecreaseForRecord); }
SimpleStepFunctionCompressor implements StepFunctionCompressor<T> { @Override public StepFunction<T> compress(StepFunction<T> function) { double[] arguments = function.getX(); T[] values = function.getY(); if (arguments.length >= minSizeToBeCompressed) { List<StepFunctionPoint> points = new ArrayList<>(); for (int i = 0; i < arguments.length; i++) points.add(new StepFunctionPoint(arguments[i], values[i])); points = compress(points); double[] resX = new double[points.size()]; T[] resY = Arrays.copyOf(values, points.size()); for (int i = 0; i < points.size(); i++) { StepFunctionPoint pnt = points.get(i); resX[i] = pnt.x; resY[i] = pnt.y; } return new StepFunction<>(resX, resY); } return function; } SimpleStepFunctionCompressor();  SimpleStepFunctionCompressor(int minSizeToBeCompressed, double minImpurityIncreaseForRecord,
        double minImpurityDecreaseForRecord); @Override StepFunction<T> compress(StepFunction<T> function); }
SimpleStepFunctionCompressor implements StepFunctionCompressor<T> { @Override public StepFunction<T> compress(StepFunction<T> function) { double[] arguments = function.getX(); T[] values = function.getY(); if (arguments.length >= minSizeToBeCompressed) { List<StepFunctionPoint> points = new ArrayList<>(); for (int i = 0; i < arguments.length; i++) points.add(new StepFunctionPoint(arguments[i], values[i])); points = compress(points); double[] resX = new double[points.size()]; T[] resY = Arrays.copyOf(values, points.size()); for (int i = 0; i < points.size(); i++) { StepFunctionPoint pnt = points.get(i); resX[i] = pnt.x; resY[i] = pnt.y; } return new StepFunction<>(resX, resY); } return function; } SimpleStepFunctionCompressor();  SimpleStepFunctionCompressor(int minSizeToBeCompressed, double minImpurityIncreaseForRecord,
        double minImpurityDecreaseForRecord); @Override StepFunction<T> compress(StepFunction<T> function);  }