Class TopHatFunction

  • All Implemented Interfaces:
    Function<Double,​Double>

    public class TopHatFunction
    extends Object
    implements Function<Double,​Double>
    Class representing the top-hat function, defined as: $$ \begin{align*} T(x)= \begin{cases} 0 & x < x_1\\ y & x_1 < x < x_2\\ 0 & x > x_2 \end{cases} \end{align*} $$ where $x_1$ is the lower edge of the "hat", $x_2$ is the upper edge and $y$ is the height of the function. This function is discontinuous at $x_1$ and $x_2$.
    • Constructor Detail

      • TopHatFunction

        public TopHatFunction​(double x1,
                              double x2,
                              double y)
        Creates an instance.
        Parameters:
        x1 - the lower edge
        x2 - the upper edge, must be greater than x1
        y - the height
    • Method Detail

      • apply

        public Double apply​(Double x)
        Evaluates the function.
        Specified by:
        apply in interface Function<Double,​Double>
        Parameters:
        x - The argument of the function, not null. Must have $x_1 < x < x_2$
        Returns:
        The value of the function