@Override
    public double p(double x) {
        if (x < 0 || x > 1) {
            return 0.0;
        } else {
            return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta);
        }
    }
@Test
    public void testP() {
        System.out.println("p");
        BetaDistribution instance = new BetaDistribution(2, 5);
        instance.rand();
        assertEquals(0, instance.p(-0.1), 1E-4);
        assertEquals(0, instance.p(0.0), 1E-4);
        assertEquals(1.9683, instance.p(0.1), 1E-4);
        assertEquals(2.4576, instance.p(0.2), 1E-4);
        assertEquals(2.1609, instance.p(0.3), 1E-4);
        assertEquals(1.5552, instance.p(0.4), 1E-4);
        assertEquals(0.9375, instance.p(0.5), 1E-4);
        assertEquals(0.0, instance.p(1.0), 1E-4);
        assertEquals(0.0, instance.p(1.5), 1E-4);
    }