如何在朱莉娅中生成任意等级的随机矩阵?
朱莉娅有什么办法可以生成具有任意/指定等级的随机矩阵?例如,是否有任何功能可以生成等级2的随机3x3矩阵?
Is there any way in Julia to generate a random matrix that has some arbitrary/specified rank? For example, is there any function that would allow generating a random 3x3 matrix of rank 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于您所说的“随机矩阵”(即什么分布?),但是
rand(3,2)*rand(2,3)
将产生一个随机矩阵3x3等级的矩阵2分布。This depends a little on what you mean by "random matrix" (i.e. what distribution?), but
rand(3,2)*rand(2,3)
will produce a random matrix 3x3 matrix of rank 2 with some distribution.一种选择是生成R随机向量(独立的概率1),并用后者的随机(或预定义)线性组合填充其余的矩阵。
极简主义的解决方案是复制一些初始向量。
An option is to generate r random vectors (probability 1 of being independent) and fill the rest of the matrix with random (or predefined) linear combinations of the latter.
A minimalist solution is to just replicate some of the initial vectors.
生成所需格式的随机矩阵,计算其SVD,根据等级将较低的单数值设置为零,重建等级降低的矩阵。
与随机矩阵的乘法产生的相比,这应该给出不同的“随机”,更高的成本。
Generate a random matrix of the desired format, compute its SVD, set the lower singular values to zero according to the rank, reconstruct the rank-reduced matrix.
This should give a different kind of "random", at higher cost, than the one resulting from the multiplication of random matrices.