[math-fun] random points on sphere, normals
Salamin: Random points on the unit n-sphere can be generated without the need for sqrt and trig. Generate n+1 independent Gaussian random numbers, and normalize the vector to unit length. -- Gene --WDS: I agree this is the way that would have occurred to me to generate point on sphere... but... First of all, seems to me "normalizing vector to unit length" requires sqrt. Second, generating random Gaussians in the first place is often done with the aid of trig, log, and/or sqrt (Box-Muller method). There is however is a nice approach due to Chris Wallace for generating certain kinds of randoms, especially Gaussians, without any fancy functions. You have a pool of random standard Gaussian deviates. If we then apply a KxK orthogonal matrix to any K of the pool members, the result is K new Gaussian deviates. In this way you can keep updating the pool. Once the pool is re-randomized enough you output some of its members. This depends inherently on the fact the Gaussian is the maxent distribution with mean=0 and variance=1. The Wallace approach can be implemented in ways not requiring sqrt or trig, and very fast -- this is one of the fastest, and perhaps *the* fastest, random-Gaussian generation method known.. It has some small statistical flaws however, and if you get serious about correcting the flaws, that slows it down somewhat. I happen to think, which is I believe a new remark by me, this same kind of approach would be a good way to generate "stable" random variables. I also have ways to generate "gamma" variates by such an approach. But the trouble is, the standard Gaussian has no parameters, but other things such as stables, gammas, etc do have parameters. And if you generate samples from a parameterized distribution via a Wallacian pool-update procedure, then you've got to stick with just one choice of parameter values for everybody in the pool. Which is very limiting because users might want to keep changing parameters.
Salamin: Random points on the unit n-sphere can be generated without the need for sqrt and trig. Generate n+1 independent Gaussian random numbers, and normalize the vector to unit length. -- Gene
This can be used to generate a uniform [-1, 1] variable using three standard Gaussians together with the field operations and sqrt(): U[-1, 1] = Z^2/sqrt(X^2 + Y^2 + Z^2) This is very elegant, apart from the annoying sqrt(). It transpires that we can actually dispose of the sqrt(), given an extra Gaussian: -------- Problem 1 (solved): Find a rational function (no sqrt allowed) of *four* standard Gaussians, which will produce a uniform U[a, b] distribution. Solution: http://mathoverflow.net/questions/164851/which-distributions-can-you-sample-... -------- Problem 2 (open): Can we do it with fewer than four Gaussians? It's obvious we need at least two, since erf is not a rational function. Sincerely, Adam P. Goucher
participants (2)
-
Adam P. Goucher -
Warren D Smith