Search
 
SCRIPT & CODE EXAMPLE
 

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]
Comment

PREVIOUS NEXT
Code Example
Python :: create an empty list of lists in python 
Python :: how to change the values of a column in numpy array 
Python :: textclip python arabic 
Python :: python 
Python :: bitcoin wallet python 
Python :: use matplotlib in python 
Python :: python subprocess exception handling 
Python :: download python 2.7 for windows 10 
Python :: python list of dictionary unique 
Python :: run python.py file 
Python :: for loop with enumerate python 
Python :: python tic tac toe 
Python :: aws lambda environment variables python 
Python :: python read json file array 
Python :: how to count how many cameras you have with python 
Python :: index of a string index dataframe 
Python :: how to get dictionary input from user in python 
Python :: seconds to datetime.time 
Python :: round off to two decimal places python 
Python :: how to colour letters in python 
Python :: matplotlib animate 
Python :: python dequeu 
Python :: unique values in dataframe column count 
Python :: python sort the values in a dictionary 
Python :: python docx extract image 
Python :: python time sleep 
Python :: list exclude list 
Python :: how to make exe from.py file 
Python :: seaborn pink green color palette python 
Python :: how to read panda column 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =