Open mhtess opened 8 years ago
Looks fine to me. The code below seems to work:
var hyperDist = Infer({method: "enumerate"}, function(){
return flip(.5) ? Beta({a:1,b:1}) : Beta({a:0.01,b:0.01})
});
expectation(Infer({method: "rejection", samples: 5000}, function(){
var dist = sample(hyperDist);
return sample(dist);
}));
Are you looking for something else?
Hm. I get not implemented
Oh, you're right—I wasn't running the test on the public version of webppl. It would definitely be possible to make this work, e.g. by providing a toJSON
function for continuous distributions.
Note that this already works:
Infer({method: "enumerate"}, function(){
return flip(.5) ? Bernoulli({p: .5}) : Bernoulli({p: .7});
});
Maybe we could serialize continuous distributions (and, say, variational programs; #27) as computation graphs in JSON.
For example, is something like this ever conceivable?