AlgART Home

net.algart.arrays
Class SummingHistogram.CountOfValues

java.lang.Object
  extended by net.algart.arrays.SummingHistogram.CountOfValues
Enclosing class:
SummingHistogram

public static final class SummingHistogram.CountOfValues
extends java.lang.Object

The helper class for static methods of SummingHistogram class, calculating the integrals of v(r) function between two given values: minValuevmaxValue.

More precisely, this class is used by the static methods

and allows to return some additional information. All these methods have two arguments minValue, maxValue and calculate the integral of v(r), defined in 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 r1=r(maxValue) and r2=r(maxValue), where r(v) is the inverse function to v(r) (see 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:

If minValue≥maxValue, these methods always return 0.0 and fill the last argument (if it is not null) by the following values: count()=0, isLeftBound()=false, isRightBound()=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
Constructor and Description
SummingHistogram.CountOfValues()
          Creates new uninitialized instance of this class.
 
Method Summary
Modifier and Type Method and Description
 double count()
          Returns the difference r(maxValue)−r(minValue).
 boolean isInitialized()
          Returns true if and only this object is initialized.
 boolean isLeftBound()
          Returns true if r(maxValue)=r(minValue)=0 — in other words, if minValue..maxValue range fully lies to the left from the minimal element of the source array A[k].
 boolean isRightBound()
          Returns true if r(maxValue)=r(minValue)=N — in other words, if minValue..maxValue range fully lies to the right from the maximal element of the source array A[k].
 java.lang.String toString()
          Returns a brief string description of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SummingHistogram.CountOfValues

public SummingHistogram.CountOfValues()
Creates new uninitialized instance of this class. You must call one of SummingHistogram.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 Detail

isInitialized

public boolean isInitialized()
Returns true if and only this object is initialized. It means that it was passed to one of SummingHistogram.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 if r(maxValue)=r(minValue)=0 — in other words, if minValue..maxValue range fully lies to the left from the minimal element of the source array A[k]. See the comments 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:
java.lang.IllegalStateException - if this instance is not initialized yet.

isRightBound

public boolean isRightBound()
Returns true if r(maxValue)=r(minValue)=N — in other words, if minValue..maxValue range fully lies to the right from the maximal element of the source array A[k]. See the comments 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:
java.lang.IllegalStateException - if this instance is not initialized yet.

count

public double count()
Returns the difference r(maxValue)−r(minValue). In other words, it is the number of elements of the source A array, lying in range minValue..maxValue, generalized to the real case. See the comments 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 isLeftBound() || isRightBound(). 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 bars b[k], k is an integer in range (int)minValuek<maxValue, are zero.

If minValue>=maxValue, this method returns 0.0.

Returns:
the difference r(maxValue)−r(minValue).
Throws:
java.lang.IllegalStateException - if this instance is not initialized yet.

toString

public java.lang.String toString()
Returns a brief string description of this object.

The result of this method may depend on implementation.

Overrides:
toString in class java.lang.Object
Returns:
a brief string description of this object.