Because the implementation of MH updates the random variables one at a time, the resulting chain is not ergodic for certain models and thus doesn't actually sample from the posterior distribution. Example:
(mh-query 100 100
(define bools (list (flip) (flip)))
bools
(not (equal? bools (list true false))
(equal? bools (list false true))) ;; -> will return samples only from either '(#t #t) or '(#f #f)
I ran this code on the probabilistic models of cognition book's website.
My quick suggestion for a fix: do a full state transition (every dimension) regularly in the beginning, then once you have an estimate for how many "components" the markov chain has, you can decide how often you want to do a full state transition after that.
Because the implementation of MH updates the random variables one at a time, the resulting chain is not ergodic for certain models and thus doesn't actually sample from the posterior distribution. Example:
I ran this code on the probabilistic models of cognition book's website.
My quick suggestion for a fix: do a full state transition (every dimension) regularly in the beginning, then once you have an estimate for how many "components" the markov chain has, you can decide how often you want to do a full state transition after that.