public TrapezoidalDistribution(
[Real, DefaultValue(0)] double a, [Real, DefaultValue(1)] double b,
[Real, DefaultValue(2)] double c, [Real, DefaultValue(3)] double d,
[Positive] double n1, [Positive] double n3)
{
// boundary validation
if (a > b)
throw new ArgumentOutOfRangeException("b", "Argument b must be higher than a.");
if (b > c)
throw new ArgumentOutOfRangeException("c", "Argument c must be higher than b.");
if (d < c)
throw new ArgumentOutOfRangeException("d", "Argument d must be higher than c.");
if (d <= a)
throw new ArgumentOutOfRangeException("d", "The maximum value d must be higher than the minimum value a");
if (n1 <= 0)
throw new ArgumentOutOfRangeException("n1", "Slope n1 must be positive.");
if (n3 <= 0)
throw new ArgumentOutOfRangeException("n3", "Slope n3 must be positive.");
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.n1 = n1;
this.n3 = n3;
double num = 2 * n1 * n3;
double den = 2 * alpha * (b - a) * n3
+ (alpha + 1) * (c - b) * n1 * n3
+ 2 * (d - c) * n1;
this.constant = num / den;
}