ran_mat | R Documentation |
Random generator of matrices with given eigenvalues.
ran_mat(p, ev = stats::runif(p, 0, 10), seed = NULL)
p |
A positive integer >= 2, the dimension. |
ev |
A vector of length |
seed |
A number, the seed for the generator. Ignored if |
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
.
A p
by p
matrix whose eigenvalues equal to ev
.
p <- 30
eigen_values <- (0.1*p-1+1:p)/p
K <- ran_mat(p, ev=eigen_values, seed=1)
sort(eigen(K)$val)-eigen_values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.