Class Binning


  • public class Binning
    extends java.lang.Object
    Static utility methods to convert from a value to a bin, useful for dealing with histograms and LUTs.
    Author:
    Aivar Grislis
    • Constructor Summary

      Constructors 
      Constructor Description
      Binning()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double[] centerValuesPerBin​(int bins, double min, double max)
      Returns array of center values for each bin.
      static double[] edgeValuesPerBin​(int bins, double min, double max)
      Returns array of left edge values for each bin.
      static int exclusiveValueToBin​(int bins, double min, double max, double value)
      Convert value to bin number.
      static int valueToBin​(int bins, double min, double max, double value)
      Convert value to bin number.
      • Methods inherited from class java.lang.Object

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

      • Binning

        public Binning()
    • Method Detail

      • valueToBin

        public static int valueToBin​(int bins,
                                     double min,
                                     double max,
                                     double value)
        Convert value to bin number.

        This variant is inclusive, it assigns all values to the range 0..(bins-1).

        Parameters:
        bins -
        min -
        max -
        value -
        Returns:
        bin number 0...(bins-1)
      • exclusiveValueToBin

        public static int exclusiveValueToBin​(int bins,
                                              double min,
                                              double max,
                                              double value)
        Convert value to bin number.

        This variant is exclusive, not all values map to the range 0...(bins-1).

      • edgeValuesPerBin

        public static double[] edgeValuesPerBin​(int bins,
                                                double min,
                                                double max)
        Returns array of left edge values for each bin.
      • centerValuesPerBin

        public static double[] centerValuesPerBin​(int bins,
                                                  double min,
                                                  double max)
        Returns array of center values for each bin.