Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generation of Correlated Data
Date: Sun, 17 Aug 2008 05:27:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 53
Message-ID: <g88cr6$d72$1@fred.mathworks.com>
References: <g7ri75$8hr$1@fred.mathworks.com> <g885b5$m3v$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1218950822 13538 172.30.248.35 (17 Aug 2008 05:27:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 17 Aug 2008 05:27:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:485872



"Deva MDP" <devasiri@gmail.com> wrote in message <g885b5$m3v
$1@fred.mathworks.com>...
> "Deva MDP" <devasiri@gmail.com> wrote in message
> <g7ri75$8hr$1@fred.mathworks.com>...
> > Can some one tell how to generate two random data sets 
> > with known correlation, (say Corr. Coef. = 0.5)
> devasiri@gmail.com
> 
> Dear Friend,
> 
> Thank you for the support given. I undestood how to generate
> two data vectors to a required correlatin between them.But
> my problem is as follows which I couldn't clarify yet.
> 
> I have generated a correlated random vector with 3 columns
> for a desired correlaton matrix. Though my work is
> successful, still I don't know the theory behind this procedure.
> The procedure adopted is as follows.
>  
> (1) Generated 3 random vectors with ndependently normally
> dstributed entries. X=[x1 x2 x3]
> Corr(X)= Identity matrix approximately.
>  
> (2) Then x is transformed in to Y by Y=X*c , where c=
> squreroot of G (G s the ultimate correlation matrix of Y)
> (c is +ve definte matrx)
> The form of G = (1 g g;g 1 g;g g 1], g is the correlaton
> between the formed vectors.
>  
> Thankful If you can kndly let me know the theory behind this
> procedure.
> 
> Best regards
> 
> Devasiri

  For the sake of discussion suppose that your three independent normally 
distributed random variables x1, x2, and x3 have mean 0 and variance 1, so 
that correlation and covariance are one and the same.  If c is the matrix 
square root of the G you have defined, then the following holds true.  The 
covariance matrix of your n by 3 matrix Y = X*c is given by

 E{Y'*Y} = E{(X*c)'*(X*c)} = E{c'*X'*X*c}
 = c'*E{X'*X}*c = c'*I*c = c'*c = c*c = G

Here I is the identity matrix for the covariance matrix of X, and c = c' because 
it is symmetric.  Thus Y has the desired covariances.

  Note that the same would be true for any positive definite G.  All you have to 
do is find its matrix square root (using eigenvector methods presumably.)

Roger Stafford