在 python 中计算 2D rms
calculating 2D rms in python
我有一个 Nx2 数组,用于存储 N 个不同点的 x,y 坐标。我必须计算数据的传播(我正在考虑均方根)。 scipy 中是否有任何函数可以完成这项工作?如果不是,最有效的计算方法是什么?
The root mean square is the standard deviation:
In [100]: np.random.seed(2015)
In [101]: A = np.random.random((10,2))
In [102]: A
Out[102]:
array([[ 0.73759523, 0.51757155],
[ 0.88418945, 0.45172399],
[ 0.94467608, 0.82238998],
[ 0.06360332, 0.93889193],
[ 0.33245351, 0.62721741],
[ 0.00321837, 0.70402271],
[ 0.07105811, 0.05554161],
[ 0.28901979, 0.28649662],
[ 0.2688956 , 0.20721542],
[ 0.25877509, 0.63308562]])
In [147]: np.std(A - A.mean(axis=0))
Out[147]: 0.29777164364514941
相当于:
In [146]: np.sqrt(((A - A.mean(axis=0))**2).mean())
Out[146]: 0.29777164364514941
我有一个 Nx2 数组,用于存储 N 个不同点的 x,y 坐标。我必须计算数据的传播(我正在考虑均方根)。 scipy 中是否有任何函数可以完成这项工作?如果不是,最有效的计算方法是什么?
The root mean square is the standard deviation:
In [100]: np.random.seed(2015)
In [101]: A = np.random.random((10,2))
In [102]: A
Out[102]:
array([[ 0.73759523, 0.51757155],
[ 0.88418945, 0.45172399],
[ 0.94467608, 0.82238998],
[ 0.06360332, 0.93889193],
[ 0.33245351, 0.62721741],
[ 0.00321837, 0.70402271],
[ 0.07105811, 0.05554161],
[ 0.28901979, 0.28649662],
[ 0.2688956 , 0.20721542],
[ 0.25877509, 0.63308562]])
In [147]: np.std(A - A.mean(axis=0))
Out[147]: 0.29777164364514941
相当于:
In [146]: np.sqrt(((A - A.mean(axis=0))**2).mean())
Out[146]: 0.29777164364514941