How to generate random matrices that are rank-deficient by generating their SVD first?

19 views (last 30 days)
How to generate random matrices that are rank-deficient by generating their SVD first?

Accepted Answer

John D'Errico
John D'Errico on 29 Apr 2019
Edited: John D'Errico on 30 Apr 2019
You do it by understanding what a rank deficient matrix is, and what the svd means. The svd of a matrix is a decomposition of the form:
A = U*S*V'
Here U and V are arbitrary ("random") orthogonal matrices, and S is diagonal, containing the singular values. U,S, and V need to be the correct size.
So, to pick a set of singular values. As long as at least one of them is zero, that is all you need. This is true because a diagonal matrix with at least one zero will always be singular. And the product of any pair of matrices cannot have higher rank than either of the members of that product.
The problem is, only you know what "random" means to you. The idea of generating a "random" number, without specifying the distribution of that number is something that has no meaning. So you need to choose those things that will be called random.
You can easily generate an arbitrary orthogonal matrix of size nxn as
Q = orth(randn(n,n));
Of course, that this call to orth actually uses the svd itself seems a bit incestuous. But you could also just use a QR, and avoid the svd.
[Q,R] = qr(randn(n,n));
Pick the singular values as a vector. Remember, one of them must be zero. Create the matrix S using diag. Then form the product as I show above.

More Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!