@Override
    public double p(int k) {
        if (k == 0) {
            return q;
        } else if (k == 1) {
            return p;
        } else {
            return 0.0;
        }
    }
@Test
    public void testP() {
        System.out.println("p");
        BernoulliDistribution instance = new BernoulliDistribution(0.3);
        instance.rand();
        assertEquals(0.7, instance.p(0), 1E-7);
        assertEquals(0.3, instance.p(1), 1E-7);
        assertEquals(0.0, instance.p(2), 1E-7);
    }