use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class MathFunctions method inverseBetaCdf.
@Description("inverse of Beta cdf given a, b parameters and probability")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double inverseBetaCdf(@SqlType(StandardTypes.DOUBLE) double a, @SqlType(StandardTypes.DOUBLE) double b, @SqlType(StandardTypes.DOUBLE) double p) {
checkCondition(p >= 0 && p <= 1, INVALID_FUNCTION_ARGUMENT, "p must be in the interval [0, 1]");
checkCondition(a > 0, INVALID_FUNCTION_ARGUMENT, "a must be > 0");
checkCondition(b > 0, INVALID_FUNCTION_ARGUMENT, "b must be > 0");
BetaDistribution distribution = new BetaDistribution(null, a, b, BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
return distribution.inverseCumulativeProbability(p);
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class MathFunctions method binomialCdf.
@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);
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class MathFunctions method betaCdf.
@Description("Beta cdf given the a, b parameters and value")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double betaCdf(@SqlType(StandardTypes.DOUBLE) double a, @SqlType(StandardTypes.DOUBLE) double b, @SqlType(StandardTypes.DOUBLE) double value) {
checkCondition(value >= 0 && value <= 1, INVALID_FUNCTION_ARGUMENT, "value must be in the interval [0, 1]");
checkCondition(a > 0, INVALID_FUNCTION_ARGUMENT, "a must be > 0");
checkCondition(b > 0, INVALID_FUNCTION_ARGUMENT, "b must be > 0");
BetaDistribution distribution = new BetaDistribution(null, a, b, BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
return distribution.cumulativeProbability(value);
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class MathFunctions method inverseBinomialCdf.
@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);
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class MathFunctions method inversePoissonCdf.
@Description("Inverse of Poisson cdf given lambda (mean) parameter and probability")
@ScalarFunction
@SqlType(StandardTypes.INTEGER)
public static long inversePoissonCdf(@SqlType(StandardTypes.DOUBLE) double lambda, @SqlType(StandardTypes.DOUBLE) double p) {
checkCondition(p >= 0 && p < 1, INVALID_FUNCTION_ARGUMENT, "p must be in the interval [0, 1)");
checkCondition(lambda > 0, INVALID_FUNCTION_ARGUMENT, "lambda must be greater than 0");
PoissonDistribution distribution = new PoissonDistribution(lambda);
return distribution.inverseCumulativeProbability(p);
}
Aggregations