I'm trying to generate random variables. I read about Box-Muller transform which is a way to generate a pair of normal variables, 2-d normal distrubution. But how do I expand that transform to generate 3-d, 4-d, etc. normal variables with this approach? Or is there a different approach to consider?
Asked
Active
Viewed 7,451 times
8
-
Box-Muller attempts to give you *two* independent normals. Are you asking about vectors of normals? (I see it in your tags but your question should be explicit.) Do you mean multivariate normal with some mean and covariance matrix, or do you mean independent normal? Please also note that Box-Muller is very old - whether you're interested in speed or accuracy in the tail, there are better approaches for generating normals. – Glen_b Mar 05 '13 at 00:44
-
Yes I'm looking at independent normals, I would like to generate via box-muller if you can guide me. – gizgok Mar 05 '13 at 03:23
-
1"*I would like to generate via box-muller*" --- Why this and not some other thing? – Glen_b Mar 05 '13 at 04:21
-
1A multivariate generalization of Box-Muller would somehow generate uniformly distributed points on the $n-1$-sphere and independently rescale them by a $\chi^2_{n}$ variate. See the related question at http://stats.stackexchange.com/questions/7977. It is evident this will not be efficient compared to generating $n$ iid normals in the usual ways (including Box-Muller). – whuber Mar 05 '13 at 04:33
-
1@whuber that strikes my funny bone since of course (and I know you know it already), one easy way to generate on the $n-1$-sphere when $n$ is not small is by *starting* with normals. – Glen_b Mar 05 '13 at 05:36
-
Good question; I edited it a bit (please check). For some recipe, see a related question [here](http://mathematics.livejournal.com/1144375.html). That question asked about how to extend Box-Muller for multivariate case in order to generate _regular_ (less-than-random) multivariate normal cloud. – ttnphns Mar 05 '13 at 06:17
1 Answers
3
Box-Muller generates pairs of independent normals from pairs of independent uniforms.
To get more than two independent normals, generate more uniforms. If you want 17 normals, generate 18 uniforms, and get 9 pairs of normals. Discard one. If your 18 uniforms are independent, your 17 normals should be.
http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
(Incidentally Marsaglia appears to have invented this kind of approach first, I think perhaps in the polar-method form detailed at the link. But because it was right after the war, it was treated as a secret and he was not able to publish it.)
You can also get correlated normals by starting from independent ones, for example via use of a Choleski decomposition of the covariance matrix.

Glen_b
- 257,508
- 32
- 553
- 939
-
This viable advice only in a task of generating _random_ data. What if to wish to generate non-random data? (See my comment to the OP answer) – ttnphns Mar 05 '13 at 06:33
-
@ttnphns If OP edits to ask such a question... I'll see if I can add to it. – Glen_b Mar 05 '13 at 09:40