Random multidimensional normal distribution

I had a problem when I should be able to generate a set of randomly selected numbers of a multidimensional normal distribution with an average of 0 and a given 3 * 3 variance-covariance matrix in Java.

Is there an easy way to do this?

+4
source share
2 answers

1) Use the library implementation as suggested by Dima.

Or, if you really feel the burning need to do it yourself:

2) , M V / V, Cholesky Decomposition V, L , V = LL t ( t ). Z ( Random.nextGaussian() ). LZ + M .

+4

Apache Commons , :

MultivariateNormalDistribution mnd = new MultivariateNormalDistribution(means, covariances);
double vals[] = mnd.sample();
+2

Source: https://habr.com/ru/post/1570316/


All Articles