Skip to content
fn

histc

→Tensor
histc(input: Tensor, bins: _int = ..., min: _float = ..., max: _float = ...)

Implementing kernel

C++ engine symbols that back this Python API.

Compute a histogram of input with bins equally-spaced bins.

Bins span [min, max] inclusive of the upper edge; values outside the range, and NaN, are discarded. If min == max (both 0 by default), the range is the data's; a range that is still one point v widens to [v - 1, v + 1].

Parameters

inputTensor
Source tensor (floating-point).
binsint= 100
Number of bins.
minfloat= 0
Lower edge.
maxfloat= 0
Upper edge. min == max == 0 means "use data range".

Returns

Tensor

1-D tensor of length bins containing counts, in input's dtype.

Raises

ValueError
min > max, or the range is not finite.

Notes

Bin width is (max−min)/bins(max - min) / \text{bins}. Right edge is inclusive of the final bin only.

Examples

>>> import lucid
>>> x = lucid.tensor([0.1, 0.5, 0.9, 1.1])
>>> lucid.histc(x, bins=4, min=0, max=1)
Tensor([1, 1, 0, 1])