出於好奇+ 1,是有具體numpy的函數來執行以下操作(這將假想更快):平均元件的i和i在numpy的陣列
a = np.array((0,2,4))
b = np.zeros(len(a) - 1)
for i in range(len(b)):
b[i] = a[i:i+2].mean()
print(b)
#prints [1,3]
乾杯
出於好奇+ 1,是有具體numpy的函數來執行以下操作(這將假想更快):平均元件的i和i在numpy的陣列
a = np.array((0,2,4))
b = np.zeros(len(a) - 1)
for i in range(len(b)):
b[i] = a[i:i+2].mean()
print(b)
#prints [1,3]
乾杯
我不這麼認爲... – rubik 2011-05-05 14:14:42