简体   繁体   中英

(R) Generate a semi-orthogonal random matrix

I need to generate a random NxK matrix (where N > K), where the columns K are orthogonal random vectors.

An option I tried is to generate a squared orthogonal matrix with size NxN and then select the first K columns, but I wonder if there is a more efficient way of doing so.

Current code (in R):

library(pracma)
Z <- rortho(N)[,1:K]

You can do that with the rstiefel package:

library(rstiefel)
rustiefel(N, K)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM