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 intcachefillCache fill sizeprivate double[]cachepossCache for positions to be inserted.private java.lang.Object[]cachevalsCache for data to be inserted.private intdestsizeDestination (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 Taggregate(T first, T second)Rule to combine two bins or entries into one.protected voidaggregateSpecial(T value, int bin)Aggregate for a special value.protected abstract TcloneForCache(T data)Clone a data passed to the algorithm for computing the initial size.protected abstract Tdownsample(java.lang.Object[] data, int start, int end, int size)Perform downsampling on a number of bins.Tget(double coord)Access the value of a bin with new data.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.ObjHistogram.Iteriter()Get an iterator over all histogram bins.protected abstract TmakeObject()Make a new empty bucket for the data store.(package private) voidmaterialize()Materialize the histogram from the cache.voidputData(double coord, T value)Put fresh data into the histogram (or into the cache).private voidtestResample(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:ObjHistogramAccess the value of a bin with new data.- Overrides:
getin 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:AbstractStaticHistogramGet an iterator over all histogram bins.- Specified by:
iterin interfaceHistogram- Overrides:
iterin classObjHistogram<T>- Returns:
- Iterator
-
getNumBins
public int getNumBins()
Description copied from class:AbstractStaticHistogramGet the number of bins actually in use.- Specified by:
getNumBinsin interfaceHistogram- Overrides:
getNumBinsin classAbstractStaticHistogram- Returns:
- number of bins
-
getBinsize
public double getBinsize()
Description copied from class:AbstractStaticHistogramGet the size (width) of a bin.- Specified by:
getBinsizein interfaceHistogram- Overrides:
getBinsizein classAbstractStaticHistogram- Returns:
- bin size
-
getCoverMinimum
public double getCoverMinimum()
Description copied from class:AbstractStaticHistogramGet minimum (covered by bins, not data!)- Specified by:
getCoverMinimumin interfaceHistogram- Overrides:
getCoverMinimumin classAbstractStaticHistogram- Returns:
- minimum
-
getCoverMaximum
public double getCoverMaximum()
Description copied from class:AbstractStaticHistogramGet maximum (covered by bins, not data!)- Specified by:
getCoverMaximumin interfaceHistogram- Overrides:
getCoverMaximumin 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.
-
-