Okay, sorry it took me so long to get back to this problem, but I've been busy with getting ready for E3. So I finally have a solution for uniformly distributed unit quaternions (or 4 vectors, whatever you want to call them)
For background (and previous definitions) see the previous post about random unit 3 vectors
Now, we'll derive a way to randomly generate points on the surface of a 4-dimensional sphere. Again, we'll calculate a formula for A. The surface measure of a section swept out by
is
So the probability of getting a point whose θ2 is between 0 and x is
This would be difficult to invert, so instead, we'll use the fact that we can make θ2 a function of multiple random numbers, as long as the probability comes out right. So let's guess that it would take the form
We multiply X by π, and add π/2 to arcsin(Y) to change the range of both expressions to (0, π). If this guess is correct, the two coefficients will probably add up to 1 (making this a weighted average of the two expressions). So the probability that θ2 is less than x (for x between 0 and π) is the sum of all probabilities (for all possible m's) that X is less than m and arcsin(Y)+π/2 is less than (x- m). Therefore
And setting these two equal gives
so that means
Which initially looks over constrained (3 equations and 2 unknowns), but fortunately we guessed well, and it turns out that
So, finally, we can say that to generate a uniformly random point on the surface of a 4-dimensional sphere
Edit: These equations were corrected according to a comment made on the previous post pointing out that some variables had been switched
And it's pretty easy to see that (in terms of random number generation)
yields the same results as
Which looks a little nicer (you don't need to add the π/2). I'll leave it as an excersize for the reader to figure out that to generate a uniformly random point throughout the sphere (not just on the surface) you just need to pick a random radius by
where n is the number of dimensions of the sphere
No comments:
Post a Comment