随机排列矩阵 [英] Random permutation matrix
本文介绍了随机排列矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种简单的方法可以在Matlab中模拟随机置换矩阵(假设大小为1000 x 1000)?我想研究这类矩阵的独立和的特征值分布.
Is there an easy way to simulate a random permutation matrix (say of size 1000 by 1000) in Matlab? I would like to study the eigenvalue distribution of independent sum of such matrices.
提前谢谢!
推荐答案
您可以生成随机置换矩阵这样:
-
创建一个单位矩阵:
Create a unity matrix:
A = eye( N ); %// N is the size of your matrix
For large values of N
it is better to use sparse matrices:
A = speye( N ); % create sparse identity matrix
生成随机排列:
Generate a random permutation:
idx = randperm(1:N);
使用向量索引相应地重新排列行
Use vector indexing to rearrange the rows accordingly
A = A(idx, :);
Voila!
这篇关于随机排列矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文