presto-main/src/main/java/io/prestosql/operator/scalar/WilsonInterval.java/WilsonInterval/wilsonInterval
class WilsonInterval:    private static double wilsonInterval(long successes, long trials, double z, int bound)
    {
        checkCondition(successes >= 0, INVALID_FUNCTION_ARGUMENT, "number of successes must not be negative");
        checkCondition(trials > 0, INVALID_FUNCTION_ARGUMENT, "number of trials must be positive");
        checkCondition(successes <= trials, INVALID_FUNCTION_ARGUMENT, "number of successes must not be larger than number of trials");
        checkCondition(z >= 0, INVALID_FUNCTION_ARGUMENT, "z-score must not be negative");

        double p = successes * 1.0 / trials;
        double n = trials;

        return (p + (z * z) / (2 * n) + bound * z * Math.sqrt((p * (1 - p)) / n + (z * z) / (4 * n * n))) / (1 + (z * z) / n);
    }