Azzera filtri
Azzera filtri

Create a matrix with a specific correlation within a specific distribution

1 visualizzazione (ultimi 30 giorni)
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?

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by