MATLAB Answers

What the two columns represnt when i generate a multivarite normal random numbers

1 view (last 30 days)
Fissha Marye
Fissha Marye on 30 Nov 2019
Commented: Jeff Miller on 2 Dec 2019
I run the following command to genrate two variables joint normally distributed with mean Mu and covariance matrix Sigma, which are defined below
MU=zeros(2,1)
sigma=[1 0.7;0.7 1]
M=mvnrnd(MU,sigma,N)
Then it genartes N,2 vector. But I want to know what the two columns represent.
Thank you!

  0 Comments

Sign in to comment.

Accepted Answer

Jeff Miller
Jeff Miller on 1 Dec 2019
The two columns represent the two variables measured for each case, and the N rows represent the N randomly selected cases from this bivariate normal distribution. For example, the cases/rows might be analogous to people, and the variables/columns analogous to their heights and weights.

  4 Comments

Show 1 older comment
Jeff Miller
Jeff Miller on 2 Dec 2019
Yes, that's correct. You might have a look at the scattergram to make sure that the variables look like what you expect:
plot(X,Y,'*');
xlabel('X');
ylabel('Y');
Fissha Marye
Fissha Marye on 2 Dec 2019
Many thanks Jeff,
Could you explain about error: horizontal dimensions mismatch (1000x1 vs 499x1).
I am running the following code
X=2+5*w+e
Y=10+3*X+i
Now I want to use x and y to run an OLS and I save as a dtagrid using dataGrid = [Y X(:,1)]
data = importdata(filename,delimiterIn,headerlinesIn);
Y= data.data(:,1)
y_lab = data.colheaders{1}
x = [ones(N,1),data.data(:,2)]
x_lab = data.colheaders{2}
But I got the error message
horizontal dimensions mismatch (1000x1 vs 499x1). In my case I want to use N=1000

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags