public ShiftedGeometricDistribution(double p) {
        if (p <= 0 || p > 1) {
            throw new IllegalArgumentException("Invalid p: " + p);
        }

        this.p = p;
        entropy = (-p * MathEx.log2(p) - (1 - p) * MathEx.log2(1 - p)) / p;
    }
@Test
    public void testShiftedGeometricDistribution() {
        System.out.println("ShiftedGeometricDistribution");
        MathEx.setSeed(19650218); // to get repeatable results.
        ShiftedGeometricDistribution instance = new ShiftedGeometricDistribution(0.4);
        int[] data = instance.randi(1000);
        ShiftedGeometricDistribution est = ShiftedGeometricDistribution.fit(data);
        assertEquals(0.4, est.p, 1E-2);
    }