Documentation

experimental.histogram() function

Flux 0.112.0+

The experimental.histogram() function is subject to change at any time. By using this function, you accept the risks of experimental functions.

The experimental.histogram() function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins. A bin is defined by an upper bound where all data points that are less than or equal to the bound are counted in the bin. Bin counts are cumulative.

import "experimental"

experimental.histogram(
  bins: [50.0, 75.0, 90.0],
  normalize: false
)

Output schema

experimental.histogram() outputs a single table for each input table. Each output table represents a unique histogram. Output tables have the same group key as the corresponding input table.

The function does the following:

  • Drops columns that are not part of the group key.
  • Adds an le column to store upper bound values.
  • Stores bin counts in the _value column.

Parameters

bins

(Required) A list of upper bounds to use when computing the histogram frequencies, including the maximum value of the data set. This value can be set to positive infinity if no maximum is known.

Bin helper functions

The following helper functions can be used to generated bins.

linearBins()
logarithmicBins()

normalize

Convert count values into frequency values between 0 and 1. Default is false.

Normalized histograms cannot be aggregated by summing their counts.

tables

Input data. Default is piped-forward data (<-).

Examples

Histogram with dynamically generated bins

import "experimental"

data
  |> experimental.histogram(
    bins: linearBins(start:0.0, width:20.0, count:5)
  )
Input data
_timehost_value
2021-01-01T00:00:00Zhost133.4
2021-01-01T00:01:00Zhost157.2
2021-01-01T00:02:00Zhost178.1
2021-01-01T00:03:00Zhost179.6
_timehost_value
2021-01-01T00:00:00Zhost210.3
2021-01-01T00:01:00Zhost219.8
2021-01-01T00:02:00Zhost254.6
2021-01-01T00:03:00Zhost256.9
Output data
hostle_value
host100
host1200
host1401
host1602
host1804
host1+Inf4
hostle_value
host200
host2202
host2402
host2604
host2804
host2+Inf4

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.