如何生成对非对角线元素有约束的伪随机正定矩阵? [英] how to generate pseudo-random positive definite matrix with constraints on the off-diagonal elements?

查看:127
本文介绍了如何生成对非对角线元素有约束的伪随机正定矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户希望对var/covar矩阵中每对变量之间的相关性强加唯一,不平凡的上限/下限.

The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix.

例如:我想要一个方差矩阵,其中所有变量都具有0.9> | rho(x_i,x_j)| > 0.6,rho(x_i,x_j)是变量x_i和x_j之间的相关性.

For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j.

谢谢.

好吧,已经找到了一种快速,肮脏的解决方案,但是即使有人知道更精确的方法到达那里,也将受到欢迎.

Ok, something of a quick&dirty solution has been found, still if anyone know of a more exact way to get there, it'll be welcome.

我丢失了原来的登录名,因此我以新的登录名重新发布了该问题. 上一次迭代得到了以下答案

I lost my original login, so i'm reposting the question under a new login. The previous iteration got the following answer

*您的意思是伪随机,这是 semi 随机-Robert Gould

*you mean pseudo-random, that's the correct terminology for semi random – Robert Gould

*好点,但是我认为他的意思是半伪随机(在谈论计算机随机性时使用伪伪:-p)– fortran

*Good point, but I think he meant semi pseudo-random (the pseudo is assumed when talking about computer randomness :-p) – fortran

**关联"是指协方差"吗? –斯旺特

*With "correlation", do you mean "covariance"? – Svante

*不,我确实是指相关.我想生成一个正定矩阵,以使所有的相关性都比平凡的边界更严格. – vak

*no, i really do mean correlation. I want to generate a positive definite matrix such that all the correlations have tighter than trivial bounds. – vak

*请参阅我的答案.您是否坚持认为样本相关性在指定范围内,还是只是生成样本的总体相关性?我确实建议一个想法,如果您的问题是前者,则可能会起作用. –木片

*See my answer. Do you insist that the sample correlations lie within the specified bounds, or just the population correlations that generate the sample? I do suggest an idea that may work if your problem is the former. – woodchips

* woodship:不,我担心您的解决方案将无法正常工作,请在原始威胁中查看我的答案(上面的链接).谢谢.

*woodship: no i'm afraid your solution will not work, please see my answer in the original threat (link above). Thanks.

推荐答案

您可以创建N个大小为M且单位方差的N个随机向量的集合.并向它们添加一个随机向量(大小N和单位方差)乘以一定数k. 然后,将所有这些向量之间的相关性作为正定矩阵.如果M非常大,则相关分布中将没有方差,并且相关将为:k ^ 2/(1 + k ^ 2). M越小,偏离对角线元素的分布越宽. 另外,您可以让M很大,然后将公共向量"乘以每个不同的k.如果正确使用这些参数,则可能会得到更严格的控制.这里有一些Matlab代码可以做到这一点:

You can create a set of N random vectors of size M and unit variance. And add to them a random vector (size N and unit variance) multiplied by a certain number k. Then you take the correlation between all those vectors, that will be a positive definite matrix. If M is very big then there will be no variance in the correlation distribution and the correlation will be: k^2/(1+k^2). The smaller M gets the wider the distribution of the off diagonal elements. Alternatively, you can let M be very large and multiply the "common vector" by a different k each. You might get tighter control if you play with these parameters properly. Here goes some Matlab code to do that:

clear all;
vecLarg=10;
theDim=1000;
corrDist=0*randn(theDim,1);
Baux=randn(vecLarg,theDim)+  (corrDist*randn(1,vecLarg))'+(k*ones(theDim,1)*randn(1,vecLarg))'  ;
A=corrcoef(Baux);
hist(A(:),100);

这篇关于如何生成对非对角线元素有约束的伪随机正定矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆