MATLAB: How to generate correlated random sources drawn i.i.d from an arbitrary joint distribution in matlab

correlated samplescorrelation coeffi...correlation coefficientjoint distributionrandom binary sourcesrandom number generatorstatistics

Hi guys, In my system model, I need to generate some group of binary correlated files in a way that, there is no correlation between different groups but there is correlation within each group. and I don't require to have a fix correlation coefficient, it can be varied in each group of files if it helps. so I need to generate some correlated random sources with a joint distribution for each group while members of each group are not correlated with the other groups. Would you please guide me to understand how can I do that? Any help is appreciated

Best Answer

m = 1000000; % size of the files
% 2 groups
% group1 3 files
C12 = 0.2;
C23 = 0.2;
C13 = 0.2;
G1 = [1 C12 C23;
C12 1 C13;
C13 C23 1];
% group2 2 files
C12 = 0.3;
G2 = [1 C12;
C12 1];
M = blkdiag(G1,G2);
M = 1.5*M; % empirical correction
n = size(M,1);
M(1:n+1:end) = 1;
% Xbin is m x n, each column is the binary file content
C = chol(M) / sqrt(2);
Xbin = erf(randn(m,n)*C + 1) > 0.5;
corrcoef(Xbin)