Suppose I have the following numpy array:
import numpy as npmy_data = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]])# obtain the lengthn = len(my_data) # 5
I want to do this computation for t=0, 1, 2, 3, 4.
- take the t-th row
- compute dot product of the t-th row and the entire array
- compute sum
- divide by (n-t)
- retun all the results as an array
I.e.
t = 0v0 = my_data[t:,]my_data_dot = np.dot(my_data, v0)my_data_sum = np.sum(my_data_dot)/(n-t)
How can I do this without using looping statements?
Please show me the simplest way.