jklustor-overlap-0.0.2-20140619012940 (ChemAxon)


com.chemaxon.calculations.util
Class Histo

Object
  extended by com.chemaxon.calculations.util.Histo

@Beta
public class Histo
extends Object

Simple histogram of values.

Author:
Gabor Imre

Constructor Summary
Histo(double l, double h, int bins)
           
Histo(double l, double h, int bins, boolean autoscale, boolean autoalloc)
          Create a histogram containing real numbers.
Histo(int minValue, int bins)
           
Histo(int minValue, int bins, int binWidth, boolean autoalloc)
          Create a histogram containing integers.
 
Method Summary
 void add(double d)
          Add a value to the histogram.
 long getBin(int bin)
          Get the value from a bin.
 int getBinCount()
          Get bin count.
 Optional<Integer> getBinIndex(double d)
          Look up associated bin.
 double getBinLowerBound(int bin)
          Lower bound of a bin.
 double getBinUpperBound(int bin)
          Upper bound of a bin.
 List<String> getHistoBody(int rows)
          Compose histogram body
 double getLowerBound()
          Lower bound of the histogram.
 List<String> getSmallestBinsBlock(int rows)
          Compose the list of smallest bins block.
 List<String> getStatBlock()
          Compose statistics block.
 double getUpperBound()
          Upper bound of the histogram.
 boolean isEmpty()
          Check if the histogram is empty.
 boolean isInCurrentBounds(double d)
          Check if a bin is associated with the given value.
(package private) static long max(long[] l)
          Find maximum in an array.
(package private) static long sum(long[] l)
          Sum the elements of a given array.
 String toString()
           
 String toString(int rows, boolean listSmallBins)
           
 List<String> toStrings()
           
 List<String> toStrings(int rows, boolean listSmallBins)
          Create a String representation.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Histo

public Histo(int minValue,
             int bins,
             int binWidth,
             boolean autoalloc)
Create a histogram containing integers.


Histo

public Histo(int minValue,
             int bins)

Histo

public Histo(double l,
             double h,
             int bins,
             boolean autoscale,
             boolean autoalloc)
Create a histogram containing real numbers.

Parameters:
l - Lowest value to be assigned to the first bin.
h - Highest value to be assigned to the last bin.
bins - Bin count.

Histo

public Histo(double l,
             double h,
             int bins)
Method Detail

isEmpty

public boolean isEmpty()
Check if the histogram is empty.

Returns:
True when no values added yet

add

public void add(double d)
Add a value to the histogram.

Parameters:
d - Value to be added

max

static long max(long[] l)
Find maximum in an array.

Parameters:
l - Array of number
Returns:
The maximum value found in the array

sum

static long sum(long[] l)
Sum the elements of a given array.

Parameters:
l - Array of numbers
Returns:
Sum of the elements of the given array

isInCurrentBounds

public boolean isInCurrentBounds(double d)
Check if a bin is associated with the given value.

Parameters:
d - Value
Returns:
true when the value can be assigned to a specific bin
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getBinCount

public int getBinCount()
Get bin count.

Returns:
Count of individual bins

getLowerBound

public double getLowerBound()
Lower bound of the histogram.

Returns:
Lower bound of the histogram
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getUpperBound

public double getUpperBound()
Upper bound of the histogram.

Returns:
Upper bound of the histogram
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getBinLowerBound

public double getBinLowerBound(int bin)
Lower bound of a bin.

Parameters:
bin - Index of a bin (0-based)
Returns:
Lower bound of a bin. This value is always inclusive, an item equals with this value is always associated to the given bin
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getBinUpperBound

public double getBinUpperBound(int bin)
Upper bound of a bin.

Parameters:
bin - Index of a bin (0-based)
Returns:
Upper bound of a bin. This value is usually not inclusive, an item equals with this value is usually associated to the next bin. Exclusion is the last bin, an item equals with its upper bound is assigned to itself.
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getBinIndex

public Optional<Integer> getBinIndex(double d)
Look up associated bin.

Parameters:
d - A value
Returns:
Associated bin index if not out of bounds
Throws:
UnsupportedOperationException - when the underlying histogram is auto scaled, in this case the result of this check would depend on the subsequent value additions.

getBin

public long getBin(int bin)
Get the value from a bin.

Parameters:
bin - Bin index
Returns:
Value of the bin.

getStatBlock

public List<String> getStatBlock()
Compose statistics block.

Statistics block is a set of lines containing counts, sum, avg, etc

Returns:
List of one line Strings

getHistoBody

public List<String> getHistoBody(int rows)
Compose histogram body

Histogram body is the chart area, with axis labels.

Parameters:
rows - Number of rows in the chart area
Returns:
List of one line Strings (length is rows + 3 lines)

getSmallestBinsBlock

public List<String> getSmallestBinsBlock(int rows)
Compose the list of smallest bins block.

Smallest bins are the bins, which presented with a minimal height bar and contains fewer than 50% of the values represented by the associated bar.

Parameters:
rows - Number of rows used to render the histogram
Returns:
List of Strings

toStrings

public List<String> toStrings(int rows,
                              boolean listSmallBins)
Create a String representation.

Parameters:
rows - Rows to use for the histogram area
listSmallBins - List of smallest bins to be printed
Returns:
String representation

toString

public String toString(int rows,
                       boolean listSmallBins)

toStrings

public List<String> toStrings()

toString

public String toString()
Overrides:
toString in class Object

jklustor-overlap-0.0.2-20140619012940 (ChemAxon)