histogramdd#

deepinv.physics.functional.histogramdd(x, bins=10, low=None, upp=None, bounded=False, weights=None, sparse=False, edges=None)[source]#

Computes the multidimensional histogram of a tensor.

This is a torch implementation of numpy.histogramdd. This function is borrowed from torchist.

Note

Similar to numpy.histogram, all bins are half-open except the last bin which also includes the upper bound.

Parameters:
  • x (torch.Tensor) – A tensor, (*, D).

  • bins (int, list[int]) – The number of bins in each dimension, scalar or (D,).

  • low (float, list[float]) – The lower bound in each dimension, scalar or (D,). If low is None, the min of x is used instead.

  • upp (float, list[float]) – The upper bound in each dimension, scalar or (D,). If upp is None, the max of x is used instead.

  • bounded (bool) – Whether x is bounded by low and upp, included. If False, out-of-bounds values are filtered out.

  • weights (torch.Tensor) – A tensor of weights, (\*,). Each sample of x contributes its associated weight towards the bin count (instead of 1).

  • sparse (bool) – Whether the histogram is returned as a sparse tensor or not.

  • edges (torch.Tensor, list[torch.Tensor]) – The edges of the histogram. Either a vector or a list of vectors. If provided, bins, low and upp are inferred from edges.

Returns:

(torch.Tensor) : the histogram

Return type:

Tensor