Class FloatIntervalTableFunction

java.lang.Object
com.amalgamasimulation.utils.tablefunction.FloatIntervalTableFunction
All Implemented Interfaces:
ITableFunction, Serializable

public class FloatIntervalTableFunction extends Object implements ITableFunction
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 Details

  • Constructor Details

    • FloatIntervalTableFunction

      public FloatIntervalTableFunction(List<Double> arguments, List<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(List<Pair<Double,Double>> argumentsAndValues)
      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

      public FloatIntervalTableFunction(List<FloatPair> argumentsAndValues, boolean floatPairs)
    • 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 than beginArgInclusive 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 from beginArgInclusive to endArgExclusive).
      Specified by:
      getSumBetween in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive 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 to cumulativeValueLimit
      Specified by:
      getPeriod in interface ITableFunction
      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 interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - 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 interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - 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 interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - 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 interface ITableFunction
      Parameters:
      arg - - argument
      Returns:
      Value by argument
    • getInterpolated

      public double getInterpolated(double arg)
      Specified by:
      getInterpolated in interface ITableFunction
    • getMinNonZeroArgument

      public double getMinNonZeroArgument()
      Returns minimal argument with non-zero value
      Specified by:
      getMinNonZeroArgument in interface ITableFunction
      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 interface ITableFunction
      Parameters:
      beginArgument - - right border of the arguments search interval
      endArgument - - 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 interface ITableFunction
      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 interface ITableFunction
      Parameters:
      beginArgument - - right border of the arguments search interval
      endArgument - - 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

      public Pair<Double,Double> getAdjacentValues(double arg)
      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

      public List<Pair<Double,Double>> getArgumentValuePairs()
      Returns all argument-value pairs
      Specified by:
      getArgumentValuePairs in interface ITableFunction
      Returns:
      All argument-value pairs
    • getArgumentCumulativeValuePairs

      public List<Pair<Double,Double>> getArgumentCumulativeValuePairs()
      Returns all cumulative argument-value pairs
      Returns:
      All cumulative argument-value pairs
    • getCopy

      public FloatIntervalTableFunction getCopy()
      Specified by:
      getCopy in interface ITableFunction
    • multiply

      public void multiply(double factor)
    • toString

      public String toString()
      Overrides:
      toString in class Object