@Override
    public double rand() {
        if (MathEx.random() < q) {
            return 0;
        } else {
            return 1;
        }
    }
@Test
    public void testSd() {
        System.out.println("sd");
        BernoulliDistribution instance = new BernoulliDistribution(0.3);
        instance.rand();
        assertEquals(Math.sqrt(0.21), instance.sd(), 1E-7);
    }