How do I declare correlation between a random variable with beta distribution and a random variable with normal distribution?
이전 댓글 표시
I have a random variable with beta distribution declared:
aux_alpha = 3;
aux_beta = 813.21;
LB = 41.368542; %lower bound
D = 1337.582858; %difference between upper bound and lower bound
alpha = aux_alpha+1;
beta = aux_beta+1;
aux_fy = betarnd(alpha,beta);
fy = aux_fy*D+LB;
And a random variable with normal distribution:
Ast_mean = Ast0*b*d;
Ast_std = 0.02*Ast_mean;
Ast = normrnd(Ast_mean,Ast_std);
There is a correlation of 0.5 between them. I'm trying to test it with the code:
nsam = 10000;
rhoij = 0.5;
y1 = normrnd(0,1,nsam,1);
y2 = normrnd(0,1,nsam,1);
RY = [1 rhoij;rhoij 1];
Jzy = chol(RY,'lower');
z1 = 0;
z2 = 0;
u1 = 0;
u2 = 0;
for sam = 1:nsam
zaux = Jzy*[y1(sam);y2(sam)];
z1(sam) = zaux(1);
z2(sam) = zaux(2);
u1(sam) = normcdf(z1(sam));
u2(sam) = normcdf(z2(sam));
x1_aux(sam) = betainv(u1(sam),alpha,beta);
x1(sam) = x1_aux(sam)*D+LB;
x2(sam) = norminv(u2(sam),Ast_mean,Ast_std);
end
rho = corrcoef(x1,x2)
But rho is not returning the correct correlation (0.5). Does anyone know how to solve this? I'm in doubt especially in the part where I use betainv().
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multivariate Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!