Open
Description
There's a bug in the ARS code that isn't apparent in the demo. Lines 86 and 91 of ars.m should be:
if log(U) <= lhVal - uhVal
and
elseif log(U) <= func(x, varargin{:}) - uhVal
respectively, since we are working with log probs. This issue doesn't show up in arsDemo because eventually the grid of points becomes so dense that they overlap, but if you do not retain the grid points from sample to sample the issue is readily apparent.
To reproduce the bug with the current code, change example 1 arsDemo.m to
nSamples = 20000;
sigma = 1;
fprintf(sprintf('drawing %i samples from a 1D gaussian\n',nSamples));
% Take one sample at a time
samples = zeros(nSamples,1);
for s = 1:nSamples
samples(s) = ars(func, a, b, domain, 1, sigma);
end
Metadata
Metadata
Assignees
Labels
No labels