Class SummingHistogram.CountOfValues
- Enclosing class:
SummingHistogram
The helper class for static methods of SummingHistogram
class,
calculating the integrals of
More precisely, this class is used by the static methods
SummingHistogram.integralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.integralBetweenValues(int[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(int[], double, double, CountOfValues)
and allows to return some additional information. All these methods have two arguments
minValue, maxValue and calculate the integral of comments to Histogram class
,
in terms of the simple histogram model for first 2 methods or the precise
histogram model for the last 2 methods. The integral is calculated between
Histogram
class). This integral is returned in the result of the methods.
But, while calculating the integral, these methods incidentally calculate the additional information, which is stored in the instance of this class, passed as the last argument, if it is not null. Namely, they calculate:
count()
: the differencer2−r1 = r(maxValue)−r(minValue) ;isLeftBound()
flag: it is true ifr(maxValue)=r(minValue)=0 — in other words, ifminValue..maxValue range fully lies to the left from the minimal element of the source array A[k];isRightBound()
flag: it is true ifr(maxValue)=r(minValue)=N — in other words, ifminValue..maxValue range fully lies to the right from the maximal element of the source array A[k].
If minValue≥maxValue, these methods always return 0.0 and fill the last argument
(if it is not null) by the following values: count()
=0isLeftBound()
=falseisRightBound()
=false
Note: in the special case N=0 (all bars b[k] are zero)
the values of isLeftBound()
and isRightBound()
flags are not specified.
The only way to create an instance of this class is the constructor without arguments,
that creates an uninitialized instance.
"Uninitialized" means that any attempt to read information by count()
,
isLeftBound()
or isRightBound()
leads to IllegalStateException.
The only way to change the information stored in this instance is calling one of 4 static methods
of SummingHistogram
class, listed above.
These methods change its state to initialized.
This class does not implement own equals and hashCode methods. So, this class does not provide a mechanism for comparing different instances of this class.
This class is not thread-safe, but is thread-compatible and can be synchronized manually, if multithread access is necessary.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
count()
Returns the differencer(maxValue)−r(minValue) .boolean
Returns true if and only this object is initialized.boolean
Returns true ifr(maxValue)=r(minValue)=0 — in other words, ifminValue..maxValue range fully lies to the left from the minimal element of the source array A[k].boolean
Returns true ifr(maxValue)=r(minValue)=N — in other words, ifminValue..maxValue range fully lies to the right from the maximal element of the source array A[k].toString()
Returns a brief string description of this object.
-
Constructor Details
-
CountOfValues
public CountOfValues()Creates newuninitialized
instance of this class. You must call one ofSummingHistogram.integralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.integralBetweenValues(int[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(int[], double, double, CountOfValues)
methods for this instance before you will be able to use it.
-
-
Method Details
-
isInitialized
public boolean isInitialized()Returns true if and only this object is initialized. It means that it was passed to one ofSummingHistogram.integralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.integralBetweenValues(int[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(long[], double, double, CountOfValues)
,SummingHistogram.preciseIntegralBetweenValues(int[], double, double, CountOfValues)
methods at least once and that method was successfully finished. If the object is not initialized, then all its methods, excepting this one and methods of the basic Object class (toString, equals, etc.) throw IllegalStateException.- Returns:
- whether this object is initialized.
-
isLeftBound
public boolean isLeftBound()Returns true ifr(maxValue)=r(minValue)=0 — in other words, ifminValue..maxValue range fully lies to the left from the minimal element of the source array A[k]. See thecomments to this class
for more details.If minValue>=maxValue, this method returns false.
- Returns:
- whether
minValue..maxValue range fully lies to the left from the minimal element of the source array A[k]. - Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
isRightBound
public boolean isRightBound()Returns true ifr(maxValue)=r(minValue)=N — in other words, ifminValue..maxValue range fully lies to the right from the maximal element of the source array A[k]. See thecomments to this class
for more details.If minValue>=maxValue, this method returns false.
- Returns:
- whether
minValue..maxValue range fully lies to the right from the maximal element of the source array A[k]. - Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
count
public double count()Returns the differencer(maxValue)−r(minValue) . In other words, it is the number of elements of the source A array, lying in rangeminValue..maxValue , generalized to the real case. See thecomments to this class
for more details.In the precise histogram model, this value can be zero only if
minValue..maxValue range fully lies to the left from the minimal element or to the right from the maximal element of the source array, in other words, if . In all other cases, this method returns a positive value, because r(v) function is increasing. Unlike this, in the simple histogram model this value will be zero also in a case, when all histogram barsisLeftBound()
||isRightBound()
b[k] , k is an integer in range(int)minValue≤k<maxValue, are zero. If minValue>=maxValue, this method returns 0.0.
- Returns:
- the difference
r(maxValue)−r(minValue) . - Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
toString
Returns a brief string description of this object.The result of this method may depend on implementation.
-