用Python的numpy计算均方根偏差(RMSD)

问题描述 投票:0回答:3

我将两个原子的坐标转化为一个数组:coord

我必须计算这两组坐标之间的均方根偏差(RMSD)。

为此我有:

def cal_rmsd_numpy(coord_1, coord_2):
    rmsd = np.sqrt(((coord_1 - coord_2) ** 2).mean())    ## this would be the formula
    return rmsd

rmsd = cal_rmsd_numpy(coord_1, coord_2)

print(rmsd)

但是结果没有给我正确的数字。 我认为错误出在公式中。有人可以帮我纠正我的错误吗?

RMSD 的公式为:

enter image description here

python numpy square-root deviation
3个回答
1
投票

找到解决方案:

rmsd = np.sqrt(((((coordenadas_1 - coordenadas_2)** 2))*3).mean())

0
投票

你必须先将坐标的减法相加:

rmsd = np.sqrt((((coordenadas_1 - coordenadas_2)**2).sum()).mean())

或者更直观地看一下公式:

rmsd = np.sqrt((((coordenadas_1 - coordenadas_2)**2).sum())/len(coordenadas_1))


0
投票
np.sqrt(((a - b)**2).sum(-1).mean())
© www.soinside.com 2019 - 2024. All rights reserved.