MCPcopy Create free account
hub / github.com/dask/dask / histogram

Function histogram

dask/array/routines.py:863–1069  ·  view source on GitHub ↗

Blocked variant of :func:`numpy.histogram`. Parameters ---------- a : dask.array.Array Input data; the histogram is computed over the flattened array. If the ``weights`` argument is used, the chunks of ``a`` are accessed to check chunking compatibility betwe

(a, bins=None, range=None, normed=False, weights=None, density=None)

Source from the content-addressed store, hash-verified

861
862
863def histogram(a, bins=None, range=None, normed=False, weights=None, density=None):
864 """
865 Blocked variant of :func:`numpy.histogram`.
866
867 Parameters
868 ----------
869 a : dask.array.Array
870 Input data; the histogram is computed over the flattened
871 array. If the ``weights`` argument is used, the chunks of
872 ``a`` are accessed to check chunking compatibility between
873 ``a`` and ``weights``. If ``weights`` is ``None``, a
874 :py:class:`dask.dataframe.Series` object can be passed as
875 input data.
876 bins : int or sequence of scalars, optional
877 Either an iterable specifying the ``bins`` or the number of ``bins``
878 and a ``range`` argument is required as computing ``min`` and ``max``
879 over blocked arrays is an expensive operation that must be performed
880 explicitly.
881 If `bins` is an int, it defines the number of equal-width
882 bins in the given range (10, by default). If `bins` is a
883 sequence, it defines a monotonically increasing array of bin edges,
884 including the rightmost edge, allowing for non-uniform bin widths.
885 range : (float, float), optional
886 The lower and upper range of the bins. If not provided, range
887 is simply ``(a.min(), a.max())``. Values outside the range are
888 ignored. The first element of the range must be less than or
889 equal to the second. `range` affects the automatic bin
890 computation as well. While bin width is computed to be optimal
891 based on the actual data within `range`, the bin count will fill
892 the entire range including portions containing no data.
893 normed : bool, optional
894 This is equivalent to the ``density`` argument, but produces incorrect
895 results for unequal bin widths. It should not be used.
896 weights : dask.array.Array, optional
897 A dask.array.Array of weights, of the same block structure as ``a``. Each value in
898 ``a`` only contributes its associated weight towards the bin count
899 (instead of 1). If ``density`` is True, the weights are
900 normalized, so that the integral of the density over the range
901 remains 1.
902 density : bool, optional
903 If ``False``, the result will contain the number of samples in
904 each bin. If ``True``, the result is the value of the
905 probability *density* function at the bin, normalized such that
906 the *integral* over the range is 1. Note that the sum of the
907 histogram values will not be equal to 1 unless bins of unity
908 width are chosen; it is not a probability *mass* function.
909 Overrides the ``normed`` keyword if given.
910 If ``density`` is True, ``bins`` cannot be a single-number delayed
911 value. It must be a concrete number, or a (possibly-delayed)
912 array/sequence of the bin edges.
913
914 Returns
915 -------
916 hist : dask Array
917 The values of the histogram. See `density` and `weights` for a
918 description of the possible semantics.
919 bin_edges : dask Array of dtype float
920 Return the bin edges ``(length(hist)+1)``.

Callers

nothing calls this directly

Calls 14

sumMethod · 0.95
is_dask_collectionFunction · 0.90
unpack_collectionsFunction · 0.90
TaskClass · 0.90
ArrayClass · 0.90
asarrayFunction · 0.90
TaskRefClass · 0.90
flattenFunction · 0.90
from_collectionsMethod · 0.80
diffMethod · 0.80
tokenizeFunction · 0.50
ndimMethod · 0.45

Tested by

no test coverage detected