Class PiecewiseFunction
Step changes occur at specified finite arguments, shifting the value at the respective argument by the size of the step.
Rate changes apply to argument intervals, representing linear growth or decrease of value over the argument.
- Author:
- Andrey Malykhanov, Alexander Morozov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a break point in the piecewise function, characterized by its argument, and one or both of the following: value step change, rate change.static final recordA function segment is a section between breakpoints where the function behaves linearly or has a constant rate.static enum -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty (constant zero) piecewise function.PiecewiseFunction(List<Pair<Double, Double>> plotPoints) Creates a new piecewise function by its plot points. -
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculates the absolute integral of the piecewise linear function over the entire argument domain of [-∞, +∞].doubleabsoluteIntegral(Interval withinArgumentInterval) Calculates the absolute integral of the piecewise linear function over the the specified argument interval.addRate(double fromArgument, double rateDelta) Adds a rate change to this piecewise linear function, starting from the specified argument.Adds a rate change to the piecewise linear function within the specified interval.addStepChange(double argument, double valueStep) Adds a step change to the piecewise linear function.addStepChange(Interval withinArgumentInterval, double valueStep) Adds a step change to the piecewise linear function within the specified interval.antiderivative(double argumentIntegrationStep) Calculates an antiderivative of this piecewise linear function performing a stepwise integration of segments with non-zero rates.Returns a list of all break points in the piecewise function.breakPoints(Interval withinArgumentInterval) Returns a list of break points in the piecewise function within a specified argument interval.copy()Creates a new instance of thisPiecewiseFunctionthat is a copy of this function, and returns this instance.Calculates a derivative of this piecewise linear function with corresponding step changes at break points.discretized(double step, PiecewiseFunction.InterpolationType interpolationType) Returns a discretized version of thisPiecewiseFunctionusing a fixed discretization step.booleandoublefirstArgumentWithValueLessEqualThan(double lessEqualThanValue, double startingFromArgument) Finds and returns the first argument in the piecewise linear function where its value is less than or equal to the specified threshold, starting the search from the given argument, inclusive.doublefirstArgumentWithValueMoreEqualThan(double moreEqualThanValue, double startingFromArgument) Finds and returns the first argument in the piecewise linear function where its value is greater than or equal to the specified threshold, starting the search from the given argument, inclusive.inthashCode()doubleintegral()Calculates the integral of the piecewise linear function over the entire argument domain of [-∞, +∞].doubleCalculates the integral of the piecewise linear function over the specified argument interval.intervalsWithRateLessThan(double rateLessThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is less than the specified threshold.intervalsWithRateLessThan(Interval withinArgumentInterval, double rateLessThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is less than the specified threshold, within the specified argument interval.intervalsWithRateMoreThan(double rateMoreThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is greater than the specified threshold.intervalsWithRateMoreThan(Interval withinArgumentInterval, double rateMoreThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is greater than the specified threshold, within the specified argument interval.intervalsWithValueLessEqualThan(double valueLessEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than or equal to the specified threshold.intervalsWithValueLessEqualThan(Interval withinArgumentInterval, double valueLessEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than or equal to the specified threshold.intervalsWithValueLessThan(double valueLessThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than the specified threshold.intervalsWithValueLessThan(Interval withinArgumentInterval, double valueLessThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than the specified threshold.intervalsWithValueMoreEqualThan(double valueMoreEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than or equal to the specified threshold.intervalsWithValueMoreEqualThan(Interval withinArgumentInterval, double valueMoreEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than or equal to the specified threshold.intervalsWithValueMoreThan(double valueMoreThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than the specified threshold.intervalsWithValueMoreThan(Interval withinArgumentInterval, double valueMoreThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than the specified threshold.booleanChecks whether this piecewise function is non-decreasing, i.e.: it has no negative step changes, and It has no segments with negative rate.booleanChecks whether this piecewise function is non-increasing, i.e.: it has no positive step changes, and It has no segments with positive rate.max(PiecewiseFunction other) Computes the maximum of this function and another piecewise function.doublemaxValue()Finds the maximum value of this function on the entire argument domain of [-∞, +∞].doubleFinds the maximum value of this piecewise linear function within the specified interval.min(PiecewiseFunction other) Computes the minimum of this function and another piecewise function.minus(PiecewiseFunction other) Subtracts the points of another piecewise function from this function.doubleminValue()Finds the minimum value of this function on the entire argument domain of [-∞, +∞].doubleFinds the minimum value of this piecewise linear function within the specified interval.multiply(double factor) Multiplies the values of this piecewise function by the specified factor.doubleCalculates the sum of all absolute values of negative step changes in this piecewise linear function.doublenegativeStepChangesSum(Interval withinArgumentInterval) Calculates the sum of all absolute values of negative step changes in this piecewise linear function within the specified argument interval.Returns a list of points of a linear 2d-plot of this function.plotPoints(Interval withinArgumentInterval) Returns a list of points of a linear 2d-plot plot of this function within the specified argument interval.plus(PiecewiseFunction other) Adds the points of another piecewise function to this function.doubleCalculates the integral of the positive part of the piecewise linear function over the entire argument domain of [-∞, +∞].doublepositiveIntegral(Interval withinArgumentInterval) Calculates the integral of the positive part of the piecewise linear function over the specified argument interval.doubleCalculates the sum of positive step changes in this piecewise linear function.doublepositiveStepChangesSum(Interval withinArgumentInterval) Calculates the sum of all positive step changes in this piecewise linear function within the specified argument interval.doublerateAt(double argument) Calculates the rate of growth (or decrease in case of negative rate) of this function at the specified argument.segmentsIterator(Interval argumentInterval) Returns an iterator over thePiecewiseFunction.FunctionSegmentinstances within the specified argument interval.segmentsStream(Interval argumentInterval) Returns a stream ofPiecewiseFunction.FunctionSegmentinstances within the specified argument interval.shiftArgument(double argumentShift) Shifts the function along the argument (X) axis by the specified amount.shiftValue(double valueShift) Shifts the function along the value (Y) axis by the specified amount.subFunction(IntervalLike withinArgumentInterval) Computes and returns a new instance ofPiecewiseFunctionwhich is a sub-function of this function, i.e.Returns a Java code that creates aPiecewiseFunctionequal to this one.doublevalueAt(double argument) Calculates the value of the piecewise linear function at the specified argument.
-
Constructor Details
-
PiecewiseFunction
public PiecewiseFunction()Creates a new empty (constant zero) piecewise function. -
PiecewiseFunction
Creates a new piecewise function by its plot points. For example, if we need to create the following function, we must supply these points:
- Parameters:
plotPoints- plot points of the piecewise function being created. Arguments cannot beDouble.NaN. Values must be finite and notDouble.NaN. Points should be sorted by argument in non-descending order. The first point with an argument greater than negative infinity must have a value equal to the value of the point at negative infinity, or zero if that point is the first.- See Also:
-
-
Method Details
-
segmentsIterator
Returns an iterator over thePiecewiseFunction.FunctionSegmentinstances within the specified argument interval. Each segment represents a section of the function where it behaves linearly or has a constant rate.If the provided argument interval is empty, the iterator will contain no elements.
- Parameters:
argumentInterval- the interval within which to retrieve the function segments, can beInterval.EMPTYorInterval.UNIVERSE- Returns:
- an iterator over the
PiecewiseFunction.FunctionSegmentinstances within the specified argument interval
-
segmentsStream
Returns a stream ofPiecewiseFunction.FunctionSegmentinstances within the specified argument interval. Each segment represents a section of the function where it behaves linearly or has a constant rate.- Parameters:
argumentInterval- the interval within which to retrieve the function segments, can beInterval.EMPTYorInterval.UNIVERSE- Returns:
- a stream of
PiecewiseFunction.FunctionSegmentinstances within the specified argument interval
-
addStepChange
Adds a step change to the piecewise linear function.Changes this instance and returns the reference to itself.
- Parameters:
argument- the argument where the step change occurs. Cannot beDouble.NaNvalueStep- the size of the step change. Must be finite and notDouble.NaN.- Returns:
- reference to this
PiecewiseFunctioninstance with the added step changeIllustration:

-
addStepChange
Adds a step change to the piecewise linear function within the specified interval.More specifically, adds a step change of valueStep at the min boundary of the interval, and a step change of -valueStep at the max boundary of the interval.
Changes this instance and returns the reference to itself.
- Parameters:
withinArgumentInterval- the interval where the step change occurs. Must be finite and notnullvalueStep- the size of the step change. Must be finite and notDouble.NaN- Returns:
- a reference to this
PiecewiseFunctioninstance with the added step changeIllustration:

-
addRate
Adds a rate change to this piecewise linear function, starting from the specified argument. The rate change represents a linear growth or decrease in value over the argument interval.Changes this instance and returns the reference to itself.
- Parameters:
fromArgument- the starting argument for the rate change. Must be finite and notDouble.NaNrateDelta- the rate of change to be applied. Must be finite and notDouble.NaN- Returns:
- a reference to this
PiecewiseFunctioninstance with the added rate changeIllustration:

-
addRate
Adds a rate change to the piecewise linear function within the specified interval. The rate change represents a linear growth or decrease in value over the interval.More specifically, adds a rate change of rateDelta at the min boundary of the interval, and a rate change of -rateDelta at the max boundary of the interval.
Changes this instance and returns the reference to itself.
- Parameters:
withinArgumentInterval- the interval within which the rate change occurs Must be finite and notnull.rateDelta- the rate of change to be applied. Must be finite and notDouble.NaN- Returns:
- a reference to this
PiecewiseFunctioninstance with the added rate changeIllustration:

-
valueAt
public double valueAt(double argument) Calculates the value of the piecewise linear function at the specified argument. If the argument corresponds to a step change, returns the value after this step change.- Parameters:
argument- the argument at which to evaluate the function, can be infinite. Must not beDouble.NaN- Returns:
- the value of the function at the specified argument, can be infinite
Illustration:

-
derivative
Calculates a derivative of this piecewise linear function with corresponding step changes at break points.- Returns:
- a new
PiecewiseFunctionthat represents a derivative of this piecewise linear functionIllustration:

- See Also:
-
antiderivative
Calculates an antiderivative of this piecewise linear function performing a stepwise integration of segments with non-zero rates.The rate of this piecewise function in both -∞ or +∞ must be equal to zero, as otherwise the antiderivative cannot be defined. If this is not the case, an
IllegalStateExceptionwill be thrown.- Parameters:
argumentIntegrationStep- step of integrating, applied for segments of this function with non-zero rates, must be finite, positive, and notDouble.NaN- Returns:
- a new
PiecewiseFunctionthat represents an antiderivative of this piecewise linear functionIllustration:

-
rateAt
public double rateAt(double argument) Calculates the rate of growth (or decrease in case of negative rate) of this function at the specified argument. If the argument corresponds to the point where the rate changes, returns the value after such rate change.- Parameters:
argument- the argument at which to calculate the rate of the function, can be infinite. Must not beDouble.NaN- Returns:
- the rate of the function at the specified argument, cannot be
infinite
Illustration:

-
shiftArgument
Shifts the function along the argument (X) axis by the specified amount.Creates and returns a new instance of
PiecewiseFunction; this instance remains unchanged.- Parameters:
argumentShift- the amount by which to shift along the argument (X) axis. Must be finite and notDouble.NaN- Returns:
- a new
PiecewiseFunctioninstance shifted along the argument (X) axis by the specified amountIllustration:

-
shiftValue
Shifts the function along the value (Y) axis by the specified amount.Creates and returns a new instance of
PiecewiseFunction; this instance remains unchanged.- Parameters:
valueShift- the amount by which to shift along the value (Y) axis. Must be finite and notDouble.NaN- Returns:
- a new
PiecewiseFunctioninstance shifted along the value (Y) axis by the specified amountIllustration:

-
subFunction
Computes and returns a new instance ofPiecewiseFunctionwhich is a sub-function of this function, i.e. function which is:- equal to this function inside the specified argument interval or interval set,
- zero elsewhere.
If the specified interval is
Interval.UNIVERSE, returns a copy of this function. If the specified interval isInterval.EMPTY, or has a zero length, returns a constant zero function- Parameters:
withinArgumentInterval- argument where the values of this function are preserved, can be empty but must not be zero-length- Returns:
- a new instance of
PiecewiseFunctionwhich is a sub-function of this functionIllustration:

-
plotPoints
Returns a list of points of a linear 2d-plot of this function. The returned list consists ofPair<Double,Double> instances. In each pair, the first element corresponds to the argument and the second element corresponds to the value. The list is ordered by argument in ascending order.Note that because of step changes, there can be up to 2 points for the same argument.
- Returns:
- list of points of linear 2d-plot of this function.
-
plotPoints
Returns a list of points of a linear 2d-plot plot of this function within the specified argument interval. The returned list consists ofPair<Double,Double> instances. In each pair, the first element corresponds to the argument and the second element corresponds to the value. The list is ordered by argument in ascending order.Note that because of step changes, there can be up to 2 points for the same argument.
- Parameters:
withinArgumentInterval- the interval within which to look for the plot points. Must not benull.- Returns:
- list of points of linear 2d-plot of this function.
-
breakPoints
Returns a list of all break points in the piecewise function.The break points are sorted by their argument in ascending order.
- Returns:
- a list of
PiecewiseFunction.BreakPointinstances representing break points.
-
breakPoints
Returns a list of break points in the piecewise function within a specified argument interval.The returned list contains only the break points whose arguments fall within the specified interval. The break points are sorted by their argument in ascending order.
- Parameters:
withinArgumentInterval- the interval within which to find break points. Must not benull.- Returns:
- a list of
PiecewiseFunction.BreakPointinstances representing break points within the specified interval.
-
min
Computes the minimum of this function and another piecewise function. Creates and returns a new instance ofPiecewiseFunctionwhich is the minimum of this function and another piecewise function. The current instance remains unchanged.- Parameters:
other- the other piecewise function, must not benull- Returns:
- a new
PiecewiseFunctioninstance which is the minimum of both functionsIllustration:

-
max
Computes the maximum of this function and another piecewise function. Creates and returns a new instance ofPiecewiseFunctionwhich is the maximum of this function and another piecewise function. The current instance remains unchanged.- Parameters:
other- the other piecewise function, must not benull- Returns:
- a new
PiecewiseFunctioninstance which is the maximum of both functionsIllustration:

-
plus
Adds the points of another piecewise function to this function. Creates and returns a new instance ofPiecewiseFunctionwith the combined points. The current instance remains unchanged.- Parameters:
other- the other piecewise function whose points are to be added, must not benull- Returns:
- a new
PiecewiseFunctioninstance with the points of both functions combinedIllustration:

-
minus
Subtracts the points of another piecewise function from this function. Creates and returns a new instance ofPiecewiseFunctionwith the points of the other function subtracted. The current instance remains unchanged.- Parameters:
other- the other piecewise function whose points are to be subtracted, must not benull- Returns:
- a new
PiecewiseFunctioninstance with the points of the other function subtractedIllustration:

-
multiply
Multiplies the values of this piecewise function by the specified factor. Creates and returns a new instance ofPiecewiseFunctionwith the values multiplied by the factor. The current instance remains unchanged.- Parameters:
factor- the factor by which to multiply the values of the function. Must be finite and notDouble.NaN- Returns:
- a new
PiecewiseFunctioninstance with the values multiplied by the factorIllustration:

-
copy
Creates a new instance of thisPiecewiseFunctionthat is a copy of this function, and returns this instance.- Returns:
- a copy of this instance
-
firstArgumentWithValueMoreEqualThan
public double firstArgumentWithValueMoreEqualThan(double moreEqualThanValue, double startingFromArgument) Finds and returns the first argument in the piecewise linear function where its value is greater than or equal to the specified threshold, starting the search from the given argument, inclusive.If the value of the function at the given argument is already greater than or equal to the specified threshold, returns this given argument.
- Parameters:
moreEqualThanValue- the threshold value to compare against. Must be finite and notDouble.NaNstartingFromArgument- the argument from which to start the search, inclusive. Must not beDouble.NaN- Returns:
- the first argument where the value is greater than or equal to the
specified threshold, or
Double.POSITIVE_INFINITYif no such argument is foundIllustration:

-
firstArgumentWithValueLessEqualThan
public double firstArgumentWithValueLessEqualThan(double lessEqualThanValue, double startingFromArgument) Finds and returns the first argument in the piecewise linear function where its value is less than or equal to the specified threshold, starting the search from the given argument, inclusive.If the value of the function at the given argument is already less than or equal to the specified threshold, returns this given argument.
- Parameters:
lessEqualThanValue- the threshold value to compare against. Must be finite and notDouble.NaNstartingFromArgument- the argument from which to start the search, inclusive. Must not beDouble.NaN- Returns:
- the first argument where the value is less than or equal to the
specified threshold, or
Double.POSITIVE_INFINITYif no such argument is foundIllustration:

-
maxValue
public double maxValue()Finds the maximum value of this function on the entire argument domain of [-∞, +∞].- Returns:
- maximum value of this function on the entire argument domain of [-∞,
+∞]
Illustration:

-
maxValue
Finds the maximum value of this piecewise linear function within the specified interval. ReturnsDouble.NEGATIVE_INFINITYforInterval.EMPTY.- Parameters:
withinArgumentInterval- the interval within which to search for the maximum value Must not benull.- Returns:
- the maximum value of the function within the specified interval, or
Double.NEGATIVE_INFINITYIllustration:

-
minValue
public double minValue()Finds the minimum value of this function on the entire argument domain of [-∞, +∞].- Returns:
- minimum value of this function on the entire argument domain of [-∞,
+∞]
Illustration:

-
minValue
Finds the minimum value of this piecewise linear function within the specified interval. ReturnsDouble.POSITIVE_INFINITYforInterval.EMPTY.- Parameters:
withinArgumentInterval- the interval within which to search for the minimum value Must not benull.- Returns:
- the minimum value of the function within the specified interval, or
Double.POSITIVE_INFINITYIllustration:

-
integral
public double integral()Calculates the integral of the piecewise linear function over the entire argument domain of [-∞, +∞].- Returns:
- the integral of the function over the entire argument domain of [-∞,
+∞]
Illustration:

-
integral
Calculates the integral of the piecewise linear function over the specified argument interval.- Parameters:
withinArgumentInterval- the interval within which to calculate the integral. Must not benull.- Returns:
- the integral of the function over the specified interval
Illustration:

-
absoluteIntegral
public double absoluteIntegral()Calculates the absolute integral of the piecewise linear function over the entire argument domain of [-∞, +∞].Absolute integral of a function is the integral of the absolute value of this function. It measures the total area between the function's plot and the argument (X) axis, disregarding the sign of the function's values.
- Returns:
- the absolute integral of the function over the entire argument domain
of [-∞, +∞]
Illustration:

-
absoluteIntegral
Calculates the absolute integral of the piecewise linear function over the the specified argument interval.Absolute integral of a function is the integral of the absolute value of this function. It measures the total area between the function's plot and the argument (X) axis, disregarding the sign of the function's values.
- Parameters:
withinArgumentInterval- the interval within which to calculate the integral. Must not benull.- Returns:
- the absolute integral of the function over the specified argument
interval
Illustration:

-
positiveIntegral
public double positiveIntegral()Calculates the integral of the positive part of the piecewise linear function over the entire argument domain of [-∞, +∞]. Positive integral measures the total area between the function's plot and the argument (X) axis considering only the parts of function where its value is positive.- Returns:
- the integral of the positive part of the function over the entire
argument domain of [-∞, +∞].
Illustration:

-
positiveIntegral
Calculates the integral of the positive part of the piecewise linear function over the specified argument interval. Positive integral measures the total area between the function's plot and the argument (X) axis considering only the parts of function where its value is positive.- Parameters:
withinArgumentInterval- the interval within which to calculate the integral. Must not benull- Returns:
- the integral of the positive part of the function over the
specified argument interval.
Illustration:

-
intervalsWithValueMoreEqualThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than or equal to the specified threshold.- Parameters:
valueMoreEqualThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is greater than or equal to the specified thresholdIllustration:

-
intervalsWithRateMoreThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is greater than the specified threshold, within the specified argument interval.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullrateMoreThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is greater than the specified thresholdIllustration:

-
intervalsWithRateMoreThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is greater than the specified threshold.- Parameters:
rateMoreThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's rate is greater than the specified thresholdIllustration:

-
intervalsWithRateLessThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is less than the specified threshold, within the specified argument interval.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullrateLessThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is less than the specified thresholdIllustration:

-
intervalsWithRateLessThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's change rate is less than the specified threshold.- Parameters:
rateLessThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's rate is less than the specified thresholdIllustration:

-
intervalsWithValueMoreEqualThan
public IntervalSet intervalsWithValueMoreEqualThan(Interval withinArgumentInterval, double valueMoreEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than or equal to the specified threshold.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullvalueMoreEqualThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is greater than or equal to the specified thresholdIllustration:

-
intervalsWithValueLessEqualThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than or equal to the specified threshold.- Parameters:
valueLessEqualThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is less than or equal to the specified thresholdIllustration:

-
intervalsWithValueLessEqualThan
public IntervalSet intervalsWithValueLessEqualThan(Interval withinArgumentInterval, double valueLessEqualThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than or equal to the specified threshold.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullvalueLessEqualThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is less than or equal to the specified thresholdIllustration:

-
intervalsWithValueMoreThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than the specified threshold.- Parameters:
valueMoreThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is greater than the specified thresholdIllustration:

-
intervalsWithValueMoreThan
public IntervalSet intervalsWithValueMoreThan(Interval withinArgumentInterval, double valueMoreThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is greater than the specified threshold.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullvalueMoreThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is greater than the specified thresholdIllustration:

-
intervalsWithValueLessThan
Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than the specified threshold.- Parameters:
valueLessThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is less than the specified thresholdIllustration:

-
intervalsWithValueLessThan
public IntervalSet intervalsWithValueLessThan(Interval withinArgumentInterval, double valueLessThan) Finds and returns anIntervalSetinstance describing the sorted set of intervals where this piecewise function's value is less than the specified threshold.- Parameters:
withinArgumentInterval- the argument interval within which to find the intervals. Must not benullvalueLessThan- the threshold value to compare against. Must be finite and notDouble.NaN- Returns:
- an
IntervalSetinstance describing the sorted set of intervals where this function's value is less than the specified thresholdIllustration:

-
discretized
public PiecewiseFunction discretized(double step, PiecewiseFunction.InterpolationType interpolationType) Returns a discretized version of thisPiecewiseFunctionusing a fixed discretization step. The resulting function is aligned to a uniform grid with the specified step, and its values match the original function exactly at every grid point.At every discretization grid point, for all discretization types:
discretized.valueAt(t) == this.valueAt(t)Interpolation between grid points:
PiecewiseFunction.InterpolationType.STEP_AFTERThe function is reconstructed as a right-continuous step function. On the interval [x,x + step), the value equalsthis.valueAt(t + step). This produces a staircase that preserves all sampled cumulative values at the end of each step.PiecewiseFunction.InterpolationType.LINEARA straight line is used over each interval [x,x + step). The slope is selected so that the line passes exactly through both grid points. The resulting function is a piecewise-linear approximation of the original one, constrained to match at all grid boundaries.
- Parameters:
step- the discretization step size (must be positive and finite)interpolationType- the interpolation method between grid points- Returns:
- A new
PiecewiseFunctionthat is a discretized version of thisPiecewiseFunction.
-
positiveStepChangesSum
public double positiveStepChangesSum()Calculates the sum of positive step changes in this piecewise linear function.- Returns:
- the sum of positive step changes in the function
Illustration:

-
positiveStepChangesSum
Calculates the sum of all positive step changes in this piecewise linear function within the specified argument interval.- Parameters:
withinArgumentInterval- the argument interval within which to calculate the sum of positive step changes- Returns:
- the sum of positive step changes in the function
Illustration:

-
negativeStepChangesSum
public double negativeStepChangesSum()Calculates the sum of all absolute values of negative step changes in this piecewise linear function.- Returns:
- sum of all absolute values of negative step changes in the function
Illustration:

-
negativeStepChangesSum
Calculates the sum of all absolute values of negative step changes in this piecewise linear function within the specified argument interval.- Parameters:
withinArgumentInterval- the argument interval within which to calculate the sum of absolute values of negative step changes- Returns:
- sum of all absolute values of negative step changes in the function
Illustration:

-
toCodeString
Returns a Java code that creates aPiecewiseFunctionequal to this one. Can be used, for example, for unit testing and debugging.- Returns:
- string representing a Java code that creates a
PiecewiseFunctionequal to this one
-
isNonDecreasing
public boolean isNonDecreasing()Checks whether this piecewise function is non-decreasing, i.e.:- it has no negative step changes, and
- It has no segments with negative rate.
- Returns:
trueif the function is non-decreasing,falseotherwise
-
isNonIncreasing
public boolean isNonIncreasing()Checks whether this piecewise function is non-increasing, i.e.:- it has no positive step changes, and
- It has no segments with positive rate.
- Returns:
trueif the function is non-increasing,falseotherwise
-
hashCode
public int hashCode() -
equals
-