histogram() function
The 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.
The bin counts are cumulative.
Each input table is converted into a single output table representing a single histogram. The output table has the same group key as the input table. Columns not part of the group key are removed and an upper bound column and a count column are added.
histogram(
column: "_value",
upperBoundColumn: "le",
countColumn: "_value",
bins: [50.0, 75.0, 90.0],
normalize: false,
)
Parameters
column
The name of a column containing input data values.
The column type must be float.
Default is "_value"
.
upperBoundColumn
The name of the column in which to store the histogram’s upper bounds.
Default is "le"
.
countColumn
The name of the column in which to store the histogram counts.
Default is "_value"
.
bins
(Required) A list of upper bounds to use when computing the histogram frequencies. Bins should contain a bin whose bound is 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
When true
, will convert the counts 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
The following examples use data provided by the sampledata
package
to show how histogram()
transforms data.
Create a cumulative histogram
import "sampledata"
sampledata.float()
|> histogram(bins: [0.0, 5.0, 10.0, 20.0])
Create a cumulative histogram with dynamically generated bins
import "sampledata"
sampledata.float()
|> histogram(bins: linearBins(start: 0.0, width: 4.0, count: 3))
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.