|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.science.Bins.Intervals
public static class Bins.Intervals
Specifies how a given set of intervals are laid out.
The left (start) boundary of the leftmost (smallest) interval is given by begin
.
The right (end) boundary of the rightmost (largest) interval is given by end
.
In between these bounds, a total of number
intervals are present, each approximately of the same size width
.
Using the interval boundary convention discussed in the class javadocs
,
the boundaries are {begin, begin + 1*width, ..., begin + (number - 1)*width}
.
Written out explicitly, the intervals are
[begin, begin + 1*width),
[begin + 1*width, begin + 2*width),
...,
[begin + (number - 1)*width, end]
where end == number*width
.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
private double |
begin
|
private double |
end
|
private int |
number
|
private double |
width
|
Constructor Summary | |
---|---|
private |
Bins.Intervals(double begin,
double end,
int number)
Constructor. |
Method Summary | |
---|---|
private double |
boundary(int i)
Returns the ith interval boundary's left value (i.e. the smallest value that is inside the interval). |
boolean |
equals(Object obj)
Determines equality based on whether or not obj is an Intervals instance whose every field equals that of this instance. |
double |
getBegin()
Accessor for begin . |
double |
getEnd()
Accessor for end . |
int |
getNumber()
Accessor for number . |
double |
getWidth()
Accessor for width . |
int |
hashCode()
|
private int |
index(double d)
Returns the index of the interval which contains d. |
private static Bins.Intervals |
make(double[] values,
double offset,
double width)
Specifies that minimal set of intervals which satisifes these conditions: every element of values is inside one of the intervals every interval in the set has the same size, equal to the width param every interval's boundary points are separated from offset by an integral multiple of width. |
private static Bins.Intervals |
make(double[] values,
int number)
Specifies that set of intervals which satisifes these conditions: every element of values is inside one of the intervals the number of intervals in the set equals the number param the left (starting) boundary of the leftmost (smallest) interval equals the minimum element of values the right (ending) boundary of the rightmost (largest) interval equals the maximum element of values This method finds the min and max elements of values, which it uses for begin and end . |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final double begin
private final double end
private final int number
private final double width
Constructor Detail |
---|
private Bins.Intervals(double begin, double end, int number) throws IllegalArgumentException, IllegalStateException
IllegalArgumentException
- if begin is not normal
;
end is not normal;
begin is not < end;
number <= 0
IllegalStateException
- if some internal problem occursMethod Detail |
---|
private static Bins.Intervals make(double[] values, double offset, double width) throws IllegalArgumentException, IllegalStateException
boundaryPoint = offset + (i * width)
for some int i.
This method finds the min and max elements of values,
which it uses to compute appropriate values for begin
and end
.
Note that offset need not lie inside the intervals (i.e. inside [begin, end]).
This method is useful when you want control over where the interval boundary points fall. A common requirement might be that the boundaries are always integers. In this case, supply offset = 0 and width = 1.
IllegalArgumentException
- if values == null; values.length == 0; any element of values is NaN;
offset is not normal
;
width is not normal and positive
IllegalStateException
- if some internal problem occursprivate static Bins.Intervals make(double[] values, int number) throws IllegalArgumentException, IllegalStateException
This method finds the min and max elements of values,
which it uses for begin
and end
.
IllegalArgumentException
- if values == null; values.length == 0; any element of values is NaN;
number <= 0
IllegalStateException
- if some internal problem occurspublic double getBegin()
begin
.
public double getEnd()
end
.
public int getNumber()
number
.
public double getWidth()
width
.
public final boolean equals(Object obj)
equals
in class Object
public final int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
private double boundary(int i) throws IllegalArgumentException
Contract: the result is >= begin
and < end
IllegalArgumentException
- if i is < 0 or >= number
private int index(double d) throws IllegalArgumentException
Contract: the result is guaranteed to be >= 0 and < number
.
IllegalArgumentException
- if d is not normal
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |