bincount#
- class brainunit.math.bincount(x, weights=None, minlength=0, *, length=None, **kwargs)#
Count number of occurrences of each value in array of non-negative ints.
The number of bins (of size 1) is one larger than the largest value in x. If minlength is specified, there will be at least this number of bins in the output array (though it will be longer if necessary, depending on the contents of x). Each bin gives the number of occurrences of its index value in x. If weights is specified the input array is weighted by it, i.e. if a value
nis found at positioni,out[n] += weight[i]instead ofout[n] += 1.- Parameters:
- Returns:
out – The result of binning the input array. The length of
outis equal tomax(x) + 1.- Return type:
Array
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> u.math.bincount(jnp.array([0, 1, 1, 2, 2, 2])) Array([1, 2, 3], dtype=int32)