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 classAbstractStaticHistogram.IterIterator class to iterate over all bins.
-
Field Summary
Fields Modifier and Type Field Description protected doublebaseArray 'base', i.e. the point of 0.0.protected doublebinsizeWidth of a bin.protected doublemaxTo avoid introducing an extra bucket for the maximum value.protected intoffsetArray shift to account for negative indices.protected intsizeSize 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 intgetBinNr(double coord)Compute the bin number.doublegetBinsize()Get the size (width) of a bin.doublegetCoverMaximum()Get maximum (covered by bins, not data!)doublegetCoverMinimum()Get minimum (covered by bins, not data!)intgetNumBins()Get the number of bins actually in use.protected static intgrowSize(int current, int requiredSize)Compute the size to grow to.abstract AbstractStaticHistogram.Iteriter()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:
getNumBinsin interfaceHistogram- Returns:
- number of bins
-
getBinsize
public double getBinsize()
Get the size (width) of a bin.- Specified by:
getBinsizein interfaceHistogram- Returns:
- bin size
-
getCoverMinimum
public double getCoverMinimum()
Get minimum (covered by bins, not data!)- Specified by:
getCoverMinimumin interfaceHistogram- Returns:
- minimum
-
getCoverMaximum
public double getCoverMaximum()
Get maximum (covered by bins, not data!)- Specified by:
getCoverMaximumin interfaceHistogram- Returns:
- maximum
-
iter
public abstract AbstractStaticHistogram.Iter iter()
Get an iterator over all histogram bins.
-
-