probmods / webchurch

A Church to Javascript compiler (DEPRECATED)
Other
140 stars 15 forks source link

mh-query samples deterministically #64

Closed gokererdogan closed 10 years ago

gokererdogan commented 10 years ago

Mh-query behaves deterministically when sampling from the below simple model. When I mh-query the below simple model (a single random variable with uniform distribution on (x, y)), the samples are all x or y when lag is even, and samples alternate between x and y when lag is odd.

(define samples1 (mh-query 10 100 (define a (if (flip 0.5) 'x 'y)) a (condition true)))

(define samples2 (mh-query 10 101 (define a (if (flip 0.5) 'x 'y)) a (condition true)))

samples1 samples2

juliusc commented 10 years ago

This is actually a funny case of the MCMC inference engine. There are only two paths of execution, both with equal probability. If the state is path #1, then it proposes path #2, and it happens that the acceptance rate is 100%. Therefore, the sequence for this program is always (x y x y ...) or (y x y x ...). If you were to, say, change the (flip) parameters to, say, .51, you won't see this behavior.