ran_mat: Random generator of matrices with given eigenvalues.
Description
Random generator of matrices with given eigenvalues.
Usage
ran_mat(p, ev = stats::runif(p, 0, 10), seed = NULL)
Value
A p by p matrix whose eigenvalues equal to ev.
Arguments
p
A positive integer >= 2, the dimension.
ev
A vector of length p, the eigenvalues of the output matrix.
seed
A number, the seed for the generator. Ignored if NULL.
Details
The function randomly fills a p by p matrix with independent \(Normal(0,1)\) entries, takes the Q matrix from its QR decomposition, and returns \(Q' diag(ev) Q\).