我有一些資料,例如 [[0, 1, 2], [0.5, 1.5, 2.5], [0.3, 1.3, 2.3]]。
我正在使用 numpy 和 python,我希望根據索引計算我的資料的平均值和標準差。所以我希望計算 (0, 0.5, 0.3) (例如每個子陣列的索引 0)、(1、1.5、1.3)(例如每個子陣列的索引 1)等的均值/標準差。
有什么建議?(包括我如何存盤結果并將其可視化,可能使用圖形或matplotlib?)
非常感謝,提前。任何可能解決此問題的軟體包的介紹也將非常有幫助。
uj5u.com熱心網友回復:
各種統計函式都帶有一個axis引數,允許您計算列的統計資訊:
import numpy as np
a = np.array([[0, 1, 2], [0.5, 1.5, 2.5], [0.3, 1.3, 2.3]])
np.mean(a, axis=0)
# array([0.26666667, 1.26666667, 2.26666667])
np.std(a, axis=0)
# array([0.20548047, 0.20548047, 0.20548047])
np.var(a, axis=0)
# array([0.04222222, 0.04222222, 0.04222222])
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/405784.html
標籤:
