Class AbstractStaticHistogram
- java.lang.Object
-
- elki.utilities.datastructures.histogram.AbstractStaticHistogram
-
- All Implemented Interfaces:
Histogram
- Direct Known Subclasses:
DoubleHistogram
,ObjHistogram
public abstract class AbstractStaticHistogram extends java.lang.Object implements Histogram
Abstract base class for histograms.Note that this is abstracted from the actual data storage, so it can be adapted for multiple use cases.
- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AbstractStaticHistogram.Iter
Iterator class to iterate over all bins.
-
Field Summary
Fields Modifier and Type Field Description protected double
base
Array 'base', i.e. the point of 0.0.protected double
binsize
Width of a bin.protected double
max
To avoid introducing an extra bucket for the maximum value.protected int
offset
Array shift to account for negative indices.protected int
size
Size of array storage.-
Fields inherited from interface elki.utilities.datastructures.histogram.Histogram
CACHE_SHIFT
-
-
Constructor Summary
Constructors Constructor Description AbstractStaticHistogram(int bins, double min, double max)
Histogram constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
getBinNr(double coord)
Compute the bin number.double
getBinsize()
Get the size (width) of a bin.double
getCoverMaximum()
Get maximum (covered by bins, not data!)double
getCoverMinimum()
Get minimum (covered by bins, not data!)int
getNumBins()
Get the number of bins actually in use.protected static int
growSize(int current, int requiredSize)
Compute the size to grow to.abstract AbstractStaticHistogram.Iter
iter()
Get an iterator over all histogram bins.
-
-
-
Field Detail
-
offset
protected int offset
Array shift to account for negative indices.
-
size
protected int size
Size of array storage.
-
base
protected double base
Array 'base', i.e. the point of 0.0. Usually the minimum.
-
max
protected double max
To avoid introducing an extra bucket for the maximum value.
-
binsize
protected double binsize
Width of a bin.
-
-
Method Detail
-
getBinNr
protected int getBinNr(double coord)
Compute the bin number. Has a special case for rounding max down to the last bin.- Parameters:
coord
- Coordinate- Returns:
- bin number
-
growSize
protected static int growSize(int current, int requiredSize)
Compute the size to grow to.- Parameters:
current
- Current sizerequiredSize
- Required size- Returns:
- Size to allocate
-
getNumBins
public int getNumBins()
Get the number of bins actually in use.- Specified by:
getNumBins
in interfaceHistogram
- Returns:
- number of bins
-
getBinsize
public double getBinsize()
Get the size (width) of a bin.- Specified by:
getBinsize
in interfaceHistogram
- Returns:
- bin size
-
getCoverMinimum
public double getCoverMinimum()
Get minimum (covered by bins, not data!)- Specified by:
getCoverMinimum
in interfaceHistogram
- Returns:
- minimum
-
getCoverMaximum
public double getCoverMaximum()
Get maximum (covered by bins, not data!)- Specified by:
getCoverMaximum
in interfaceHistogram
- Returns:
- maximum
-
iter
public abstract AbstractStaticHistogram.Iter iter()
Get an iterator over all histogram bins.
-
-