A simple algorithm for generating positive-semidefinite matrices

前端 未结 6 2144
傲寒
傲寒 2020-12-08 19:25

I want to generate positive random semi-definite matrices. I am looking for an algorithm or more preferably an simple implementation of the algorithm in C, matlab, java or a

6条回答
  •  温柔的废话
    2020-12-08 20:09

    1. generate random matrix
    2. multiply it by its own transposition
    3. you have obtained a positive semi-definite matrix.

    Example code (Python):

    from scipy import random, linalg
    matrixSize = 10 
    A = random.rand(matrixSize,matrixSize)
    B = numpy.dot(A,A.transpose())
    print 'random positive semi-define matrix for today is', B
    

提交回复
热议问题