@Description("inverse of Binomial cdf given numberOfTrials, successProbability parameters and p")
    @ScalarFunction
    @SqlType(StandardTypes.INTEGER)
    public static long inverseBinomialCdf(
            @SqlType(StandardTypes.INTEGER) long numberOfTrials,
            @SqlType(StandardTypes.DOUBLE) double successProbability,
            @SqlType(StandardTypes.DOUBLE) double p)
    {
        checkCondition(p >= 0 && p <= 1, INVALID_FUNCTION_ARGUMENT, "p must be in the interval [0, 1]");
        checkCondition(successProbability >= 0 && successProbability <= 1, INVALID_FUNCTION_ARGUMENT, "successProbability must be in the interval [0, 1]");
        checkCondition(numberOfTrials > 0, INVALID_FUNCTION_ARGUMENT, "numberOfTrials must be greater than 0");
        BinomialDistribution distribution = new BinomialDistribution(null, (int) numberOfTrials, successProbability);
        return distribution.inverseCumulativeProbability(p);
    }
@Test
    public void testInverseBinomialCdf()
    {
        assertFunction("inverse_binomial_cdf(20, 0.5, 0.5)", INTEGER, 10);
        assertFunction("inverse_binomial_cdf(20, 0.5, 0.0)", INTEGER, 0);
        assertFunction("inverse_binomial_cdf(20, 0.5, 1.0)", INTEGER, 20);

        assertInvalidFunction("inverse_binomial_cdf(5, -0.5, 0.3)", "successProbability must be in the interval [0, 1]");
        assertInvalidFunction("inverse_binomial_cdf(5, 1.5, 0.3)", "successProbability must be in the interval [0, 1]");
        assertInvalidFunction("inverse_binomial_cdf(5, 0.5, -3.0)", "p must be in the interval [0, 1]");
        assertInvalidFunction("inverse_binomial_cdf(5, 0.5, 3.0)", "p must be in the interval [0, 1]");
        assertInvalidFunction("inverse_binomial_cdf(-5, 0.5, 0.3)", "numberOfTrials must be greater than 0");
    }