有没有可以调用的方法在 python 中创建随机正交矩阵?可能使用numpy?或者有没有办法使用多个 numpy 方法创建一个正交矩阵?谢谢。
最佳答案
scipy 0.18 版有 scipy.stats.ortho_group
和 scipy.stats.special_ortho_group
.添加它的拉取请求是 https://github.com/scipy/scipy/pull/5622
例如,
In [24]: from scipy.stats import ortho_group # Requires version 0.18 of scipy
In [25]: m = ortho_group.rvs(dim=3)
In [26]: m
Out[26]:
array([[-0.23939017, 0.58743526, -0.77305379],
[ 0.81921268, -0.30515101, -0.48556508],
[-0.52113619, -0.74953498, -0.40818426]])
In [27]: np.set_printoptions(suppress=True)
In [28]: m.dot(m.T)
Out[28]:
array([[ 1., 0., -0.],
[ 0., 1., 0.],
[-0., 0., 1.]])
关于python - 如何在python numpy中创建随机正交矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38426349/