This method returns a random symmetric positive semidefinite real matrix of a given size $n$. The rank $r$ can also be specified: by default, the matrix will be full rank (with probability 1). An upper bound $s$ on the spectral radius can also be specified: by default, the matrix will have spectral radius $<= 1$.
i1 : randomPSD 5
o1 = | .585298 -.0545901 .0184505 -.0599728 -.149145 |
| -.0545901 .761001 -.0118983 -.160458 -.02979 |
| .0184505 -.0118983 .56512 .0605255 -.0250409 |
| -.0599728 -.160458 .0605255 .609506 -.00367036 |
| -.149145 -.02979 -.0250409 -.00367036 .761799 |
5 5
o1 : Matrix RR <--- RR
53 53
|
i2 : A1 = randomPSD(5, 3)
o2 = | .0822059 .117626 -.109793 -.00518272 -.0292519 |
| .117626 .168797 -.149976 -.0126384 -.0536067 |
| -.109793 -.149976 .295902 -.204962 -.0805114 |
| -.00518272 -.0126384 -.204962 .460442 -.0253618 |
| -.0292519 -.0536067 -.0805114 -.0253618 .349651 |
5 5
o2 : Matrix RR <--- RR
53 53
|
i3 : A2 = randomPSD(5, 3.0)
o3 = | .466141 -.549293 .0814037 .326059 -.171432 |
| -.549293 2.32094 -.225548 -.826411 -.0874656 |
| .0814037 -.225548 .538414 .404872 .190896 |
| .326059 -.826411 .404872 .890458 .0658219 |
| -.171432 -.0874656 .190896 .0658219 .577543 |
5 5
o3 : Matrix RR <--- RR
53 53
|
i4 : (A1, A2)/eigenvectors -- note the difference!
o4 = (({1.11022e-16 }, | .887354 -.162261 -.415623 -.116326 .0916635 |),
{.626892 } | -.344505 -.218178 -.595049 -.197553 .624642 |
{.350611 } | .265117 .620177 .364839 -.146256 .649019 |
{.379495 } | .123582 -.733874 .580879 -.109056 .322299 |
{-2.14586e-17} | .0914289 -.05366 -.051451 .956116 .276258 |
------------------------------------------------------------------------
({2.93272}, | .248943 -.183226 .443654 .667494 -.511935 |))
{.851128} | -.856474 .297886 .368634 .197344 .0536749 |
{.637309} | .163236 .62407 .206671 -.464468 -.57048 |
{.178755} | .419929 .422352 .467183 .138583 .638603 |
{.193582} | .0386539 .556639 -.637422 .52969 -.0421905 |
o4 : Sequence
|
i5 : A3 = randomPSD(5, 3, 7.0)
o5 = | 1.20614 -.134804 -.0319069 -.60937 .0177087 |
| -.134804 .16531 -.000970882 .12522 -.0189459 |
| -.0319069 -.000970882 .0606769 -.175278 .226441 |
| -.60937 .12522 -.175278 .932231 -.734734 |
| .0177087 -.0189459 .226441 -.734734 .86079 |
5 5
o5 : Matrix RR <--- RR
53 53
|
i6 : eigenvectors(A3, Hermitian => true)
o6 = ({-6.0946e-16 }, | .320451 -.0980808 .179599 -.74438 .548938 |)
{-3.07584e-17} | -.199737 .0420124 .97172 .0750933 -.0919877 |
{.150772 } | -.0655613 -.974173 .0245115 .185606 .107882 |
{1.08742 } | .699426 -.148572 .0981496 -.153387 -.674958 |
{1.98696 } | .603258 .132396 .115199 .618289 .472227 |
o6 : Sequence
|