Curious issue generating truncated normals
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!