Class StepFunction
- java.lang.Object
-
- dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
-
- dev.nm.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction
-
- dev.nm.analysis.function.rn2r1.univariate.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:
- Wikipedia: Step function
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function
Function.EvaluationException
-
-
Constructor Summary
Constructors Constructor Description StepFunction(double epsilon)Construct an empty step function.StepFunction(OrderedPairs f)Construct a step function from a collection ordered pairs.StepFunction(OrderedPairs f, double epsilon)Construct a step function from a collection ordered pairs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(OrderedPairs f)Dynamically add points to the step function.doubleevaluate(double x)Evaluate y = f(x).doublemaxDomain()Get the biggest abscissae.doubleminDomain()Get the smallest abscissae.intsize()Get the number of points.double[]x()Get the abscissae.double[]y()Get the ordinates.-
Methods inherited from class dev.nm.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction
evaluate
-
Methods inherited from class dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
dimensionOfDomain, dimensionOfRange
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.nm.analysis.function.Function
dimensionOfDomain, dimensionOfRange
-
-
-
-
Constructor Detail
-
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 pairsepsilon- 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 Detail
-
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:OrderedPairsGet the abscissae.- Specified by:
xin interfaceOrderedPairs- Returns:
- the abscissae
-
y
public double[] y()
Description copied from interface:OrderedPairsGet the ordinates.- Specified by:
yin interfaceOrderedPairs- 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:OrderedPairsGet the number of points.- Specified by:
sizein interfaceOrderedPairs- Returns:
- the number of points
-
evaluate
public double evaluate(double x)
Description copied from interface:UnivariateRealFunctionEvaluate y = f(x).- Specified by:
evaluatein interfaceUnivariateRealFunction- Parameters:
x- x- Returns:
- f(x)
-
-