Is it possible to generate a random complex $n \times p$ matrix $M$, that satisfies $M M^\dagger = \mathbb{1} $? As stated in the title, I'm interested in generating isometric complex matrices of a given $n \times p$ size. Such a matrix $M$ fulfills the following condition $ M M^\dagger = \mathbb{1} $.
Is there some way to generate such matrices efficiently?
 A: $ M M^\dagger = I$ is equivalent to $M$'s rows being any $p$ rows of a unitary matrix (with $p \ge n$), which is further equivalent to the rows of $M$ forming any $p$ elements of a size $n$ orthonormal basis of $\mathbb{C}^n$.
Therefore, you can use the following procedure to generate your random matrix:

*

*Generate a random unit-length complex vector of size $n$. (This can be done by generating any random vector, then dividing by its length.) Let's call this $v_1$.

*Using $v_1$, generate $v_2, \dots, v_n$ using complex Gram-Schmidt orthogonalization. This will create a right-handed system of orthonormal vectors.

*Finally, choose any $p \le n$ vectors from $v_1, \dots, v_n$ and use them as the rows of your matrix.

Note: If $p < n$, you can still use the same method, simply transpose the matrix at the end.
A: This paper gives a method of producing a (uniformly) random matrix $p \times p$ matrix $A$ satisfying $AA^\dagger = I$. Extracting the first $n$ rows gives you a (uniformly random) matrix satisfying $MM^\dagger = I$.
Adapting the Python script given in the paper, we could run the following:
from scipy import *
from linalg import qr
p = 5
n = 3
z = (randn(n,n) + 1j*randn(n,n))/sqrt(2)
q,r = qr(z)
d = diagonal(r)
ph = d/absolute(d)
q = q@ph@q
M = q[:n]

