What does hist do?
hist(data, nbins) counts the number of observations that fall into equally spaced bins spanning
the data range. When nbins is omitted, MATLAB (and RunMat) default to floor(sqrt(numel(data)))
bins. The resulting frequencies are displayed as a bar chart.
Behaviour highlights
- Inputs must be numeric vectors. Empty inputs return a figure with zero-height bins.
nbinsmay be provided as a numeric scalar or a vector of equally spaced bin centers. Non-positive or non-finite values raise MATLAB-style errors.- A
'BinEdges'name-value pair accepts a strictly increasing vector of edges (uniform or non-uniform). When the edges are evenly spaced the gpuArray path remains zero-copy; other cases fall back to the CPU implementation automatically. - Normalization can be supplied either as the second positional argument or via the
'Normalization'name-value pair. Supported values are"count","probability", and"pdf". - Single-precision gpuArray inputs stay on the device: bin counts are computed by a compute shader and bar vertices are emitted directly into the shared WebGPU context whenever the bins are uniform. Other cases gather automatically (full normalization semantics still apply in either path).
Examples
data = randn(1, 1000);
hist(data, 20);