1

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]
ricard.py
  • 11
  • 3
  • 5
    Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. Also, add your existing code. – zx8754 May 16 '16 at 11:35

1 Answers1

0

You can do that with the rstiefel package:

library(rstiefel)
rustiefel(N, K)
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225