有没有一种方法可以调用来在 python 中创建随机正交矩阵?可能使用 numpy?或者有没有办法使用多种 numpy 方法创建正交矩阵?谢谢。
原文由 Dacion 发布,翻译遵循 CC BY-SA 4.0 许可协议
有没有一种方法可以调用来在 python 中创建随机正交矩阵?可能使用 numpy?或者有没有办法使用多种 numpy 方法创建正交矩阵?谢谢。
原文由 Dacion 发布,翻译遵循 CC BY-SA 4.0 许可协议
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.]])
原文由 Warren Weckesser 发布,翻译遵循 CC BY-SA 3.0 许可协议
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答2.5k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
这是从 https://github.com/scipy/scipy/pull/5622/files 中提取的
rvs
方法,变化很小 - 足以作为独立的 numpy 函数运行。它符合 Warren 的测试, https://stackoverflow.com/a/38426572/901925