@Description("Inverse of Gamma cdf given shape and scale parameter and probability")
    @ScalarFunction
    @SqlType(StandardTypes.DOUBLE)
    public static double inverseGammaCdf(
            @SqlType(StandardTypes.DOUBLE) double shape,
            @SqlType(StandardTypes.DOUBLE) double scale,
            @SqlType(StandardTypes.DOUBLE) double p)
    {
        checkCondition(p >= 0 && p <= 1, INVALID_FUNCTION_ARGUMENT, "inverseGammaCdf Function: p must be in the interval [0, 1]");
        checkCondition(shape > 0, INVALID_FUNCTION_ARGUMENT, "inverseGammaCdf Function: shape must be greater than 0");
        checkCondition(scale > 0, INVALID_FUNCTION_ARGUMENT, "inverseGammaCdf Function: scale must be greater than 0");
        GammaDistribution distribution = new GammaDistribution(null, shape, scale, GammaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
        return distribution.inverseCumulativeProbability(p);
    }
@Test
    public void testInverseGammaCdf()
    {
        assertFunction("inverse_gamma_cdf(3, 3.6, 0.0)", DOUBLE, 0.0);
        assertFunction("round(inverse_gamma_cdf(3, 4, 0.99), 3)", DOUBLE, 33.624);
        assertFunction("round(inverse_gamma_cdf(3, 4, 0.50), 3)", DOUBLE, 10.696);
        // Gamma with shape 10k/2 and scale 2 is chisquare with df=10k, which is approximatly Normal with mu=10k
        // Hence, we expect that the quantile will be close to 10k, as we indeed get:
        assertFunction("round(inverse_gamma_cdf(10000.0/2, 2.0, 0.50), 3)", DOUBLE, 9999.333);

        assertInvalidFunction("inverse_gamma_cdf(0, 3, 0.5)", "inverseGammaCdf Function: shape must be greater than 0");
        assertInvalidFunction("inverse_gamma_cdf(3, 0, 0.5)", "inverseGammaCdf Function: scale must be greater than 0");
        assertInvalidFunction("inverse_gamma_cdf(3, 5, -0.1)", "inverseGammaCdf Function: p must be in the interval [0, 1]");
        assertInvalidFunction("inverse_gamma_cdf(3, 5, 1.1)", "inverseGammaCdf Function: p must be in the interval [0, 1]");
    }