本文介绍了随机多元正态分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我必须能够生成一组随机选择的一组多元正态分布,在Java中均值为0,并具有给定的3 * 3方差-协方差矩阵。

I've run into a problem where I have to be able to generate a set of randomly chosen numbers of a multivariate normal distribution with mean 0 and a given 3*3 variance-covariance matrix in Java.

是否有一种简便的方法?

Is there an easy way as to do this?

推荐答案

1)使用库

或者,如果您确实感到迫切需要自己做:

Or, if you really feel a burning need to do this yourself:

2)假设您要生成具有均值向量M和方差/协方差矩阵V的法线,请执行在V上得出下三角矩阵L,使得V = LL (上标t表示转置)。生成三个独立标准法线的向量Z(使用 Random.nextGaussian()来获取单个元素)。然后 LZ + M 将具有所需的多元正态分布。

2) Assuming you want to generate normals with a mean vector M and variance/covariance matrix V, perform Cholesky Decomposition on V to come up with lower triangular matrix L such that V=LL (where the superscript t indicates transpose). Generate a vector Z of three independent standard normals (using Random.nextGaussian() to get the individual elements). Then LZ + M will have the desired multivariate normal distribution.

这篇关于随机多元正态分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 10:57