Skip to main content

Statistics

Functions for computing histograms, correlation, convolution, covariance, and numerical integration.

histogram

Compute the histogram of a dataset.
Returns: A tuple [counts, bin_edges] where counts has shape [nbins] and bin_edges has shape [nbins + 1].

histogram2d

Compute the bi-dimensional histogram of two data samples.
Returns: A tuple [H, xedges, yedges] where H has shape [nx, ny].

histogramdd

Compute the multidimensional histogram of some data.
Returns: A tuple [H, edges] where H is the D-dimensional count array and edges is an array of D edge arrays.

histogram_bin_edges

Compute the bin edges for a histogram without computing the histogram itself. Useful for sharing bin edges across multiple histograms.
Returns: NDArray of bin edges with length nbins + 1.

bincount

Count occurrences of each value in an array of non-negative integers.
Returns: NDArray of length max(x) + 1 (or minlength, whichever is larger).

digitize

Return the indices of the bins to which each value belongs.
Returns: NDArray of bin indices. An index i means bins[i-1] <= x < bins[i] (when right=false).

correlate

Cross-correlation of two 1-dimensional sequences.
Returns: NDArray containing the cross-correlation result.

convolve

Discrete, linear convolution of two 1-dimensional sequences.
Returns: NDArray containing the convolution result.

cov

Estimate a covariance matrix.
Returns: NDArray — the covariance matrix.

corrcoef

Return Pearson correlation coefficients.
Returns: NDArray — the correlation coefficient matrix, with values in [-1, 1].

trapezoid

Integrate along the given axis using the composite trapezoidal rule.
Returns: number when integrating a 1-D array, NDArray when integrating along an axis of a multi-dimensional array.