I am trying to generate points (vectors) from the $L^2$ unit norm hypersphere uniformly at random.
This post says to:
- Generate a random Gaussian $d$-dimensional vector $v$.
- Generate a random uniform number $u$ in $[0, 1]$.
- "Normalize the vector to norm $u^{1/d}$."
Unfortunately, I don't understand how to do step (3). I believe that to normalize a vector to 1, one would compute $\frac{v}{norm(v)}$. I have considered computing $\frac{v}{u^{1/d}}$, but this doesn't make sense to me, since in the first case our divisor was $norm(v)$ despite the fact that the desired norm of 1 was not equal to $norm(v)$.
In another post referenced by the above, someone has commented a Matlab implementation of the solution, which suggests that I should compute: $\frac{v u^{1/d}}{norm(v)}$... but I don't understand the rationale for this.
Could someone confirm that the latter method is correct, and perhaps explain how so? Is there a general way to normalize a $d$-dimensional vector so that its $L^p$ norm is $c$?