Package org.epics.util.stats
Class Range
- java.lang.Object
-
- org.epics.util.stats.Range
-
public final class Range extends Object
A range of numeric values.For the purpose of range calculation, NaNs should be skipped. The only case where NaNs are allowed is for the UNDEFINED range.
The minimum and maximum are simply double values.
- Author:
- carcassi
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Range
combine(Range other)
Determines the range that can contain both ranges.boolean
contains(double value)
Determines whether the value is contained by the range or not.boolean
contains(Range range)
Determines whether the given range is contained by the range or not.boolean
equals(Object obj)
double
getMaximum()
The maximum value.double
getMinimum()
The minimum value.int
hashCode()
boolean
isFinite()
Whether the range is finite and non-zero.boolean
isReversed()
Whether the range goes from min to max or from max to min.double
normalize(double value)
Returns the value normalized within the range.static Range
of(double minValue, double maxValue)
Range from given min and max.double
rescale(double value)
Takes a normalized value and returns a proportional value within the range.Range
shrink(double factor)
Returns a new range with the same center value and width equal to the original width multiplied by the given factor.String
toString()
static Range
undefined()
An undefined range.
-
-
-
Method Detail
-
getMinimum
public double getMinimum()
The minimum value.- Returns:
- a value
-
getMaximum
public double getMaximum()
The maximum value.- Returns:
- a value
-
isReversed
public boolean isReversed()
Whether the range goes from min to max or from max to min.- Returns:
- true if range should be traversed from max to min
-
isFinite
public boolean isFinite()
Whether the range is finite and non-zero.- Returns:
- true if range is finite and non-zero
-
normalize
public double normalize(double value)
Returns the value normalized within the range. It performs a linear transformation where the minimum value of the range becomes 0 while the maximum becomes 1.- Parameters:
value
- a value- Returns:
- the value transformed based on the range
-
rescale
public double rescale(double value)
Takes a normalized value and returns a proportional value within the range. It performs a linear transformation where 0 becomes the minimum value of the range while 1 becomes the maximum.- Parameters:
value
- a value- Returns:
- the value transformed based on the range
-
contains
public boolean contains(double value)
Determines whether the value is contained by the range or not.- Parameters:
value
- a value- Returns:
- true if the value is within the range
-
contains
public boolean contains(Range range)
Determines whether the given range is contained by the range or not.- Parameters:
range
- a range- Returns:
- true if the range is a subrange of this
-
combine
public Range combine(Range other)
Determines the range that can contain both ranges. If one of the ranges in contained in the other, the bigger range is returned.- Parameters:
other
- another range- Returns:
- the bigger range
-
shrink
public Range shrink(double factor)
Returns a new range with the same center value and width equal to the original width multiplied by the given factor.- Parameters:
factor
- the multiplicative factor to resize the range width- Returns:
- a new range
-
undefined
public static Range undefined()
An undefined range.- Returns:
- the undefined range
-
of
public static Range of(double minValue, double maxValue)
Range from given min and max. If max is greater than min, a reversed range is returned.- Parameters:
minValue
- minimum valuemaxValue
- maximum value- Returns:
- the range
-
-