silx.math module

silx.math.histogramnd(sample, weights, bins_rng, n_bins, weight_min=None, weight_max=None, last_bin_closed=False, histo=None, cumul=None)

Computes the multidimensional histogram of some data.

Parameters:
  • sample (numpy.array) – The data to be histogrammed. Its shape must be either (N,) if it contains one dimensional coordinates, or an (N,D) array where the rows are the coordinates of points in a D dimensional space. The following dtypes are supported : numpy.float64, numpy.float32, numpy.int32.
  • bins_rng (array_like) – A (N, 2) array containing the lower and upper bin edges along each dimension.
  • n_bins (scalar or array_like) –
    The number of bins :
    • a scalar (same number of bins for all dimensions)
    • a D elements array (number of bins for each dimensions)
  • weights (optional, numpy.array) –

    A N elements numpy array of values associated with each sample. The values of the cumul array returned by the function are equal to the sum of the weights associated with the samples falling into each bin. The following dtypes are supported : numpy.float64, numpy.float32, numpy.int32.

    Note

    If None, the weighted histogram returned will be None.

  • weight_min (optional, scalar) –

    Use this parameter to filter out all samples whose weights are lower than this value.

    Note

    This value will be cast to the same type as weights.

  • weight_max (optional, scalar) –

    Use this parameter to filter out all samples whose weights are higher than this value.

    Note

    This value will be cast to the same type as weights.

  • last_bin_closed (optional, python.boolean) – By default the last bin is half open (i.e.: [x,y) ; x included, y excluded), like all the other bins. Set this parameter to true if you want the LAST bin to be closed.
  • histo (optional, numpy.array) –

    Use this parameter if you want to pass your own histogram array instead of the one created by this function. New values will be added to this array. The returned array will then be this one (same reference).

    Warning

    If the histo array was created by a previous call to histogramnd then the user is responsible for providing the same parameters (n_bins, bins_rng, ...).

  • cumul (optional, numpy.array) –

    Use this parameter if you want to pass your own weighted histogram array instead of the created by this function. New values will be added to this array. The returned array will then be this one (same reference).

    Warning

    If the cumul array was created by a previous call to histogramnd then the user is responsible for providing the same parameters (n_bins, bins_rng, ...).

Returns:

Histogram (bin counts, always returned) and weighted histogram of the sample (or None if weights is None).

Return type:

tuple (numpy.array, numpy.array) or (numpy.array, None)

Previous topic

silx.io.specfile module

This Page