Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in ARS #84

Open
slinderman opened this issue Apr 25, 2014 · 0 comments
Open

Bug in ARS #84

slinderman opened this issue Apr 25, 2014 · 0 comments

Comments

@slinderman
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant