I'm porting my BLOG models (
http://hakank.org/blog_ppl/ ) to webppl and so far it has gone quite easy. webppl has a lot of nice features and I like it very much.
I thought it would be easy, but in order to use observe() the height (a Gaussian). one has to use the
"proper" distributions (i.e. "Gaussian" and not "gaussian"), And here is
where I'm stuck with how to define and use "height" and "gender".
Below my model in webppl and it's not correct. I've tried a couple of variants but all of them give errors or strange results.
"""
var model = function() {
var genderList = ["male","female"];
var gender = function() {
return Categorical({ps:[0.5,0.5],vs:genderList});
};
var g = gender();
var height = function() {
if (sample(gender()) == "male") {
return Gaussian({mu:181.5,sigma:50})
} else {
return Gaussian({mu:166.8,sigma:50});
}
};
var h = height();
// condition(height=="female");
// observe(h,160.0);
return {
height:h,
gender:g
};
}
var d = Infer(model);
"""
Running it yield the non-informative "Not implemented" error:
"""
Error: Not implemented
at /home/hakank/.nvm/versions/node/v10.22.0/lib/node_modules/webppl/src/dists/base.js:10
9| toJSON: function () {
10| throw new Error('Not implemented');
--------------^
11| },
at gender_height2.wppl:41
40|
41| var d = Infer(model);
"""
So, what is the best way of modeling this problem in webppl, including observing either the height or gender?
Best regards
Hakan