use of org.apache.commons.math3.distribution.CauchyDistribution in project presto by prestodb.
the class MathFunctions method inverseCauchyCdf.
@Description("Inverse of Cauchy cdf for a given probability, median, and scale (gamma)")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double inverseCauchyCdf(@SqlType(StandardTypes.DOUBLE) double median, @SqlType(StandardTypes.DOUBLE) double scale, @SqlType(StandardTypes.DOUBLE) double p) {
checkCondition(p >= 0 && p <= 1, INVALID_FUNCTION_ARGUMENT, "p must be in the interval [0, 1]");
checkCondition(scale > 0, INVALID_FUNCTION_ARGUMENT, "scale must be greater than 0");
CauchyDistribution distribution = new CauchyDistribution(null, median, scale, CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
return distribution.inverseCumulativeProbability(p);
}
use of org.apache.commons.math3.distribution.CauchyDistribution in project presto by prestodb.
the class MathFunctions method cauchyCdf.
@Description("Cauchy cdf for a given value, median, and scale (gamma)")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double cauchyCdf(@SqlType(StandardTypes.DOUBLE) double median, @SqlType(StandardTypes.DOUBLE) double scale, @SqlType(StandardTypes.DOUBLE) double value) {
checkCondition(scale > 0, INVALID_FUNCTION_ARGUMENT, "scale must be greater than 0");
CauchyDistribution distribution = new CauchyDistribution(null, median, scale, CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
return distribution.cumulativeProbability(value);
}
Aggregations