0
$\begingroup$

Is there any way to create a random symmetric positive definite matrix ?

$\endgroup$
  • 3
    $\begingroup$ Define "random." $\endgroup$ – David G. Stork Dec 14 '18 at 4:59
  • $\begingroup$ @David G. Stork sir, thanks for the reply,actually i want to create a positive definite matrix randomly in the range from (-1 ,1) $\endgroup$ – revanth roy Dec 14 '18 at 5:29
  • 1
    $\begingroup$ @revanthroy That does not define "random". You have to specify a probability distribution. $\endgroup$ – Henrik Schumacher Dec 14 '18 at 7:05
2
$\begingroup$

See a-simple-algorithm-for-generating-positive-semidefinite-matrices

Translation to Mathematica:

n    = 5; (*size of matrix, change as needed*)
q    = Table[RandomReal[{-1, 1}], {n}, {n}];
mat  = Transpose[q].q;
PositiveDefiniteMatrixQ[mat]
(*true*)

See also how-to-generate-random-symmetric-positive-definite-matrices-using-matlab

The matrix symmetric positive definite matrix A can be written as , A = Q'DQ , where Q is a random matrix and D is a diagonal matrix with positive diagonal elements. The elements of Q and D can be randomly chosen to make a random A.

Here is the translation of the code to Mathematica

n         = 5; (*size of matrix. Change as needed *)
q         = Table[RandomReal[{-1, 1}], {n}, {n}];
eigenMean = 2; (*see link above *)

mat = Transpose[q].DiagonalMatrix[eigenMean + Table[RandomReal[{-1, 1}], {n}]].q;

PositiveDefiniteMatrixQ[mat]
(*true*)
$\endgroup$
2
$\begingroup$
dim = 10;

RandomVariate[GaussianOrthogonalMatrixDistribution[dim]]

or

With[{U = RandomVariate[CircularRealMatrixDistribution[dim]]},
 U.(RandomReal[{-1, 1}, dim] U\[Transpose])
 ]
$\endgroup$
  • $\begingroup$ Since OP did not specify a precise probability distribution, this question cannot be answered precisely. $\endgroup$ – Henrik Schumacher Dec 14 '18 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.