Curious issue generating truncated normals
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!