@Override
    public double quantile(double p) {
        if (p < 0.0 || p > 1.0) {
            throw new IllegalArgumentException("Invalid p: " + p);
        }

        double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 2.0 * Math.min(p, 1.0 - p));
        x = Math.sqrt(nu * (1.0 - x) / x);
        return p >= 0.5 ? x : -x;
    }
@Test
    public void testQuantile() {
        System.out.println("quantile");
        TDistribution instance = new TDistribution(20);
        instance.rand();
        assertEquals(-3.551808, instance.quantile(0.001), 1E-6);
        assertEquals(-2.527977, instance.quantile(0.01), 1E-6);
        assertEquals(-1.325341, instance.quantile(0.1), 1E-6);
        assertEquals(-0.8599644, instance.quantile(0.2), 1E-6);
        assertEquals(0.0,      instance.quantile(0.5), 1E-6);
        assertEquals(1.325341, instance.quantile(0.9), 1E-6);
        assertEquals(2.527977, instance.quantile(0.99), 1E-6);
        assertEquals(3.551808, instance.quantile(0.999), 1E-6);
    }