Search code examples
pythonnumpysquare-rootdeviation

Calculate root mean square deviation (RMSD) with numpy of Python


I transformed the coordinates of two atoms into an array: coord

And I must calculate the root mean squared deviation (RMSD) between the two sets of these coordinates.

For this I have:

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)

But the result does not give me the correct number. I think the error is in the formula. Could someone please help me correct what I have wrong?

The formule for RMSD is:

enter image description here


Solution

  • Solution found:

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