Class AbstractObjDynamicHistogram<T>
- java.lang.Object
-
- elki.utilities.datastructures.histogram.AbstractStaticHistogram
-
- elki.utilities.datastructures.histogram.ObjHistogram<T>
-
- elki.utilities.datastructures.histogram.AbstractObjDynamicHistogram<T>
-
- Type Parameters:
T
- Data type
- All Implemented Interfaces:
Histogram
public abstract class AbstractObjDynamicHistogram<T> extends ObjHistogram<T>
A dynamic histogram can dynamically adapt the number of bins to the data fed into the histogram.- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class elki.utilities.datastructures.histogram.ObjHistogram
ObjHistogram.BucketFactory<T>, ObjHistogram.Iter
-
-
Field Summary
Fields Modifier and Type Field Description private int
cachefill
Cache fill sizeprivate double[]
cacheposs
Cache for positions to be inserted.private java.lang.Object[]
cachevals
Cache for data to be inserted.private int
destsize
Destination (minimum) size of the structure.-
Fields inherited from class elki.utilities.datastructures.histogram.ObjHistogram
data, special, supplier
-
Fields inherited from class elki.utilities.datastructures.histogram.AbstractStaticHistogram
base, binsize, max, offset, size
-
Fields inherited from interface elki.utilities.datastructures.histogram.Histogram
CACHE_SHIFT
-
-
Constructor Summary
Constructors Constructor Description AbstractObjDynamicHistogram(int bins)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
aggregate(T first, T second)
Rule to combine two bins or entries into one.protected void
aggregateSpecial(T value, int bin)
Aggregate for a special value.protected abstract T
cloneForCache(T data)
Clone a data passed to the algorithm for computing the initial size.protected abstract T
downsample(java.lang.Object[] data, int start, int end, int size)
Perform downsampling on a number of bins.T
get(double coord)
Access the value of a bin with new data.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.ObjHistogram.Iter
iter()
Get an iterator over all histogram bins.protected abstract T
makeObject()
Make a new empty bucket for the data store.(package private) void
materialize()
Materialize the histogram from the cache.void
putData(double coord, T value)
Put fresh data into the histogram (or into the cache).private void
testResample(double coord)
Test (and perform) downsampling when needed.-
Methods inherited from class elki.utilities.datastructures.histogram.ObjHistogram
getSpecial
-
Methods inherited from class elki.utilities.datastructures.histogram.AbstractStaticHistogram
getBinNr, growSize
-
-
-
-
Field Detail
-
cacheposs
private double[] cacheposs
Cache for positions to be inserted.
-
cachevals
private java.lang.Object[] cachevals
Cache for data to be inserted.
-
cachefill
private int cachefill
Cache fill size
-
destsize
private int destsize
Destination (minimum) size of the structure. At most 2*destsize bins are allowed.
-
-
Method Detail
-
materialize
void materialize()
Materialize the histogram from the cache.
-
get
public T get(double coord)
Description copied from class:ObjHistogram
Access the value of a bin with new data.- Overrides:
get
in classObjHistogram<T>
- Parameters:
coord
- Coordinate- Returns:
- bin contents
-
putData
public void putData(double coord, T value)
Put fresh data into the histogram (or into the cache).- Parameters:
coord
- Coordinatevalue
- Value
-
aggregateSpecial
protected void aggregateSpecial(T value, int bin)
Aggregate for a special value.- Parameters:
value
- Parameter valuebin
- Special bin index.
-
testResample
private void testResample(double coord)
Test (and perform) downsampling when needed.- Parameters:
coord
- coordinate to accommodate.
-
iter
public ObjHistogram.Iter iter()
Description copied from class:AbstractStaticHistogram
Get an iterator over all histogram bins.- Specified by:
iter
in interfaceHistogram
- Overrides:
iter
in classObjHistogram<T>
- Returns:
- Iterator
-
getNumBins
public int getNumBins()
Description copied from class:AbstractStaticHistogram
Get the number of bins actually in use.- Specified by:
getNumBins
in interfaceHistogram
- Overrides:
getNumBins
in classAbstractStaticHistogram
- Returns:
- number of bins
-
getBinsize
public double getBinsize()
Description copied from class:AbstractStaticHistogram
Get the size (width) of a bin.- Specified by:
getBinsize
in interfaceHistogram
- Overrides:
getBinsize
in classAbstractStaticHistogram
- Returns:
- bin size
-
getCoverMinimum
public double getCoverMinimum()
Description copied from class:AbstractStaticHistogram
Get minimum (covered by bins, not data!)- Specified by:
getCoverMinimum
in interfaceHistogram
- Overrides:
getCoverMinimum
in classAbstractStaticHistogram
- Returns:
- minimum
-
getCoverMaximum
public double getCoverMaximum()
Description copied from class:AbstractStaticHistogram
Get maximum (covered by bins, not data!)- Specified by:
getCoverMaximum
in interfaceHistogram
- Overrides:
getCoverMaximum
in classAbstractStaticHistogram
- Returns:
- maximum
-
downsample
protected abstract T downsample(java.lang.Object[] data, int start, int end, int size)
Perform downsampling on a number of bins.- Parameters:
data
- Data array (needs cast!)start
- Interval startend
- Interval end (exclusive)size
- Intended size - extra bins are assumed to be empty, should be a power of two- Returns:
- New bin value
-
aggregate
protected abstract T aggregate(T first, T second)
Rule to combine two bins or entries into one.Note: first and second MAY be modified and returned, they will not be used afterwards.
- Parameters:
first
- First bin valuesecond
- Second bin value- Returns:
- combined bin value
-
cloneForCache
protected abstract T cloneForCache(T data)
Clone a data passed to the algorithm for computing the initial size.- Parameters:
data
- Data to be cloned- Returns:
- cloned data
-
makeObject
protected abstract T makeObject()
Make a new empty bucket for the data store.- Returns:
- New instance.
-
-