Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy weighted average

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]
 
PREVIOUS NEXT
Tagged: #numpy #weighted #average
ADD COMMENT
Topic
Name
4+2 =