Class StepFunction

All Implemented Interfaces:
Function<Vector,Double>, RealScalarFunction, UnivariateRealFunction, OrderedPairs

public class StepFunction extends AbstractUnivariateRealFunction implements OrderedPairs
A step function (or staircase function) is a finite linear combination of indicator functions of intervals. Informally speaking, a step function is a piecewise constant function having only finitely many pieces.

Note: this function is mutable for convenience. It allows dynamically adding more points to the function. It is handy when, e.g., merging two sets of points.

See Also:
  • Constructor Details

    • StepFunction

      public StepFunction(double epsilon)
      Construct an empty step function.
      Parameters:
      epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
    • StepFunction

      public StepFunction(OrderedPairs f, double epsilon)
      Construct a step function from a collection ordered pairs.
      Parameters:
      f - a collection of ordered pairs
      epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
    • StepFunction

      public StepFunction(OrderedPairs f)
      Construct a step function from a collection ordered pairs.
      Parameters:
      f - a collection of ordered pairs
  • Method Details

    • add

      public void add(OrderedPairs f)
      Dynamically add points to the step function.
      Parameters:
      f - a collection of ordered pairs
    • x

      public double[] x()
      Description copied from interface: OrderedPairs
      Get the abscissae.
      Specified by:
      x in interface OrderedPairs
      Returns:
      the abscissae
    • y

      public double[] y()
      Description copied from interface: OrderedPairs
      Get the ordinates.
      Specified by:
      y in interface OrderedPairs
      Returns:
      the ordinates
    • minDomain

      public double minDomain()
      Get the smallest abscissae.
      Returns:
      the smallest abscissae
    • maxDomain

      public double maxDomain()
      Get the biggest abscissae.
      Returns:
      the biggest abscissae
    • size

      public int size()
      Description copied from interface: OrderedPairs
      Get the number of points.
      Specified by:
      size in interface OrderedPairs
      Returns:
      the number of points
    • evaluate

      public double evaluate(double x)
      Description copied from interface: UnivariateRealFunction
      Evaluate y = f(x).
      Specified by:
      evaluate in interface UnivariateRealFunction
      Parameters:
      x - x
      Returns:
      f(x)