楼主: 笨阿虫
12684 11

[问答] 为什么生成多元正态分布随机数时要分解协方差矩阵? [推广有奖]

  • 0关注
  • 2粉丝

已卖:327份资源

本科生

54%

还不是VIP/贵宾

-

威望
0
论坛币
2688 个
通用积分
0
学术水平
5 点
热心指数
0 点
信用等级
0 点
经验
4068 点
帖子
89
精华
0
在线时间
101 小时
注册时间
2011-10-18
最后登录
2015-9-8

楼主
笨阿虫 发表于 2012-5-16 19:38:35 |AI写论文
5论坛币
统计数理懂的不多,请教数理统计知识
生成多元正态分布随机数的时候,
先生成协方差矩阵sigma,再对协方差矩阵sigma分解to determine the matrix root of sigma(查得分解方法有三种, eigenvalue decomposition
("eigen", default), singular value decomposition ("svd"), and Cholesky decomposition ("chol"))。
为什么要分解而不直接用协方差矩阵呢?生成一元正态分布的时候,直接是mean+sigma*rannorm()

例如:生成1000组相关系数均为0.3的服从多元正态分布的随机向量(X,Y,Z),其中随机变量X~N(0,1),y~N(10,2),Z~ N(20,3)。
SAS程序:
proc iml;
R={1.00 0.30 0.30,
   0.30 1.00 0.30,
   0.30 0.30 1.00};
S={1 0 0,
   0 2 0,
   0 0 3};
sigma=S*R*S;
u={0,10,20};
do i=1 to 1000;
z1=RANNOR(0);
z2=RANNOR(0);
z3=RANNOR(0);
C=root(sigma);                  
xi=C`*(z1//z2//z3)+u;      /*为什么要先求C,而不是直接用sigma?*/
m=m//xi`;
......

最佳答案

snoozer 查看完整内容

One thing you have to keep in mind is that, in matrix operation sigma=C'*C, C is not simply the element-wise square root of sigma. Say sigma is the covariance matrix of X. You need to guarantee the simulated data X satisfying cov(X)=sigma. If you use sigma directly in your simulation, the covariance matrix of X cov(X) =sigma'*I*sigma=sigma'*sigma, where I is the covariance matrix of rando ...
关键词:多元正态分布 协方差矩阵 正态分布 随机数 协方差 sigma determine default 正态分布

本帖被以下文库推荐

沙发
snoozer 发表于 2012-5-16 19:38:36
One thing you have to keep in mind is that, in matrix operation sigma=C'*C, C is not simply the element-wise square root of sigma.  

Say sigma is the covariance matrix of X. You need to guarantee the simulated data X satisfying cov(X)=sigma.

If you use sigma directly in your simulation, the covariance matrix of X cov(X) =sigma'*I*sigma=sigma'*sigma, where I is the covariance matrix of random normal and has to be identity matrix. Then this is not what your want for X.

Using the root matrix C, you get the right X ( cov(X)=C'*I *C=C'*C=sigma ).

藤椅
Jasonluo 发表于 2012-5-16 19:47:11
帮楼主顶

板凳
bobojin 发表于 2012-5-16 20:20:33
问得好,很久没见人问过这个问题了

报纸
bobojin 发表于 2012-5-16 20:33:53
如果直接用矩阵去乘,那相关性也变陏机了,不能这样做,明白没

地板
笨阿虫 发表于 2012-5-16 20:44:08
bobojin 发表于 2012-5-16 20:33
如果直接用矩阵去乘,那相关性也变陏机了,不能这样做,明白没
恩恩,谢谢你,明白不能用sigma矩阵了。那么为什么分解为C矩阵可以解决这个问题呢?
如果简单几句话说不明白,可否建议一下看哪方面的资料能理解这个问题。

7
笨阿虫 发表于 2012-5-16 20:50:19
bobojin 发表于 2012-5-16 20:33
如果直接用矩阵去乘,那相关性也变陏机了,不能这样做,明白没
因为如果直接用sigma矩阵相乘,相关性也随机了。要解决这个问题,我可能会很简单的想着先直接用方差矩阵S乘rannorm(),然后再用相关性系数矩阵R乘.他们也是满足矩阵相乘的条件。当然这样是不对的。我只是想完全明白协方差的分解

8
jingju11 发表于 2012-5-16 21:37:33
I was thinking of a simplest case for that:
http://blog.sina.com.cn/s/blog_a3a9263601012gr3.html

in one word, Cholesky root, etc. has such nice property to link Np~(0,I)random numbers to Np(mu, sigma)through decomposing the cov/corr matrix.if p =1, of course no need of decomposition.


9
eluxiaoyao 发表于 2012-5-24 16:45:47
y1=u1+sigma1*rannorm()1,
y2=u2+sigma2*rannorm()2,
rannorm()1,rannorm()2是相互独立的,则
cov(y1,y2)=0,而实际上y1,y2的协方差是不为0的,所以不能直接那么做。

10
笨阿虫 发表于 2012-5-25 09:26:10
eluxiaoyao 发表于 2012-5-24 16:45
y1=u1+sigma1*rannorm()1,
y2=u2+sigma2*rannorm()2,
rannorm()1,rannorm()2是相互独立的,则
一元的懂,我是想问多元的“协方差阵”为什么要分解,或者说,为什么协方差阵分解了之后就可以

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 14:21