mitodl / mitx-grading-library

The MITx Grading Library, a python grading library for edX
https://edge.edx.org/courses/course-v1:MITx+grading-library+examples/
BSD 3-Clause "New" or "Revised" License
14 stars 9 forks source link

Orthogonal matrix sampling #148

Closed jolyonb closed 5 years ago

jolyonb commented 6 years ago

Ok, I've finally hit the point where I want a special matrix sampler. In this case, I'm after a random orthogonal matrix. I think this can be done in the following way:

  1. Specify number of dimensions (n)
  2. Sample n random vectors of this dimension
  3. Normalize the first vector
  4. Take the second vector, subtract off the components in the direction of the first vector, and then normalize it
  5. Repeat with the third, subtracting off components in the direction of the first two vectors etc
  6. Put the resulting n orthonormal vectors in a matrix
ChristopherChudzicki commented 6 years ago

So, sample a generic n by n matrix, then do Gramm-Schmidt on the rows (or columns)?

That sounds like a good approach. This would work for unitary matrices, too, right? Just sample the original vectors over C instead of R.

jolyonb commented 6 years ago

Basically. Unitary will work the same way.