Class DoubleDynamicHistogram

  • All Implemented Interfaces:
    Histogram

    public class DoubleDynamicHistogram
    extends DoubleHistogram
    A flexible histogram storing double, that can dynamically adapt the number of bins to the data fed into the histogram.
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected double downsample​(double[] data, int start, int end, int size)
      Perform downsampling on a number of bins.
      double get​(double coord)
      Get the value at a particular position.
      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.
      void increment​(double coord, double value)
      Put fresh data into the histogram (or into the cache)
      DoubleHistogram.Iter iter()
      Get an iterator over all histogram bins.
      (package private) void materialize()
      Materialize the histogram from the cache.
      private void testResample​(double coord)
      Test (and perform) downsampling when neede.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cachec

        private double[] cachec
        Cache for data to be inserted.
      • cachev

        private double[] cachev
        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 destsize * 2 bins are allowed.
    • Constructor Detail

      • DoubleDynamicHistogram

        public DoubleDynamicHistogram​(int bins)
        Constructor.
        Parameters:
        bins - Design number of bins - may become twice as large!
    • Method Detail

      • materialize

        void materialize()
        Materialize the histogram from the cache.
      • get

        public double get​(double coord)
        Description copied from class: DoubleHistogram
        Get the value at a particular position.
        Overrides:
        get in class DoubleHistogram
        Parameters:
        coord - Coordinate
        Returns:
        Value
      • increment

        public void increment​(double coord,
                              double value)
        Put fresh data into the histogram (or into the cache)
        Overrides:
        increment in class DoubleHistogram
        Parameters:
        coord - Coordinate
        value - Value
      • testResample

        private void testResample​(double coord)
        Test (and perform) downsampling when neede.
        Parameters:
        coord - coordinate to accomodate.
      • downsample

        protected double downsample​(double[] data,
                                    int start,
                                    int end,
                                    int size)
        Perform downsampling on a number of bins.
        Parameters:
        data - Data array (needs cast!)
        start - Interval start
        end - Interval end (exclusive)
        size - Intended size - extra bins are assumed to be empty, should be a power of two
        Returns:
        New bin value