suramadu.util.stats
Class HistogramBinSpec

java.lang.Object
  extended bysuramadu.util.stats.HistogramBinSpec

public class HistogramBinSpec
extends java.lang.Object

This class is a container for HistogramBin classes. Each HistogramBin defines the specification for a single bin in a Histogram. It is the duty of the HistogramBinSpec to enforce consistency across all HistogramBins added to it, making sure that there are not overlaps, etc.

Author:
mbi

Constructor Summary
HistogramBinSpec()
          Creates a new instance of HistogramBinSpec.
HistogramBinSpec(byte loBound, byte hiBound, byte numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(java.lang.Comparable[] limits)
          Creates a new HistogramBinSpec using an array of values organized as pairs of bounds, the even numbered elements being low bounds, and the odd numbered elements being high bounds (zero based).
HistogramBinSpec(double loBound, double hiBound, double numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(float loBound, float hiBound, float numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(HistogramBin[] bins)
          Creates a new HistogramBinSpec using the specified array of HistogramBins.
HistogramBinSpec(int loBound, int hiBound, int numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(long loBound, long hiBound, long numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(java.lang.Number loBound, java.lang.Number hiBound, java.lang.Number numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
HistogramBinSpec(short loBound, short hiBound, short numBins)
          Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins.
 
Method Summary
 boolean addBin(java.lang.Comparable loBound, java.lang.Comparable hiBound)
          Adds a bin to the HistogramBinspec.
 boolean addBin(HistogramBin bin)
          Adds a bin to the HistogramBinspec.
 HistogramBin getBin(java.lang.Number n)
          Find the HistogramBin in this HistogramBinSpec in which the specified Number object resides.
 HistogramBin getModeBin()
          Get the HistogramBin whose count has the greatest value.
 java.util.Iterator iterator()
          Get an iterator to the HistogramBin list in ascending range order
 java.lang.String toString()
          Create a descriptive String that indicates the ranges and counts of all HistogramBins in this HistogramBinSpec
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HistogramBinSpec

public HistogramBinSpec()
Creates a new instance of HistogramBinSpec. This initializes bins to a new ArrayList, and nulls out freqSortedList.


HistogramBinSpec

public HistogramBinSpec(HistogramBin[] bins)
Creates a new HistogramBinSpec using the specified array of HistogramBins. The consistency of the provided bins is checked as the HistogramBinSpec is being created.

Parameters:
bins - An array of HistogramBins from which to construct this HistogramBinSpec.
See Also:
HistogramBin

HistogramBinSpec

public HistogramBinSpec(int loBound,
                        int hiBound,
                        int numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(short loBound,
                        short hiBound,
                        short numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(byte loBound,
                        byte hiBound,
                        byte numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(long loBound,
                        long hiBound,
                        long numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(float loBound,
                        float hiBound,
                        float numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(double loBound,
                        double hiBound,
                        double numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).

HistogramBinSpec

public HistogramBinSpec(java.lang.Number loBound,
                        java.lang.Number hiBound,
                        java.lang.Number numBins)
Creates a new HistogramBinSpec using the specified loBound, hiBound, and numBins. The units are arbitrary.

Parameters:
loBound - The lowest bound of the HistogramBinSpec
hiBound - The highest bound of the HistogramBinSpec
numBins - The number of bins to create in this HistogramBinSpec (minus 2 for the bottom bin and the top bin).
See Also:
HistogramBin

HistogramBinSpec

public HistogramBinSpec(java.lang.Comparable[] limits)
Creates a new HistogramBinSpec using an array of values organized as pairs of bounds, the even numbered elements being low bounds, and the odd numbered elements being high bounds (zero based). Bin consistency is checked at construction time.

Parameters:
limits - an array of bounds, alternating between low bound and high bound for consecutive and adjascent HistogramBins.
Method Detail

addBin

public boolean addBin(java.lang.Comparable loBound,
                      java.lang.Comparable hiBound)
Adds a bin to the HistogramBinspec. Bins are checked for overlapping, but are not checked for continuously adjascent.

Parameters:
loBound - the lower boundary of the HistogramBin to be created.
hiBound - the upper boundary of the HistogramBin to be created.
Returns:
true if successful, false if the new HistogramBin overlaps any existing HistogramBin in the HistogramBinSpec.
See Also:
HistogramBin, Range

addBin

public boolean addBin(HistogramBin bin)
Adds a bin to the HistogramBinspec. Bins are checked for overlapping, but are not checked for continuously adjascent.

Parameters:
bin - the HistogramBin to add to this HistogramBinSpec
Returns:
true if successful, false if the new HistogramBin overlaps any existing HistogramBin in the HistogramBinSpec.
See Also:
HistogramBin, Range

getBin

public HistogramBin getBin(java.lang.Number n)
Find the HistogramBin in this HistogramBinSpec in which the specified Number object resides.

Parameters:
n - A Number object for which to find the HistogramBin whose range encompasses it.
Returns:
the HistogramBin object that describes the range that would include the value of the specified Number
See Also:
HistogramBin

getModeBin

public HistogramBin getModeBin()
Get the HistogramBin whose count has the greatest value.

Returns:
the HistogramBin that contains the largest count in the current HistogramBinSpec.
See Also:
HistogramBin

iterator

public java.util.Iterator iterator()
Get an iterator to the HistogramBin list in ascending range order

Returns:
an iterator to the HistogramBin list in ascending range order
See Also:
HistogramBin

toString

public java.lang.String toString()
Create a descriptive String that indicates the ranges and counts of all HistogramBins in this HistogramBinSpec

Returns:
a descriptive String that indicates the ranges and counts of all HistogramBins in this HistogramBinSpec
See Also:
HistogramBin