MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > Generating random numbers for correlated variables 

Subject: Generating random numbers for correlated variables From: Kirk Date: 27 Jan, 2009 15:50:18 Message: 1 of 8 
I have a question regarding the generation of random data when the two variables are strongly correlated. 
Subject: Generating random numbers for correlated variables From: Ting Su Date: 27 Jan, 2009 15:53:55 Message: 2 of 8 
Kirk, 
Subject: Generating random numbers for correlated variables From: ImageAnalyst Date: 27 Jan, 2009 16:02:24 Message: 3 of 8 
Not an answer to your question, but related, and some people might 
Subject: Generating random numbers for correlated variables From: Kirk Date: 27 Jan, 2009 18:13:02 Message: 4 of 8 
Thanks for the tip. I think this is on the right track. However, I'm still a bit confused. Would the approach then be to use 'normrnd' to get a randomly generated vector of TMAX values from measured TMAX means and standard deviations: 
Subject: Generating random numbers for correlated variables From: Roger Stafford Date: 27 Jan, 2009 20:05:07 Message: 5 of 8 
"Kirk" <kwythers.nospam@umn.edu> wrote in message <glnire$h33$1@fred.mathworks.com>... 
Subject: Generating random numbers for correlated variables From: Kirk Date: 28 Jan, 2009 15:42:02 Message: 6 of 8 
> Probably you should use 'mvnrnd(mu,sigma,cases)' separately for each of the twelve months. For each one you would need its two corresponding means in 'mu' and the month's two by two covariances in 'sigma'. The number in 'cases' tells how many random numbers you want to generate for that month. 
Subject: Generating random numbers for correlated variables From: Roger Stafford Date: 29 Jan, 2009 02:30:04 Message: 7 of 8 
"Kirk" <kwythers.nospam@umn.edu> wrote in message <glpuca$dsc$1@fred.mathworks.com>... 
Subject: Generating random numbers for correlated variables From: Kirk Date: 29 Jan, 2009 05:17:01 Message: 8 of 8 
> Its documentation states "MU is an nbyd matrix, and mvnrnd generates each row of R using the corresponding row of mu. SIGMA is a dbyd symmetric positive semidefinite matrix, or a dbydbyn array." For you with d = 4 you will need twelve different 4 x 4 covariance matrices, one for each month, combined in a 4 x 4 x 12 multidimensional array, and these need to have a 'repmat' applied to them to achieve the desired 4 x 4 x 12000 size. Your MU needs to be 12000 x 4. The result will be a 12000 x 4 array containing the 12000 sets of the four random variables. 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.