Package elki.math
Class DoubleMinMax
- java.lang.Object
-
- elki.math.DoubleMinMax
-
public class DoubleMinMax extends java.lang.Object
Class to find the minimum and maximum double values in data.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Constructor Summary
Constructors Constructor Description DoubleMinMax()
Constructor without starting values.DoubleMinMax(double min, double max)
Constructor with predefined minimum and maximum values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
asDoubleArray()
Return minimum and maximum as array.double
getDiff()
Return the difference between minimum and maximum.double
getMax()
Get the current maximum.double
getMin()
Get the current minimum.boolean
isValid()
Test whether the result is defined.static DoubleMinMax[]
newArray(int size)
Generate a new array of initialized DoubleMinMax objects (with default constructor)void
put(double val)
Process a single double value.void
put(double[] data)
Process a whole array of double values.void
put(DoubleMinMax val)
Process a MinMax pair.void
reset()
Reset statistics.java.lang.String
toString()
-
-
-
Constructor Detail
-
DoubleMinMax
public DoubleMinMax()
Constructor without starting values. The minimum will be initialized toDouble.POSITIVE_INFINITY
. The maximum will be initialized toDouble.NEGATIVE_INFINITY
. So that the first data added will replace both.
-
DoubleMinMax
public DoubleMinMax(double min, double max)
Constructor with predefined minimum and maximum values.- Parameters:
min
- Minimum valuemax
- Maximum value
-
-
Method Detail
-
put
public void put(double val)
Process a single double value. If the new value is smaller than the current minimum, it will become the new minimum. If the new value is larger than the current maximum, it will become the new maximum.- Parameters:
val
- New value
-
put
public void put(double[] data)
Process a whole array of double values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.- Parameters:
data
- Data to process
-
put
public void put(DoubleMinMax val)
Process a MinMax pair.- Parameters:
val
- New value
-
getMin
public double getMin()
Get the current minimum.- Returns:
- current minimum.
-
getMax
public double getMax()
Get the current maximum.- Returns:
- current maximum.
-
getDiff
public double getDiff()
Return the difference between minimum and maximum.- Returns:
- Difference of current Minimum and Maximum.
-
isValid
public boolean isValid()
Test whether the result is defined.- Returns:
- true when at least one value has been added
-
asDoubleArray
public double[] asDoubleArray()
Return minimum and maximum as array.- Returns:
- Minimum, Maximum
-
newArray
public static DoubleMinMax[] newArray(int size)
Generate a new array of initialized DoubleMinMax objects (with default constructor)- Parameters:
size
- Array size- Returns:
- initialized array
-
reset
public void reset()
Reset statistics.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-