Class FloatIntervalTableFunction
java.lang.Object
com.amalgamasimulation.utils.tablefunction.FloatIntervalTableFunction
- All Implemented Interfaces:
ITableFunction
,Serializable
Class representing interval table function - a table function containing an
ordered sequence of intervals [Xi, Xi+1) with a double value assigned to each
interval. Each argument interval includes its lower bound but does not
include its upper bound. Infinite arguments and values are not allowed.
Negative arguments are allowed and fully supported. Negative values are
allowed but can lead to undetermined results of methods relying on cumulative
calculations such as
getSumBetween
, getPeriod
,
getMaxSum
, getMinSum
.- Author:
- Andrey Malykhanov
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected TFloatArrayList
protected TFloatArrayList
protected TFloatArrayList
-
Constructor Summary
ConstructorDescriptionCreates a new instance of empty interval table function with no arguments and values.FloatIntervalTableFunction
(double[] arguments, double[] values) Creates a new instance of interval table function with specified arguments and values.FloatIntervalTableFunction
(float[] arguments, float[] values) FloatIntervalTableFunction
(List<FloatPair> argumentsAndValues, boolean floatPairs) FloatIntervalTableFunction
(List<Pair<Double, Double>> argumentsAndValues) Creates a new instance of interval table function with specified arguments and values.FloatIntervalTableFunction
(List<Double> arguments, List<Double> values) Creates a new instance of interval table function with specified arguments and values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInterval
(double beginArgInclusive, double endArgExclusive, double value) Adds a new interval to the interval table function.double
get
(double arg) Returns value by argumentgetAdjacentValues
(double arg) Returns two values closest to argument, first is left-sided, second is right-sidedReturns all cumulative argument-value pairsReturns all argument-value pairsdouble
getAverageSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns average sum value between the specified argumentsgetCopy()
double
getCumulative
(double arg) Returns cumulative sum of values by the given argumentdouble
getInterpolated
(double arg) double
Returns minimal argument with non-zero valuedouble
getMaxNonZeroArgumentBetween
(double beginArgument, double endArgument) Returns minimal argument with non-zero value.double
getMaxSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns maximum value between the specified argumentsdouble
Returns minimal argument with non-zero valuedouble
getMinNonZeroArgumentBetween
(double beginArgument, double endArgument) Returns minimal argument with non-zero value.double
getMinSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns minimum value between the specified argumentsdouble
getPeriod
(double beginArgInclusive, double cumulativeValueLimit) Returns the argument with cumulative value summ equal tocumulativeValueLimit
double
getSumBetween
(double beginArgInclusive, double endArgExclusive) Retruns square under the line of the plot between the specified values (definite integral of the function frombeginArgInclusive
toendArgExclusive
).void
multiply
(double factor) toString()
-
Field Details
-
arguments
-
values
-
cumulativeValues
-
-
Constructor Details
-
FloatIntervalTableFunction
Creates a new instance of interval table function with specified arguments and values. Number of arguments should be equal to number of values. Arguments and values should all be finite numbers. If arguments are sorted in ascending order and there are no repeating arguments, a new instance will be created fast, otherwise additional calculations will be made to sort arguments and group values for repeating arguments.- Parameters:
arguments
- - list of arguments. NaNs and infinities are not allowed.values
- - list of values. NaNs and infinities are not allowed.
-
FloatIntervalTableFunction
Creates a new instance of interval table function with specified arguments and values. Arguments and values should all be finite numbers. If arguments are sorted in ascending order and there are no repeating arguments, a new instance will be created fast, otherwise additional calculations will be made to sort arguments and group values for repeating arguments.- Parameters:
argumentsAndValues
- - list of (argument, value) pairs. NaNs and infinities are not allowed.
-
FloatIntervalTableFunction
-
FloatIntervalTableFunction
public FloatIntervalTableFunction(double[] arguments, double[] values) Creates a new instance of interval table function with specified arguments and values. Number of arguments should be equal to number of values. Arguments and values should all be finite numbers. If arguments are sorted in ascending order and there are no repeating arguments, a new instance will be created fast, otherwise additional calculations will be made to sort arguments and group values for repeating arguments.- Parameters:
arguments
- - list of arguments. NaNs and infinities are not allowed.values
- - list of values. NaNs and infinities are not allowed.
-
FloatIntervalTableFunction
public FloatIntervalTableFunction(float[] arguments, float[] values) -
FloatIntervalTableFunction
public FloatIntervalTableFunction()Creates a new instance of empty interval table function with no arguments and values.
-
-
Method Details
-
addInterval
public void addInterval(double beginArgInclusive, double endArgExclusive, double value) Adds a new interval to the interval table function. The interval partially cover or overlap several existing intervals.- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so that interval has non-zero length. NaNs and infinities are not allowed.value
- - value added to the specified interval. NaNs and infinities are not allowed.
-
getSumBetween
public double getSumBetween(double beginArgInclusive, double endArgExclusive) Retruns square under the line of the plot between the specified values (definite integral of the function frombeginArgInclusive
toendArgExclusive
).- Specified by:
getSumBetween
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so that interval has non-zero length. NaNs and infinities are not allowed.- Returns:
- Square under the line of the plot between the specified values.
-
getPeriod
public double getPeriod(double beginArgInclusive, double cumulativeValueLimit) Returns the argument with cumulative value summ equal tocumulativeValueLimit
- Specified by:
getPeriod
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.cumulativeValueLimit
- - cumulative values limit. NaNs and infinities are not allowed.- Returns:
- The argument with cumulative value summ equal to
cumulativeValueLimit
-
getMaxSum
public double getMaxSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns maximum value between the specified arguments- Specified by:
getMaxSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so that interval has non-zero length. NaNs and infinities are not allowed.argWindow
- - argument windowargStep
- - step between the arguments- Returns:
- Maximum argument between the specified values
-
getAverageSum
public double getAverageSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns average sum value between the specified arguments- Specified by:
getAverageSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so that interval has non-zero length. NaNs and infinities are not allowed.argWindow
- - argument windowargStep
- - step between the arguments- Returns:
- Average sum value between the specified arguments
-
getMinSum
public double getMinSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns minimum value between the specified arguments- Specified by:
getMinSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so that interval has non-zero length. NaNs and infinities are not allowed.argWindow
- - argument windowargStep
- - step between the arguments- Returns:
- Minimum argument between the specified values
-
get
public double get(double arg) Returns value by argument- Specified by:
get
in interfaceITableFunction
- Parameters:
arg
- - argument- Returns:
- Value by argument
-
getInterpolated
public double getInterpolated(double arg) - Specified by:
getInterpolated
in interfaceITableFunction
-
getMinNonZeroArgument
public double getMinNonZeroArgument()Returns minimal argument with non-zero value- Specified by:
getMinNonZeroArgument
in interfaceITableFunction
- Returns:
- Minimal argument with non-zero value, or Double.POSITIVE_INFINITY if there are no non-zero values in the table function
-
getMinNonZeroArgumentBetween
public double getMinNonZeroArgumentBetween(double beginArgument, double endArgument) Returns minimal argument with non-zero value. Restricts the search by the area between beginArgument time and endArgument inclusive- Specified by:
getMinNonZeroArgumentBetween
in interfaceITableFunction
- Parameters:
beginArgument
- - right border of the arguments search intervalendArgument
- - left border of the arguments search interval- Returns:
- Minimal argument with non-zero value, or Double.POSITIVE_INFINITY if there are no non-zero values in the table function
-
getMaxNonZeroArgument
public double getMaxNonZeroArgument()Returns minimal argument with non-zero value- Specified by:
getMaxNonZeroArgument
in interfaceITableFunction
- Returns:
- Minimal argument with non-zero value, or Double.NEGATIVE_INFINITY if there are no non-zero values in the table function
-
getMaxNonZeroArgumentBetween
public double getMaxNonZeroArgumentBetween(double beginArgument, double endArgument) Returns minimal argument with non-zero value. Restricts the search by the area between beginArgument time and endArgument inclusive- Specified by:
getMaxNonZeroArgumentBetween
in interfaceITableFunction
- Parameters:
beginArgument
- - right border of the arguments search intervalendArgument
- - left border of the arguments search interval- Returns:
- Minimal argument with non-zero value, or Double.NEGATIVE_INFINITY if there are no non-zero values in the table function
-
getCumulative
public double getCumulative(double arg) Returns cumulative sum of values by the given argument- Parameters:
arg
- - argument, cannot be NaN or infinity- Returns:
- Cumulative square under the plot of function from -Infinity to by the given argument
-
getAdjacentValues
Returns two values closest to argument, first is left-sided, second is right-sided- Parameters:
arg
- - argument- Returns:
- Two values closest to argument, first is left-sided, second is right-sided
-
getArgumentValuePairs
Returns all argument-value pairs- Specified by:
getArgumentValuePairs
in interfaceITableFunction
- Returns:
- All argument-value pairs
-
getArgumentCumulativeValuePairs
Returns all cumulative argument-value pairs- Returns:
- All cumulative argument-value pairs
-
getCopy
- Specified by:
getCopy
in interfaceITableFunction
-
multiply
public void multiply(double factor) -
toString
-