Class BinMapper


  • @Equality
    public abstract class BinMapper
    extends java.lang.Object
    Maps axis values to bin indices.
    Since:
    16 Jan 2017
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      BinMapper()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static BinMapper createMapper​(boolean log, double binWidth, double binPhase, double point)
      Returns a BinMapper instance.
      abstract int getBinIndex​(double value)
      Returns the bin index for a given value.
      abstract double[] getBinLimits​(int index)
      Returns the bin limits for a given bin index.
      static double log​(double val)
      Logarithm function, used for transforming values on logarithmic X axis.
      • Methods inherited from class java.lang.Object

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

      • BinMapper

        public BinMapper()
    • Method Detail

      • getBinIndex

        public abstract int getBinIndex​(double value)
        Returns the bin index for a given value. In case of an invalid value (NaN, or non-positive for log mapper), behaviour is undefined (quite likely zero will be returned).
        Parameters:
        value - valid axis value
        Returns:
        bin index
      • getBinLimits

        public abstract double[] getBinLimits​(int index)
        Returns the bin limits for a given bin index.
        Parameters:
        index - bin index
        Returns:
        (lower,upper) bin limits
      • createMapper

        public static BinMapper createMapper​(boolean log,
                                             double binWidth,
                                             double binPhase,
                                             double point)
        Returns a BinMapper instance.

        Notional bin boundaries are for log=false:

           binWidth*(0+binPhase), binWidth*(1+binPhase), ...
         
        and for log=true:
           binWidth**(0+binPhase), binWidth**(1+binPhase), ...
         

        The point parameter is used internally to determine the zero point of the bins. In principle this should make no difference to behaviour, but in case that the data is situated a very long way from 1, setting it close to the actual data point locations may avoid rounding errors.

        Parameters:
        log - false for linear axis scaling, true for logarithmic
        binWidth - width of each bin; this is additive for linear and multiplicative for logarithmic scaling
        binPhase - determines sub-bin boundary shifts along axis, normally in range 0..1
        point - representative point on axis near which bins are situated
      • log

        public static double log​(double val)
        Logarithm function, used for transforming values on logarithmic X axis.
        Parameters:
        val - value
        Returns:
        log to base 10 of val