org.jboss.dna.common.statistic
Class Histogram<T extends Number>

java.lang.Object
  extended by org.jboss.dna.common.statistic.Histogram<T>
Type Parameters:
T - the type of value

@NotThreadSafe
public class Histogram<T extends Number>
extends Object

A representation of a histogram of values.


Nested Class Summary
 class Histogram.Bucket
          Represents a bucket in a histogram.
 class Histogram.BucketingStrategy
           
 class Histogram.DefaultBucketingStrategy
           
 class Histogram.ExplicitBucketingStrategy
           
 class Histogram.StandardDeviationBucketingStrategy
           
 
Field Summary
static int DEFAULT_BUCKET_COUNT
           
static int DEFAULT_SIGNIFICANT_FIGURES
           
 
Constructor Summary
Histogram(MathOperations<T> operations, List<T> values)
           
Histogram(MathOperations<T> operations, T... values)
           
 
Method Summary
 int getBucketCount()
          Return the number of buckets in this histogram.
 List<Histogram.Bucket> getBuckets()
          Get the buckets in this histogram.
 MathOperations<T> getMathOperations()
           
 int getSignificantFigures()
           
 Histogram.BucketingStrategy getStrategy()
           
 List<String> getTextGraph(int maxBarLength)
          Generate a textual (horizontal) bar graph of this histogram.
 long getTotalNumberOfValues()
          Return the total number of values that have gone into this histogram.
 Histogram<T> setBucketCount(int count)
          Set the number of buckets that this histogram will use.
 Histogram<T> setSignificantFigures(int significantFigures)
          Set the number of significant figures used in the calculation of the bucket widths.
 void setStrategy(double median, double standardDeviation, int sigma)
          Set the histogram to use the standard deviation to determine the bucket sizes.
 void setStrategy(T minimum, T maximum)
          Set the histogram to use the supplied minimum and maximum values to determine the bucket size.
 void setStrategyToDefault()
          Set the histogram to use the actual minimum and maximum values to determine the bucket sizes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUCKET_COUNT

public static final int DEFAULT_BUCKET_COUNT
See Also:
Constant Field Values

DEFAULT_SIGNIFICANT_FIGURES

public static final int DEFAULT_SIGNIFICANT_FIGURES
See Also:
Constant Field Values
Constructor Detail

Histogram

public Histogram(MathOperations<T> operations,
                 List<T> values)

Histogram

public Histogram(MathOperations<T> operations,
                 T... values)
Method Detail

getStrategy

public Histogram.BucketingStrategy getStrategy()

getMathOperations

public MathOperations<T> getMathOperations()
Returns:
math

setStrategy

public void setStrategy(double median,
                        double standardDeviation,
                        int sigma)
Set the histogram to use the standard deviation to determine the bucket sizes.

Parameters:
median -
standardDeviation -
sigma -

setStrategy

public void setStrategy(T minimum,
                        T maximum)
Set the histogram to use the supplied minimum and maximum values to determine the bucket size.

Parameters:
minimum -
maximum -

setStrategyToDefault

public void setStrategyToDefault()
Set the histogram to use the actual minimum and maximum values to determine the bucket sizes.


getSignificantFigures

public int getSignificantFigures()

setSignificantFigures

public Histogram<T> setSignificantFigures(int significantFigures)
Set the number of significant figures used in the calculation of the bucket widths.

Parameters:
significantFigures - the number of significant figures for the bucket widths
Returns:
this histogram, useful for method-chaining
See Also:
DEFAULT_SIGNIFICANT_FIGURES

getBucketCount

public int getBucketCount()
Return the number of buckets in this histogram.

Returns:
the number of buckets.

setBucketCount

public Histogram<T> setBucketCount(int count)
Set the number of buckets that this histogram will use.

Parameters:
count - the number of buckets
Returns:
this histogram, useful for method-chaining
See Also:
DEFAULT_BUCKET_COUNT

getBuckets

public List<Histogram.Bucket> getBuckets()
Get the buckets in this histogram. If the histogram has not yet been computed, this method will cause it to be generated. The resulting list should not be modified.

Returns:
the histogram buckets.

getTotalNumberOfValues

public long getTotalNumberOfValues()
Return the total number of values that have gone into this histogram.

Returns:
the total number of values
See Also:
Histogram.Bucket.getPercentageOfValues()

getTextGraph

public List<String> getTextGraph(int maxBarLength)
Generate a textual (horizontal) bar graph of this histogram.

Parameters:
maxBarLength - the maximum bar length, or 0 if the bar length is to represent actual counts
Returns:
the strings that make up the histogram


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.