全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
12588 11
2012-05-16
悬赏 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 ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
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 ).
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-5-16 19:47:11
帮楼主顶
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-5-16 20:20:33
问得好,很久没见人问过这个问题了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-5-16 20:33:53
如果直接用矩阵去乘,那相关性也变陏机了,不能这样做,明白没
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

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

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群