org.apache.commons.math.analysis.function
Class StepFunction

java.lang.Object
  extended by org.apache.commons.math.analysis.function.StepFunction
All Implemented Interfaces:
UnivariateRealFunction

public class StepFunction
extends java.lang.Object
implements UnivariateRealFunction

Step function.

Since:
3.0
Version:
$Id$

Constructor Summary
StepFunction(double[] x, double[] y)
          Builds a step function from a list of arguments and the corresponding values.
 
Method Summary
 double value(double x)
          Compute the value of the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StepFunction

public StepFunction(double[] x,
                    double[] y)
Builds a step function from a list of arguments and the corresponding values. Specifically, returns the function h(x) defined by

 h(x) = y[0] for all x < x[1]
        y[1] for x[1] <= x < x[2]
        ...
        y[y.length - 1] for x >= x[x.length - 1]
 
The value of x[0] is ignored, but it must be strictly less than x[1].

Parameters:
x - Domain values where the function changes value.
y - Values of the function.
Throws:
NonMonotonicSequenceException - if the x array is not sorted in strictly increasing order.
NullArgumentException - if x or y are null.
NoDataException - if x or y are zero-length.
DimensionMismatchException - if x and y do not have the same length.
Method Detail

value

public double value(double x)
Compute the value of the function.

Specified by:
value in interface UnivariateRealFunction
Parameters:
x - Point at which the function value should be computed.
Returns:
the value of the function.


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.