1
$\begingroup$

Could anybody tell me that How one can generate a random singular matrices using matlab? I know that using rand(n) we can generate a random matrix of order n. But I found that these random matrices are non singular while I am interested in generating random singular matrices of higher order. Is there any command through which we can generate a random singular matrices? I need help.

Thanks a lot

4 Answers 4

2

If you're not too worried about the distribution of the matrix, you could just generate an $n-1 \times n$ matrix, and let the $n$th row be the sum of the others.

n = 3; A = rand(n-1,n); A(end+1,:) = sum(A); 
  • 0
    `A(end,:)` refers to the last row of the matrix $A$. Assigning a row to row `end+1` is a quick way to append a row to the matrix.2012-09-16
1

Another possibility is to take a random $n \times n$ matrix and adjust one entry to make the determinant $0$. This will be possible as long as the corresponding cofactor is not $0$, which is almost always the case.

  • 0
    Thank you very much sir. I have to think how to make code for that?2012-09-16
1

If the distribution of the points is not important, you can generate an $n\times n$ matrix with rank $k$ with the following pseudocode.

Generate a random matrix $R$ of dimension $n\times k$. Set A=R*R^T. 

Then $A$ will be an $n\times n$ matrix with rank $k$. This is due to the fact that $A$ is a series of $k$ outer products from the columns of $R$.

0

How are the entries of the matrix generated? Are they Bernoulli / Gaussian / uniform random variables? Whatever the PDF of each matrix entry, here's what you can do:

  1. Generate a random matrix.
  2. Check if matrix is singular.
  3. If singular, then use it. If not singular, discard it, and go back to 1.

Of course, you have to think about what "singular" means in MATLAB, for we're using floating-point numbers, not real numbers. Rank lower than eps would do, but it may be too conservative. You would wait a billion years until you found a singular random matrix.

  • 0
    If I were to referee a research paper that dealt with "ra$n$dom singular matrices", I would insist that the author specify the distribution or the method of generating those "random" matrices.2012-09-16