Curious issue generating truncated normals

조회 수: 4 (최근 30일)
Patrick Rolande
Patrick Rolande 2012년 1월 13일
I try two ways of generating truncated multivariate normals below, which give different results. I'd be interested if anyone could shed light on why this might be. In the code I generate bivariate normal draws with variance c*c', where c=[1 0;1 2], truncated above at (-2,-2).
In the first case, I use simple accept reject sampling. In the second, I sequentially draw truncated normals (this is explained here, for example: http://www.hss.caltech.edu/~mshum/gradio/ghk_desc.pdf).
The means are consistently different. The first variable has a mean of around -2.41 with accept reject and -2.37 with sequential sampling. This seems peculiar to me - any ideas?
u = [-2 -2];
trials = 10000;
c = [1 0;1 2];
i=0;
AR = zeros(trials,2);
while i < trials
t = c*normrnd(0,1,2,1);
if t' <= u
i=i+1;
AR(i,:) = t';
end
end
mean(AR)
GHK = zeros(trials,2);
for i=1:trials
r1 = norminv(rand*normcdf(u(1)/c(1,1)));
r2 = norminv(rand*normcdf((u(2)-c(2,1)*r1)/c(2,2)));
GHK(i,:) = (c*[r1;r2])';
end
mean(GHK)

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by