de.lmu.ifi.dbs.elki.math
Class FlexiHistogram<T,D>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.math.ReplacingHistogram<T>
      extended by de.lmu.ifi.dbs.elki.math.AggregatingHistogram<T,D>
          extended by de.lmu.ifi.dbs.elki.math.FlexiHistogram<T,D>
Type Parameters:
T - Type of data in histogram
D - Type of input data
All Implemented Interfaces:
Iterable<Pair<Double,T>>

public class FlexiHistogram<T,D>
extends AggregatingHistogram<T,D>

Histogram with flexible size, guaranteed to be in [bin, 2*bin[


Nested Class Summary
static class FlexiHistogram.Adapter<T,D>
          Adapter interface to specify bin creation, data caching and combination.
 
Nested classes/interfaces inherited from class de.lmu.ifi.dbs.elki.math.ReplacingHistogram
ReplacingHistogram.Iter, ReplacingHistogram.RIter
 
Field Summary
private  int destsize
          Destination (minimum) size of the structure.
private  FlexiHistogram.Adapter<T,D> downsampler
          Adapter class, extended "maker".
private  ArrayList<Pair<Double,D>> tempcache
          Cache for elements when not yet initialized.
 
Fields inherited from class de.lmu.ifi.dbs.elki.math.ReplacingHistogram
base, binsize, data, max, offset, size
 
Constructor Summary
FlexiHistogram(int bins, FlexiHistogram.Adapter<T,D> adapter)
          Create a new histogram for an unknown data range.
 
Method Summary
 void aggregate(double coord, D value)
          Add a value to the histogram using the aggregation adapter.
static FlexiHistogram<Pair<Double,Double>,Pair<Double,Double>> DoubleSumDoubleSumHistogram(int bins)
          Histograms that work like two DoubleSumHistogram(int), component wise.
static FlexiHistogram<Double,Double> DoubleSumHistogram(int bins)
          Convenience constructor for Double-based Histograms.
 T get(double coord)
          Get the data at a given Coordinate.
 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!)
 ArrayList<T> getData()
          Get the raw data.
 int getNumBins()
          Get the number of bins actually in use.
static FlexiHistogram<Integer,Integer> IntSumHistogram(int bins)
          Convenience constructor for Integer-based Histograms.
static FlexiHistogram<Pair<Integer,Integer>,Pair<Integer,Integer>> IntSumIntSumHistogram(int bins)
          Histograms that work like two IntSumHistogram(int), component wise.
 Iterator<Pair<Double,T>> iterator()
          Get an iterator over all histogram bins.
static FlexiHistogram<Long,Long> LongSumHistogram(int bins)
          Convenience constructor for Long-based Histograms.
static FlexiHistogram<Pair<Long,Long>,Pair<Long,Long>> LongSumLongSumHistogram(int bins)
          Histograms that work like two LongSumHistogram(int), component wise.
private  void materialize()
           
static FlexiHistogram<MeanVariance,Double> MeanVarianceHistogram(int bins)
          Convenience constructor for MeanVariance-based Histograms.
 void replace(double coord, T d)
          Put data at a given coordinate.
 Iterator<Pair<Double,T>> reverseIterator()
          Get an iterator over all histogram bins.
private  void testResample()
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.math.AggregatingHistogram
DoubleSumDoubleSumHistogram, DoubleSumHistogram, IntSumHistogram, IntSumIntSumHistogram, LongSumHistogram, LongSumLongSumHistogram, MeanVarianceHistogram
 
Methods inherited from class de.lmu.ifi.dbs.elki.math.ReplacingHistogram
DoubleDoubleHistogram, DoubleHistogram, getBinNr, IntHistogram, IntIntHistogram, make
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

downsampler

private FlexiHistogram.Adapter<T,D> downsampler
Adapter class, extended "maker".


tempcache

private ArrayList<Pair<Double,D>> tempcache
Cache for elements when not yet initialized.


destsize

private int destsize
Destination (minimum) size of the structure. At most 2*destsize bins are allowed.

Constructor Detail

FlexiHistogram

public FlexiHistogram(int bins,
                      FlexiHistogram.Adapter<T,D> adapter)
Create a new histogram for an unknown data range. The generated histogram is guaranteed to have within bins and 2*bins bins in length.

Parameters:
bins - Target number of bins
adapter - Adapter for data types and combination rules.
Method Detail

materialize

private void materialize()

replace

public void replace(double coord,
                    T d)
Description copied from class: ReplacingHistogram
Put data at a given coordinate. Note: this replaces the contents, it doesn't "add" or "count".

Overrides:
replace in class ReplacingHistogram<T>
Parameters:
coord - Coordinate
d - New Data

testResample

private void testResample()

get

public T get(double coord)
Description copied from class: ReplacingHistogram
Get the data at a given Coordinate.

Overrides:
get in class ReplacingHistogram<T>
Parameters:
coord - Coordinate.
Returns:
data element there (which may be a new empty bin or null)

getBinsize

public double getBinsize()
Description copied from class: ReplacingHistogram
Get the size (width) of a bin.

Overrides:
getBinsize in class ReplacingHistogram<T>
Returns:
bin size

getCoverMaximum

public double getCoverMaximum()
Description copied from class: ReplacingHistogram
Get maximum (covered by bins, not data!)

Overrides:
getCoverMaximum in class ReplacingHistogram<T>
Returns:
maximum

getCoverMinimum

public double getCoverMinimum()
Description copied from class: ReplacingHistogram
Get minimum (covered by bins, not data!)

Overrides:
getCoverMinimum in class ReplacingHistogram<T>
Returns:
minimum

getData

public ArrayList<T> getData()
Description copied from class: ReplacingHistogram
Get the raw data. Note that this does NOT include the coordinates.

Overrides:
getData in class ReplacingHistogram<T>
Returns:
raw data array.

getNumBins

public int getNumBins()
Description copied from class: ReplacingHistogram
Get the number of bins actually in use.

Overrides:
getNumBins in class ReplacingHistogram<T>
Returns:
number of bins

iterator

public Iterator<Pair<Double,T>> iterator()
Description copied from class: ReplacingHistogram
Get an iterator over all histogram bins.

Specified by:
iterator in interface Iterable<Pair<Double,T>>
Overrides:
iterator in class ReplacingHistogram<T>

reverseIterator

public Iterator<Pair<Double,T>> reverseIterator()
Description copied from class: ReplacingHistogram
Get an iterator over all histogram bins.

Overrides:
reverseIterator in class ReplacingHistogram<T>

aggregate

public void aggregate(double coord,
                      D value)
Description copied from class: AggregatingHistogram
Add a value to the histogram using the aggregation adapter.

Overrides:
aggregate in class AggregatingHistogram<T,D>
Parameters:
coord - Coordinate
value - New value

IntSumHistogram

public static FlexiHistogram<Integer,Integer> IntSumHistogram(int bins)
Convenience constructor for Integer-based Histograms. Uses a constructor to initialize bins with Integer(0)

Parameters:
bins - Number of bins
Returns:
New histogram for Integer.

LongSumHistogram

public static FlexiHistogram<Long,Long> LongSumHistogram(int bins)
Convenience constructor for Long-based Histograms. Uses a constructor to initialize bins with Long(0)

Parameters:
bins - Number of bins
Returns:
New histogram for Long.

DoubleSumHistogram

public static FlexiHistogram<Double,Double> DoubleSumHistogram(int bins)
Convenience constructor for Double-based Histograms. Uses a constructor to initialize bins with Double(0), and downsampling is done by summation.

Parameters:
bins - Number of bins
Returns:
New histogram for Doubles.

MeanVarianceHistogram

public static FlexiHistogram<MeanVariance,Double> MeanVarianceHistogram(int bins)
Convenience constructor for MeanVariance-based Histograms. Uses a constructor to initialize bins with new MeanVariance objects

Parameters:
bins - Number of bins
Returns:
New histogram for MeanVariance.

IntSumIntSumHistogram

public static FlexiHistogram<Pair<Integer,Integer>,Pair<Integer,Integer>> IntSumIntSumHistogram(int bins)
Histograms that work like two IntSumHistogram(int), component wise.

Parameters:
bins - Number of bins.
Returns:
New Histogram object

LongSumLongSumHistogram

public static FlexiHistogram<Pair<Long,Long>,Pair<Long,Long>> LongSumLongSumHistogram(int bins)
Histograms that work like two LongSumHistogram(int), component wise.

Parameters:
bins - Number of bins.
Returns:
New Histogram object

DoubleSumDoubleSumHistogram

public static FlexiHistogram<Pair<Double,Double>,Pair<Double,Double>> DoubleSumDoubleSumHistogram(int bins)
Histograms that work like two DoubleSumHistogram(int), component wise.

Parameters:
bins - Number of bins.
Returns:
New Histogram object

Release 0.4.0 (2011-09-20_1324)