in commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TrapezoidalDistribution.java [378:404]
public static TrapezoidalDistribution of(double a, double b, double c, double d) {
if (a >= d) {
throw new DistributionException(DistributionException.INVALID_RANGE_LOW_GTE_HIGH,
a, d);
}
if (b < a) {
throw new DistributionException(DistributionException.TOO_SMALL,
b, a);
}
if (c < b) {
throw new DistributionException(DistributionException.TOO_SMALL,
c, b);
}
if (c > d) {
throw new DistributionException(DistributionException.TOO_LARGE,
c, d);
}
// For consistency, delegate to the appropriate simplified distribution.
// Note: Floating-point equality comparison is intentional.
if (b == c) {
return new TriangularTrapezoidalDistribution(a, b, d);
}
if (d - a == c - b) {
return new UniformTrapezoidalDistribution(a, d);
}
return new RegularTrapezoidalDistribution(a, b, c, d);
}