class MSEImpurityMeasure implements ImpurityMeasure<MSEImpurityMeasure> {

    @Override public double impurity() {
        double impurity = 0;

        if (leftCnt > 0)
            impurity += leftY2 - 2.0 * leftY / leftCnt * leftY + Math.pow(leftY / leftCnt, 2) * leftCnt;

        if (rightCnt > 0)
            impurity += rightY2 - 2.0 * rightY / rightCnt * rightY + Math.pow(rightY / rightCnt, 2) * rightCnt;

        return impurity;
    }

    public  MSEImpurityMeasure(double leftY, double leftY2, long leftCnt, double rightY, double rightY2, long rightCnt);

}