@Description("Binomial cdf given numberOfTrials, successProbability, and a value")
    @ScalarFunction
    @SqlType(StandardTypes.DOUBLE)
    public static double binomialCdf(
            @SqlType(StandardTypes.INTEGER) long numberOfTrials,
            @SqlType(StandardTypes.DOUBLE) double successProbability,
            @SqlType(StandardTypes.INTEGER) long value)
    {
        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.cumulativeProbability((int) value);
    }
@Test
    public void testBinomialCdf()
    {
        assertFunction("binomial_cdf(5, 0.5, 5)", DOUBLE, 1.0);
        assertFunction("binomial_cdf(5, 0.5, 0)", DOUBLE, 0.03125);
        assertFunction("binomial_cdf(5, 0.5, 3)", DOUBLE, 0.8125);
        assertFunction("binomial_cdf(20, 1.0, 0)", DOUBLE, 0.0);

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