@Test
public void testSubtract() {

    Random rnd = new Random(0);
    MSEImpurityMeasure a = new MSEImpurityMeasure(
        rnd.nextDouble(), rnd.nextDouble(), rnd.nextInt(), rnd.nextDouble(), rnd.nextDouble(), rnd.nextInt()
    );
    MSEImpurityMeasure b = new MSEImpurityMeasure(
        rnd.nextDouble(), rnd.nextDouble(), rnd.nextInt(), rnd.nextDouble(), rnd.nextDouble(), rnd.nextInt()
    );
    MSEImpurityMeasure c = a.subtract(b);
    assertEquals(a.getLeftY() - b.getLeftY(), c.getLeftY(), 1e-10);
    assertEquals(a.getLeftY2() - b.getLeftY2(), c.getLeftY2(), 1e-10);
    assertEquals(a.getLeftCnt() - b.getLeftCnt(), c.getLeftCnt());
    assertEquals(a.getRightY() - b.getRightY(), c.getRightY(), 1e-10);
    assertEquals(a.getRightY2() - b.getRightY2(), c.getRightY2(), 1e-10);
    assertEquals(a.getRightCnt() - b.getRightCnt(), c.getRightCnt());
}