Creating a random square matrix with known singular values

1.1k Views Asked by At

The first step in one question has me creating a random square matrix A with singular values given as $2^{-1}, 2^{-2}\dots 2^{-n}$.

There is no other information about what assumptions can be made with this matrix, but I can probably make some just to get this done. I was considering using singular value decomposition, but I do not know how to create U and V from just the singular values without knowing the vectors. As you can tell, my Linear Algebra background is very weak! Any help is appreciated.

2

There are 2 best solutions below

2
On BEST ANSWER
  1. You take diagonal $D$ equal to your singular values.
  2. Your degenerate $U$ as follows:

    a) Generate randomly the first vector and normalize it by $||u_1||=1$

    b) Generate the second vector and clear it from $u_1$. Normalize afterwards. etc.

  3. In the same way generate $V$.
  4. Define $A=UDV^T$
1
On

The following MATLAB code does the trick:

[U, X] = qr(randn(n));   
[V, X] = qr(randn(n));    
S = diag(2.^(-1:-1:-n));  

A = U*S*V;    

It's always a matter of finding the right function in MATLAB!

Edit: Yes, the following code works, too, and is more succinct. Thanks for the tip!

U=orth(randn(n));
V=orth(randn(n));
S = diag(2.^(-1:-1:-n));  % S diagonal matrix

A = U*S*V;