0
$\begingroup$

I want to choose a random vector in high dimensions such that it all directions have the same uniform chance (i.e. isotropic in all directions). My current idea is the following algorithm:

  1. sample v from a high dim multivariate Gaussian
  2. then normalize that vector by dividing by its norm

I believe this is sufficient but don't know how to prove it. I know that high dimension stats can have weird behaviours (like most of the volume of a Gaussian is at the "edge") so I wanted to make sure I didn't miss anything trivial but important. Anyone know if this is correct? If it is how do I prove it?


What I have in mind in pytorch looks as follows:

v = MultivariateNormal(torch.zeros(10000), torch.eye(10000))
v = v/v.norm(10000)
$\endgroup$
12
  • 3
    $\begingroup$ The title of the linked question says 3d, but the answers are applicable to arbitrary dimensions. The short answer is yes, this method works; this answer gives some numerical confirmation, and this one gives citations for a proof. The only pratical thing to worry about here as far as I know is to make sure that v.norm(2) isn't extremely small for numerical reasons; this is luckily very unlikely in high dimensions. $\endgroup$ – Danica Apr 1 '18 at 1:18
  • $\begingroup$ @Dougal what I fail to see is how that answer confirms that my solution is right? $\endgroup$ – Charlie Parker Apr 1 '18 at 1:21
  • 2
    $\begingroup$ A proof is given in the paper cited by the second link, but apparently it’s still not freely available despite being from 1959.... So check this comment instead for the idea. $\endgroup$ – Danica Apr 1 '18 at 1:30
  • $\begingroup$ @Dougal thanks! I see that my method is correct which is what I wanted the most. $\endgroup$ – Charlie Parker Apr 1 '18 at 1:32
  • 1
    $\begingroup$ @Pinocchio You must be referring to an incorrect method of sampling the sphere, then! Incidentally, your solution--although correct--uses unnecessary computation. By invoking a procedure to produce multivariate Normal samples you will be performing some initial matrix calculations and then subsequent transformations, all of which are unnecessary given that all you have to do is generate independent univariate Normal values. $\endgroup$ – whuber Apr 2 '18 at 14:41