]> gitweb.michael.orlitzky.com - octave.git/blob - random_positive_definite_matrix.m
Add tests for the steepest descent method, based on the PCGM tests.
[octave.git] / random_positive_definite_matrix.m
1 function A = random_positive_definite_matrix(integerN, max_entry = realmax)
2 %
3 % Generate a random, symmetric positive-definite (SPD) matrix.
4 %
5 % Since all (SPD) matrices are diagonalizable and have positive
6 % eigenvalues, it seems likely that we can generate an SPD matrix by
7 % combining random orthogonal matrices with a diagonal matrix of
8 % random eigenvalues.
9 %
10 % I have no proof/evidence that this approach is sound.
11 %
12 % INPUT:
13 %
14 % - ``integerN`` -- The dimension of the resulting matrix.
15 %
16 % - ``max_entry`` -- (optional) Upper bound on the entries.
17 %
18 % OUTPUT:
19 %
20 % - ``A`` -- A symmetric, positive definite matrix.
21 %
22 U = random_orthogonal_matrix(integerN);
23 d = unifrnd(eps, max_entry, 1, integerN);
24 D = diag(d);
25 A = U*D*U';
26 end