Package ubic.basecode.math.distribution
Class Histogram
java.lang.Object
ubic.basecode.math.distribution.Histogram
A simple histogram.
- Author:
- keshav
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
entries()
The number of entries in the histogram (the number of times fill has been called).void
fill
(double x) Fill the histogram with x.void
fill
(int binNum, int count) Add the given number of counts to the given bin.void
fill
(DoubleMatrix1D ghr) getApproximateQuantile
(int q) Find the bin below which i% of the values are contained.double[]
getArray()
Returns the bin heights.int
Double[]
String[]
int
getBinOf
(double x) getName()
The name of the histogram.double
max()
double
min()
int
Get the number of bins in the histogram.double
overflow()
The height of the overflow bin.double
stepSize()
double
The height of the underflow bin.void
writeToFile
(FileWriter out) Write the histogram to a file.
-
Constructor Details
-
Histogram
- Parameters:
name
-nbins
-min
-max
-
-
Histogram
- Parameters:
name
-nbins
-data
-
-
-
Method Details
-
entries
public int entries()The number of entries in the histogram (the number of times fill has been called).- Returns:
- number of entries
-
fill
public void fill(double x) Fill the histogram with x.- Parameters:
x
- is the value to add in to the histogram
-
fill
- Parameters:
ghr
-
-
fill
public void fill(int binNum, int count) Add the given number of counts to the given bin.- Parameters:
binNum
-count
-
-
getApproximateQuantile
Find the bin below which i% of the values are contained. This is only approximate (especially if the number of bins is invalid input: '<'~100)- Parameters:
q
-- Returns:
- approximate quantile. Passing values of 0 and 100 is equivalent to min() and max() respectively.
-
getArray
public double[] getArray()Returns the bin heights.- Returns:
- array of bin heights
-
getBiggestBinSize
public int getBiggestBinSize()- Returns:
- the number of items in the bin that has the most members.
-
getBinEdges
- Returns:
-
getBinEdgesStrings
-
getBinOf
public int getBinOf(double x) - Parameters:
x
-- Returns:
- the index of the bin where x would fall. If x is out of range you get 0 or (nbins - 1).
-
getName
The name of the histogram.- Returns:
- histogram name
-
max
public double max()- Returns:
- maximum x value covered by histogram
-
min
public double min()- Returns:
- minimum x value covered by histogram
-
numberOfBins
public int numberOfBins()Get the number of bins in the histogram. The range of the histogram defined by min and max, and the range is divided into the number of returned.- Returns:
- number of bins
-
overflow
public double overflow()The height of the overflow bin.- Returns:
- number of overflows
-
stepSize
public double stepSize()- Returns:
- size of each bin
-
underflow
public double underflow()The height of the underflow bin.- Returns:
- number of underflows
-
writeToFile
Write the histogram to a file. The format is:bin (lower edge), number in bin.
- Parameters:
out
-- Throws:
IOException
-