# cupy.average¶

cupy.average(a, axis=None, weights=None, returned=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.

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.