# D. Scott # Linear Algebra - Theory, Intuition, Code # Code Challenge 3.3 - compute weighted mean import numpy as np import matplotlib.pyplot as plt v1 = np.array([-6,4,2,8,12]) v2 = np.ones(5) # say we desire to weight the fourth and second values: v2[1] = 1.5 v2[3] = 2 print("New weights: ",v2) print("Vector: ",v1) print("Weighted average of values in vector: ",np.dot(v1,v2)/sum(v2))