How can I generate random invertible symmetric positive semidefinite square matrix using MATLAB?
    15 次查看(过去 30 天)
  
       显示 更早的评论
    
matrixSize = 10 
A = random.rand(matrixSize,matrixSize)
B = numpy.dot(A,A.transpose())
I am not sure, this generates random positive semi-define matrix B. But I want to generate random invertible symmetric positive semidefinite square matrix. Thank for your help.
采纳的回答
  Walter Roberson
      
      
 2018-9-4
        matrixSize = 10;
while true
  A = rand(matrixSize, MatrixSize);
  if rank(A) == matrixSize; break; end    %will be true nearly all the time
end
B = A' * A;
According to https://en.wikipedia.org/wiki/Positive-definite_matrix, for any square matrix A, A' * A is positive semi-definite, and rank(A' * A) is equal to rank(A) . Matrices are invertible if they have full rank. So all we have to do is generate an initial random matrix with full rank and we can then easily find a positive semi-definite matrix derived from it. Nearly all random matrices are full rank, so the loop I show will almost always only iterate once and is very very unlikely to need more than a very small number of iterations.
0 个评论
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!