cupy.average#

cupy.average(a, axis=None, weights=None, returned=False, *, keepdims=False)[source]#

Returns the weighted average along an axis.

Parameters:
  • a (cupy.ndarray) – Array to compute average.

  • axis (int) – Along which axis to compute average. The flattened array is used by default.

  • weights (cupy.ndarray) – Array of weights where each element corresponds to the value in a. If None, all the values in a have a weight equal to one.

  • returned (bool) – If True, a tuple of the average and the sum of weights is returned, otherwise only the average is returned.

  • keepdims (bool) – If True, the axis is remained as an axis of size one.

Returns:

The average of the input array along the axis and the sum of weights.

Return type:

cupy.ndarray or tuple of cupy.ndarray

Warning

This function may synchronize the device if weight is given.

See also

numpy.average()