Multivariate Random Number Generation in Matlab -


i'm being little dense i'm not mathsy , can't seem understand covariance element of creating multivariate data.

i'm after 2 columns of random data (representing 2 correlated variables).

i think right in needing use mvnrnd function , understand 'mu' must column of mean vectors. need 4 distinct classes within data these going (1, 1) (-1 1) (1 -1) , (-1 -1). assume have function 4x different column of mean vectors each time , combine them full data set.

i don't understand should put sigma - matlab tells me must 'a d-by-d symmetric positive semi-definite matrix, or d-by-d-by-n array' i.e. covariance matrix. don't understand how create covariance matrix numbers yet generate.

any advice appreciated!

assuming understood case properly, go way:

data = [normrnd(0,1,5000,1),normrnd(0,1,5000,1)]; %% starting data series mu = mean(data,1); sigma = cov(data); 

now, should possible feed mvnrnd mu , sigma:

r = mvnrnd(mu,sigma,5000); plot(r(:,1),r(:,2),'+') %% in case wanna plot results 

i hope helps.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -