Generating histograms

Kontrast provides a function that generates histograms from arrays of numbers.

Interactive code example


The function is called as kontrast.generateHistogram(options), where options is an object with the following properties:

  • lowerLimit: number
    The lower limit of the smallest bin.
  • upperLimit: number
    The upper limit of the largest bin.
  • values: numberArray
    A numeric array of the values to be collected in the histogram.
  • binCount: number
    The number of bins.


  • binCenter: Float64Array
    The center position of each bin.
  • binLower: Float64Array
    The lower position of each bin.
  • binUpper: Float64Array
    The upper position of each bin.
  • binEdge: Float64Array
    The edge positions of the bins.
  • counts: Float64Array
    The number of counts of each bin.
  • density: Float64Array
    The (normalized) density of each bin.
  • insideCount: number
    The number of data points that are within the range (i.e., between lowerLimit and upperLimit).
  • outsideCount: number
    The number of data points that are outside the histogram range.
  • nonfiniteCount: number
    The number of non-finite data points.