public class Histogram
extends java.lang.Object
If the values v in the array are assumed to be instances of some random variable, then a probability density function may be estimated for that variable by simply dividing the count in each bin by the total number of values in the array. The resulting fractions are called the densities.
The number of bins may be specified or computed automatically. In the automatic case, we compute bin width = 2.0*(v75-v25)/pow(n,1.0/3.0), where n denotes the number of values, and v25 and v75 are the 25th and 75th percentiles, respectively. The number of bins is then computed by dividing the range (vmax-vmin) of values by that bin width, rounding down to the nearest integer. In this way, the number of bins grows as the cube root of the number of values n.
Minimum and maximum values (vmin and vmax) may also be specified or computed automatically. If specified, then only values in the range [vmin,vmax] are binned, and values outside this range are ignored.
Reference: Izenman, A. J., 1991, Recent developments in nonparametric density estimation: Journal of the American Statistical Association, v. 86, p. 205-224.
Constructor and Description |
---|
Histogram(float[] v)
Constructs a histogram for the specified array of values.
|
Histogram(float[] v,
float vmin,
float vmax)
Constructs a histogram for the specified array of values.
|
Histogram(float[] v,
float vmin,
float vmax,
int nbin)
Constructs a histogram for the specified array of values.
|
Histogram(float[] v,
int nbin)
Constructs a histogram for the specified array of values.
|
Modifier and Type | Method and Description |
---|---|
int |
getBinCount()
Gets the number of bins in this histogram.
|
double |
getBinDelta()
Gets the bin width (delta) for this histogram.
|
double |
getBinFirst()
Gets the value of the center of the first bin for this histogram.
|
Sampling |
getBinSampling()
Gets the bin sampling for this histogram.
|
long[] |
getCounts()
Gets the array of counts, one count for each bin.
|
float[] |
getDensities()
Gets the array of densities, one density for each bin.
|
long |
getHighCount()
Gets the number of values greater than vmax.
|
long |
getInCount()
Gets the number of values in the range [vmin,vmax].
|
long |
getLowCount()
Gets the number of values less than vmin.
|
float |
getMaxValue()
Gets the maximum value (vmax) for this histogram.
|
float |
getMinValue()
Gets the minimum value (vmin) for this histogram.
|
public Histogram(float[] v)
v
- the array of values.public Histogram(float[] v, int nbin)
v
- the array of values.nbin
- the number of bins.public Histogram(float[] v, float vmin, float vmax)
v
- the array of values.vmin
- the minimum value.vmax
- the maximum value.public Histogram(float[] v, float vmin, float vmax, int nbin)
v
- the array of values.vmin
- the minimum value.vmax
- the maximum value.nbin
- the number of bins.public float getMinValue()
public float getMaxValue()
public int getBinCount()
public double getBinDelta()
public double getBinFirst()
public Sampling getBinSampling()
public long[] getCounts()
public float[] getDensities()
public long getInCount()
public long getLowCount()
public long getHighCount()