How to insert correlation co-efficient matrix between variables following normal distribution in matlab?
5 次查看(过去 30 天)
显示 更早的评论
Let, there be two variables, amax, maximum value of horizontal ground acceleration and mw, magnitude of an earthquake required to find out CSR, cyclic stress ratio, a term related to liquefaction. Both of these variables follow normal random distribution and the correlation coefficient between them is 0.9. I have defined the two concerned variables as uncorrelated ones in the following manner,
amax=normrnd(mean,standard deviation,no. of rows,no. of columns); mw=normrnd(mean,standard deviation,no. of rows,no. of columns);
normrnd is a command in the matlab to generate a normal distribution of given size, for a particular value of mean and standard deviation.
For each of these values I found out corresponding CSR values through an empirical formula. Suggest me how to insert the correlation co-efficient matrix(symmetric) of order 2x2 in a matlab program along with the definitions of these two variables.
0 个评论
采纳的回答
Aniruddha Katre
2014-8-19
It seems like you want to generate two normally distributed random variables with correlation of 0.9. You can use the function "mvnrnd" from the statistics toolbox.
mu = [2 3]; % Vector of means. mean of amax is 2 and mean of mw is 3
sig = [1 0.9;0.9 1]; % Covariance matrix. Correlation is 0.9
nPts = 50; % Number of points you want to generate for each random variable
rVec = mvnrnd(mu,sig,nPts); % Generate the correlated random variables
Then you can extract "amax" and "mw" from "rVec":
amax = r(:,1);
mw = r(:,2);
And you can check the correlation between the two variables using the "corr" function and ensure that it is approximately 0.9
corr(amax,mw)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!