Curious issue generating truncated normals

4 vues (au cours des 30 derniers jours)
Patrick Rolande
Patrick Rolande le 13 Jan 2012
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)

Réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by