I need to generate data from a 3D Gaussian distribution with mean 0
and Covariance matrix I (identity matrix).
I read from some statistic books but they only talk about sampling a
2D Gaussian distribution, for example using Box-Muller.
The Box-Muller for 2D Gaussian can be described as
" First convert to the P(x,y) to pole-coordinates Q(theta, r) , it
will be product of two pdf of two independent RVs theta and r, where
theta is uniform distribution (0,2pi)
Then use inverse transform to generate the distribution of r. Finally
convert back to xy coordinates to get data from the desired 2D
Gaussian distribution."
The problem is that I want to extend it to 3D. Could you please guide
me how to do it?
Or please refer me to some papers, book chapters?
Thank you very much.
Regards,
Since you specify independent normals, just generate 3 individual,
random variables.
-Dick Startz
Use Box-Mueller three times (to get six Gaussians). Take these in
groups of three, to get two of your required samples.
R.G. Vickson
Christoph
What is often called the Box-Muller method
is actually the generation of a point in the unit
circle, projecting it onto the unit circumference,
then into 2-D space by means of the Marsaglia
Polar Method:
Choose x,y uniform in (-1,1) until
s = x^2+y^2 < 1.
Then the point
p=(x,y)/sqrt(s)
is uniform on the unit circumference,
and---the key point--- s is independent
of p and is itself uniform in (0,1).
Thus -2*ln(s) is a chi-square-2
variate and (r*x,r*y) is a standard normal
point in the plane, with
r=sqrt(-2*ln(s)/s).
If a point p=(x,y,z) is uniform on the
surface of the unit 3-sphere, then it has been
known since Archimedes related the volumes
of spherical segments to cylinders,
that z is uniform in (-1,1), but of course
z and p are not independent, so we cannot
use z, but must get another independent uniform
variate to form a chi-3 variate that projects
p into 3-space.
However, getting the point (x,y,z) uniformly
distributed on the surface of the unit 3-sphere
may be done by the Marsaglia method,
Annal Math. Statistics, V43, No 2, 645-646:
Generate x,y uniform in (-1,1) until
s = x^2+y^2 < 1.
If t=sqrt(1-s), the point
(2xt,2yt,1-2s)
is uniform on the surface of the unit sphere,
but an additional chi-3 variate is needed
to project it into a 3-D normal point.
Whether for two or three, it is probably much faster
to get the required number of independent normal
variates by means of
the Ziggurat Method of Marsaglia and Tsang.
Journal Statistical Software, V5, Issue 8,
This is a question of trying to see the forest or trying to see the trees.
The basic observation is that if you have a black box that gives you Gaussians
then use three of then to get a 3-d ditribution with unit covariance. For
other covariances you do a linear transformation. That was the forest. Or
just two for 2-d or four for ... well you get the idea.
Now for the trees. To convert a uniform random variable into a Gaussian random
variable there are awkward slow methods like inverting the cumulative and slick
quick methods. Box-Muller is slick and quick and actually does pairs.
Many black
boxes for Gaussians use Box-Muller to get a pair and then give them out one at
a time. There is no common slick quick method for triples but then there is no
real need for one given the earlier paragraph. Some think Box-Muller is awkward
amd slow as it uses inversion of cumulatives that happen to convenient
analytically.
So there are quick elaborate methods for one Gaussian. There seems to
be a small
contest to come up with the most "something" for this problem and text
books get
trapped into describing the details of such "trees" and forget the forest.
I get it and have successfully generated the data as I desire.
Thank you.
Best