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

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

问题描述

用户想要对 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

*你的意思是伪随机,这是随机的正确术语——罗伯特·古尔德

*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

*不,我的意思是相关性.我想生成一个正定矩阵,使得所有相关性都比平凡的界限更紧.– 瓦克

*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 和单位方差)乘以某个数字 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天全站免登陆