Prev: Books on the zeta function?
Next: A MILLION NUMBERS TESTED- PRIME NUMBER ALOGARITHM IS GOOD , INVERSE 19 MATHEMATICS, AUTHENTICATED BY 5 SEPERATE MATHEMATICIANS!
From: MBALOVER on 3 Apr 2010 18:45 Hi all, 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,
From: Ray Vickson on 3 Apr 2010 21:38 On Apr 3, 3:45 pm, MBALOVER <mbalov...(a)gmail.com> wrote: > Hi all, > > 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, 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
From: C Hanck on 4 Apr 2010 04:04 If you want another covariance matrix than Identity, say Sigma, you can generate three independent samples and muliply these with the Cholesky decomposition of Sigma. Christoph
From: geo on 4 Apr 2010 06:30 On Apr 3, 6:45 pm, MBALOVER <mbalov...(a)gmail.com> wrote: > Hi all, > > 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. > ---------------------------------------------------------------------------------------- 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,
From: MBALOVER on 4 Apr 2010 13:19
Great!!!, Thank you guys very much. Your answers are very clear and helpful. I get it and have successfully generated the data as I desire. Thank you. Best |