Closed longouyang closed 10 years ago
Seems to have to do with init: the non 'a samples are always at the beginning.
I think I figured it out. Currently, we use "lessdumb" initialization, which interleaves rejection with enumeration.
The enumeration was messing up because the nextVal
function for flips (inside probjs) isn't quite correct for cases where the weight is 0 or 1.
I'll land a fix for this soon in probjs.
Note to self: a similar affliction affects nextVal
for multinomials.
(define samps
(mh-query
1 1
(define x (uniform-draw '(a b c d e f)))
x
(multinomial '(#t #f)
(if (equal? x 'a)
'(1 0)
'(0 1)))))
(first samps)
Fixed in db61bc5fb5e753f4626b526b06c386a623c96fb6.
In the code below, we randomly sample a letter from the set
(a b c d e)
and then condition (in a baroque fashion) on it being equal toa
. In particular, we condition on a flip whose weight is 1 fora
and 0 otherwise.If you run this code a few times, you'll find that sometimes you'll get samples that are not
a
. What is going on here?