import numpy as np x = np.average([5, 3, 12]) print(x) # 6.666666666666 y = np.average([5, 3, 12], weights=[2, 1, 0.5]) print(y) # 5.428571428571 # [5 3 12] # [* * * ] / [2 + 1 + 0.5] = 5.428571428571 # [2 1 0.5]