grinsted / gwmcmc

An implementation of the Goodman & Weare MCMC sampler for matlab
Other
51 stars 24 forks source link

Question about rejection #9

Open Peku995 opened 1 year ago

Peku995 commented 1 year ago

Hello, I have a question concering the rejection criterium. In the case of non-parallel, in line 213, namely if logrand(1,wix)<(numel(proposedm(:,wix))-1)*log(zz(wix)) and line 216, namely if logrand(fix+1,wix)>proposedlogP(fix)-curlogP(fix,wix) || ~isreal(proposedlogP(fix)) || isnan(proposedlogP(fix))

how did you come up with these lines? I could not find them in the original publication. This would help me a lot.

grinsted commented 1 year ago

I have pretty much moved away from matlab, so it has been a while since i looked at it. So this answer comes without looking at the code or the paper - here what i think i must have been doing:

1) You can cascade acceptance/rejection criteria (the looping of if's). The gist of the idea is in the "modification of random walks" section of this paper: https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94JB03097
2) using logarithms on both sides of the inequality. 3) treat the probability as 0 outside the support of the function (hence the isreal and isnan)

I hope this helps.

Peku995 commented 1 year ago

thank you very much for the quick answer! i have one more question, which i hope is not too obvious. If I understand correctly, the Goodman and Weare algorithm is used to determine random new points, and the criterion for determining whether the new points are accepted or not is based on the the paper you mentioned above, is that correct?