class GiniImpurityMeasure implements ImpurityMeasure<GiniImpurityMeasure> {

    @Override public GiniImpurityMeasure subtract(GiniImpurityMeasure b) {
        assert left.length == b.left.length : "Subtracted measure has to have length " + left.length;
        assert left.length == b.right.length : "Subtracted measure has to have length " + left.length;

        long[] leftRes = new long[left.length];
        long[] rightRes = new long[left.length];

        for (int i = 0; i < left.length; i++) {
            leftRes[i] = left[i] - b.left[i];
            rightRes[i] = right[i] - b.right[i];
        }

        return new GiniImpurityMeasure(leftRes, rightRes);
    }

      GiniImpurityMeasure(long[] left, long[] right);

}