suramadu.util.stats
Class Histogram

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

public class Histogram
extends java.lang.Object

A class to facilitate the creation of a histogram data structure for examining the distribution of various kinds of numeric data.

Author:
mbi

Constructor Summary
Histogram(byte loBound, byte hiBound, byte numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
Histogram(java.lang.Comparable[] bounds)
          Creates a new instance of Histogram 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).
Histogram(java.lang.Comparable[] bounds, java.util.Collection c)
          Creates a new instance of Histogram with the specified Collection.
Histogram(java.lang.Comparable[] bounds, java.lang.Number[] nArray)
          Creates a new instance of Histogram with the specified array of Number Objects.
Histogram(double loBound, double hiBound, double numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
Histogram(float loBound, float hiBound, float numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
Histogram(HistogramBinSpec binSpec)
          Creates a new instance of Histogram using the specified HistogramBinSpec
Histogram(HistogramBinSpec binSpec, java.util.Collection c)
          Creates a new instance of Histogram using the specified HistogramBinSpec with the specified Collection.
Histogram(int loBound, int hiBound, int numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
Histogram(long loBound, long hiBound, long numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
Histogram(short loBound, short hiBound, short numBins, java.util.Collection c)
          Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection.
 
Method Summary
 void add(java.lang.Number n)
          Adds a Number Object to this Histogram
 HistogramBin getMode()
          Gets the HistogramBin from this Histogram that contains the most values.
static void main(java.lang.String[] args)
          Test method for unit testing.
 java.lang.String toString()
          Creates a String representation for this Histogram.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Histogram

public Histogram(int loBound,
                 int hiBound,
                 int numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(short loBound,
                 short hiBound,
                 short numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(byte loBound,
                 byte hiBound,
                 byte numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(long loBound,
                 long hiBound,
                 long numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(float loBound,
                 float hiBound,
                 float numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(double loBound,
                 double hiBound,
                 double numBins,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified low bound, high bound, and numBins, with the specified Collection. Units are arbitrary.

Parameters:
loBound - the lowest bound for this Histogram
hiBound - the highest bound for this Histogram
numBins - the number of HistogramBins to create in this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface to be collated into this Histogram.
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(HistogramBinSpec binSpec)
Creates a new instance of Histogram using the specified HistogramBinSpec

Parameters:
binSpec - an instance of a HistogramBinSpec for this Histogram
See Also:
HistogramBinSpec

Histogram

public Histogram(HistogramBinSpec binSpec,
                 java.util.Collection c)
Creates a new instance of Histogram using the specified HistogramBinSpec with the specified Collection. Units are arbitrary.

Parameters:
binSpec - an instance of a HistogramBinSpec for this Histogram
c - a Collection of like Objects that implement the java.lang.Comparable interface
See Also:
Comparable, Collection, HistogramBinSpec

Histogram

public Histogram(java.lang.Comparable[] bounds)
Creates a new instance of Histogram 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:
bounds - an array of bounds, alternating between low bound and high bound for consecutive and adjascent HistogramBins.

Histogram

public Histogram(java.lang.Comparable[] bounds,
                 java.util.Collection c)
Creates a new instance of Histogram with the specified Collection. The bounds are specified 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:
bounds - an array of bounds, alternating between low bound and high bound for consecutive and adjascent HistogramBins.
c - a Collection of like Objects that implement the java.lang.Comparable interface

Histogram

public Histogram(java.lang.Comparable[] bounds,
                 java.lang.Number[] nArray)
Creates a new instance of Histogram with the specified array of Number Objects. The bounds are specified 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:
bounds - an array of bounds, alternating between low bound and high bound for consecutive and adjascent HistogramBins.
nArray - an array of like Number Objects.
Method Detail

main

public static void main(java.lang.String[] args)
Test method for unit testing. Should be commented out for shipping

Parameters:
args - the usual main() args.

add

public void add(java.lang.Number n)
Adds a Number Object to this Histogram

Parameters:
n - the Number object to add.

getMode

public HistogramBin getMode()
Gets the HistogramBin from this Histogram that contains the most values.

Returns:
the HistogramBin from this Histogram that contains the most values.
See Also:
HistogramBin

toString

public java.lang.String toString()
Creates a String representation for this Histogram.

Returns:
a String representation for this Histogram.