public static double lchoose(int n, int k) {
        if (k < 0 || k > n) {
            throw new IllegalArgumentException(String.format("Invalid n = %d, k = %d", n, k));
        }

        return lfactorial(n) - lfactorial(k) - lfactorial(n - k);
    }
@Test
    public void testLogChoose() {
        System.out.println("logChoose");
        assertEquals(0.0, MathEx.lchoose(10, 0), 1E-6);
        assertEquals(2.302585, MathEx.lchoose(10, 1), 1E-6);
        assertEquals(3.806662, MathEx.lchoose(10, 2), 1E-6);
        assertEquals(4.787492, MathEx.lchoose(10, 3), 1E-6);
        assertEquals(5.347108, MathEx.lchoose(10, 4), 1E-6);
    }