Class 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
      class  AbstractStaticHistogram.Iter
      Iterator class to iterate over all bins.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double base
      Array 'base', i.e. the point of 0.0.
      protected double binsize
      Width of a bin.
      protected double max
      To avoid introducing an extra bucket for the maximum value.
      protected int offset
      Array shift to account for negative indices.
      protected int size
      Size of array storage.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractStaticHistogram​(int bins, double min, double max)
      Histogram constructor
    • 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.
    • Constructor Detail

      • AbstractStaticHistogram

        public AbstractStaticHistogram​(int bins,
                                       double min,
                                       double max)
        Histogram constructor
        Parameters:
        bins - Number of bins to use.
        min - Minimum Value
        max - Maximum Value
    • 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 size
        requiredSize - Required size
        Returns:
        Size to allocate
      • getNumBins

        public int getNumBins()
        Get the number of bins actually in use.
        Specified by:
        getNumBins in interface Histogram
        Returns:
        number of bins
      • getBinsize

        public double getBinsize()
        Get the size (width) of a bin.
        Specified by:
        getBinsize in interface Histogram
        Returns:
        bin size
      • getCoverMinimum

        public double getCoverMinimum()
        Get minimum (covered by bins, not data!)
        Specified by:
        getCoverMinimum in interface Histogram
        Returns:
        minimum
      • getCoverMaximum

        public double getCoverMaximum()
        Get maximum (covered by bins, not data!)
        Specified by:
        getCoverMaximum in interface Histogram
        Returns:
        maximum