Procrustes Analysis with NumPy?

前端 未结 2 1628
情歌与酒
情歌与酒 2020-12-02 21:51

Is there something like Matlab\'s procrustes function in NumPy/SciPy or related libraries?


For reference. Procrustes analysis aims to align 2 sets of points (

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 22:26

    There is a Scipy function for it: scipy.spatial.procrustes

    I'm just posting its example here:

    >>> import numpy as np
    >>> from scipy.spatial import procrustes
    
    >>> a = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd')
    >>> b = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd')
    >>> mtx1, mtx2, disparity = procrustes(a, b)
    >>> round(disparity)
    0.0
    

提交回复
热议问题