viz.analysis.computeHistogram
function computeHistogram(tensor: Tensor, numBins: number = 50, range?: [number, number]): Promise<HistogramResult>Compute a histogram of tensor values on GPU.
Parameters
tensorTensor- Input tensor (must be on WebGPU)
numBinsnumberoptional- Number of histogram bins (default: 50)
range[number, number]optional- Optional [min, max] range. If not provided, auto-computed.
Returns
Promise<HistogramResult>– Histogram with counts and bin edgesExamples
const hist = await computeHistogram(weights, 30);
console.log('Bin counts:', hist.counts);