fn
histogram_op
→vector<TensorImplPtr>int histogram_op(const int & a, int bins, double lo, double hi, bool density)Python wrappers
Public Python APIs implemented by this engine symbol.Compute a 1-D histogram of values in a over uniform bins.
Partitions the half-open interval into bins equal-width
sub-intervals and counts the number of elements of a falling in each
one. When density is true the counts are normalised so that the
histogram integrates to one over the support: counts are divided by
(bin_width * N) where N is the total number of input elements.
Math
\Delta = (hi - lo) / bins$$ **See Also** histogram2d_op : Joint 2-D histogram of paired observations. histogramdd_op : Histogram of (N, D) row-major samples in D dimensions.Parameters
aTensorImplPtrInput tensor of any shape; flattened internally.
binsint64Number of equal-width bins. Must be positive.
lodoubleLeft edge of the lowest bin (inclusive).
hidoubleRight edge of the highest bin (exclusive, except for the last bin which is closed on the right).
densityboolIf true, return a probability density; otherwise return raw counts.
Returns
vector<TensorImplPtr>[counts, edges] where counts has shape (bins,) and edges has shape (bins + 1,). Both have dtype F64.
Notes
Non-differentiable: counts are piecewise-constant in the input. Always executes on the CPU stream; GPU inputs are copied across.