Class TrapezoidalDistribution
- All Implemented Interfaces:
ContinuousDistribution
- Direct Known Subclasses:
TrapezoidalDistribution.DelegatedTrapezoidalDistribution, TrapezoidalDistribution.RegularTrapezoidalDistribution
The probability density function of \( X \) is:
\[ f(x; a, b, c, d) = \begin{cases} \frac{2}{d+c-a-b}\frac{x-a}{b-a} & \text{for } a\le x \lt b \\ \frac{2}{d+c-a-b} & \text{for } b\le x \lt c \\ \frac{2}{d+c-a-b}\frac{d-x}{d-c} & \text{for } c\le x \le d \end{cases} \]
for \( -\infty \lt a \le b \le c \le d \lt \infty \) and \( x \in [a, d] \).
Note the special cases:
- \( b = c \) is the triangular distribution
- \( a = b \) and \( c = d \) is the uniform distribution
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classSpecialisation of the trapezoidal distribution used when the distribution simplifies to an alternative distribution.private static classRegular implementation of the trapezoidal distribution.private static classSpecialisation of the trapezoidal distribution used whenb == c.private static classSpecialisation of the trapezoidal distribution used whena == bandc == d.Nested classes/interfaces inherited from interface ContinuousDistribution
ContinuousDistribution.Sampler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final doubleLower limit of this distribution (inclusive).protected final doubleStart of the trapezoid constant density.protected final doubleEnd of the trapezoid constant density.protected final doubleUpper limit of this distribution (inclusive). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetB()Gets the start of the constant region of the density function.doublegetC()Gets the end of the constant region of the density function.abstract doublegetMean()Gets the mean of this distribution.doubleGets the lower bound of the support.doubleGets the upper bound of the support.abstract doubleGets the variance of this distribution.static TrapezoidalDistributionof(double a, double b, double c, double d) Creates a trapezoidal distribution.Methods inherited from class AbstractContinuousDistribution
createSampler, getMedian, inverseCumulativeProbability, inverseSurvivalProbability, isSupportConnected, probabilityMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContinuousDistribution
cumulativeProbability, density, logDensity, survivalProbability
-
Field Details
-
a
protected final double aLower limit of this distribution (inclusive). -
b
protected final double bStart of the trapezoid constant density. -
c
protected final double cEnd of the trapezoid constant density. -
d
protected final double dUpper limit of this distribution (inclusive).
-
-
Constructor Details
-
TrapezoidalDistribution
TrapezoidalDistribution(double a, double b, double c, double d) - Parameters:
a- Lower limit of this distribution (inclusive).b- Start of the trapezoid constant density.c- End of the trapezoid constant density.d- Upper limit of this distribution (inclusive).
-
-
Method Details
-
of
Creates a trapezoidal distribution.The distribution density is represented as an up sloping line from
atob, constant frombtoc, and then a down sloping line fromctod.- Parameters:
a- Lower limit of this distribution (inclusive).b- Start of the trapezoid constant density (first shape parameter).c- End of the trapezoid constant density (second shape parameter).d- Upper limit of this distribution (inclusive).- Returns:
- the distribution
- Throws:
IllegalArgumentException- ifa >= d, ifb < a, ifc < bor ifc > d.
-
getMean
public abstract double getMean()Gets the mean of this distribution.For lower limit \( a \), start of the density constant region \( b \), end of the density constant region \( c \) and upper limit \( d \), the mean is:
\[ \frac{1}{3(d+c-b-a)}\left(\frac{d^3-c^3}{d-c}-\frac{b^3-a^3}{b-a}\right) \]
- Returns:
- the mean.
-
getVariance
public abstract double getVariance()Gets the variance of this distribution.For lower limit \( a \), start of the density constant region \( b \), end of the density constant region \( c \) and upper limit \( d \), the variance is:
\[ \frac{1}{6(d+c-b-a)}\left(\frac{d^4-c^4}{d-c}-\frac{b^4-a^4}{b-a}\right) - \mu^2 \]
where \( \mu \) is the mean.
- Returns:
- the variance.
-
getB
public double getB()Gets the start of the constant region of the density function.This is the first shape parameter
bof the distribution.- Returns:
- the first shape parameter
b
-
getC
public double getC()Gets the end of the constant region of the density function.This is the second shape parameter
cof the distribution.- Returns:
- the second shape parameter
c
-
getSupportLowerBound
public double getSupportLowerBound()Gets the lower bound of the support. It must return the same value asinverseCumulativeProbability(0), i.e. \( \inf \{ x \in \mathbb R : P(X \le x) \gt 0 \} \).The lower bound of the support is equal to the lower limit parameter
aof the distribution.- Returns:
- the lower bound of the support.
-
getSupportUpperBound
public double getSupportUpperBound()Gets the upper bound of the support. It must return the same value asinverseCumulativeProbability(1), i.e. \( \inf \{ x \in \mathbb R : P(X \le x) = 1 \} \).The upper bound of the support is equal to the upper limit parameter
dof the distribution.- Returns:
- the upper bound of the support.
-