@Override
    public double logp(int k) {
        if (k < 0) {
            return Double.NEGATIVE_INFINITY;
        } else {
            return k * Math.log(1 - p) + Math.log(p);
        }
    }
@Test
    public void testLogP() {
        System.out.println("logP");
        GeometricDistribution instance = new GeometricDistribution(0.3);
        instance.rand();
        assertEquals(Math.log(0.3), instance.logp(0), 1E-6);
        assertEquals(Math.log(0.21), instance.logp(1), 1E-6);
        assertEquals(Math.log(0.147), instance.logp(2), 1E-6);
        assertEquals(Math.log(0.1029), instance.logp(3), 1E-6);
        assertEquals(Math.log(0.07203), instance.logp(4), 1E-6);
        assertEquals(Math.log(0.008474257), instance.logp(10), 1E-6);
        assertEquals(Math.log(0.0002393768), instance.logp(20), 1E-6);
    }