Skip to content

Bug in ARS #84

Open
Open
@slinderman

Description

@slinderman

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions