Class TrapezoidalDistribution

    • Field Detail

      • a

        protected final double a
        Lower limit of this distribution (inclusive).
      • b

        protected final double b
        Start of the trapezoid constant density.
      • c

        protected final double c
        End of the trapezoid constant density.
      • d

        protected final double d
        Upper limit of this distribution (inclusive).
    • Constructor Detail

      • 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 Detail

      • of

        public static TrapezoidalDistribution of​(double a,
                                                 double b,
                                                 double c,
                                                 double d)
        Creates a trapezoidal distribution.

        The distribution density is represented as an up sloping line from a to b, constant from b to c, and then a down sloping line from c to d.

        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:
        java.lang.IllegalArgumentException - if a >= d, if b < a, if c < b or if c > 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 b of 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 c of 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 as inverseCumulativeProbability(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 a of 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 as inverseCumulativeProbability(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 d of the distribution.

        Returns:
        the upper bound of the support.