Create a matrix with a specific correlation within a specific distribution
1 view (last 30 days)
Show older comments
I am creating matrices of random variables within the normal, uniform, and chi square distributions. However, I need to be able to specify the correlation value of the matrices.
rowsize = 10;
columnsize = 3;
dg = 2;
correlation_value = 0.7;
matrix = zeros(rowsize, columnsize);
for row = 1:rowsize
for column = 1:columnsize
matrix(row, column) = chi2rnd(dg);
end
end
correlatedMatrix = SomeFunction(matrix, correlation_value);
result = corr(correlatedMatrix)
result =
1.0000 0.7000 0.7000
0.7000 1.0000 0.7000
0.7000 0.7000 1.0000
Is there a function or some code to replace
correlatedMatrix = SomeFunction(...)
or a function or code to replace the call to chi2rnd(dg) where result will still be within the chi square distribution?
0 Comments
Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!