fn

histc

Tensor
histc(input: Tensor, bins: int = ..., min: float = ..., max: float = ...)
source

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

Bins span [min, max] inclusive of the upper edge; values outside the range are silently discarded. If min == max == 0 (the default), the range is computed from the data.

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 int64 tensor of length bins containing counts.

Notes

Bin width is (maxmin)/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])