Infer returns dist object, not the distribution

48 views
Skip to first unread message

Hakan Kjellerstrand

unread,
Aug 20, 2020, 3:29:40 PM8/20/20
to webppl-dev
Some months ago I started to learn webbpl but after a while realized that I had to brush up my JavaScript skills so I haven't done much webppl since then.

However, today I started to test some webppl models that worked before but don't work as expected anymore. For example the following simple binomial model:
""""
var binomial = function() {
      var a = sample(Bernoulli({ p: 0.5 }))
      var b = sample(Bernoulli({ p: 0.5 }))
      var c = sample(Bernoulli({ p: 0.5 }))
      return a + b + c
}
var binomialDist = Infer({ model: binomial })
display(expectation(binomialDist)) display(binomialDist)
"""

Before it printed the following:
 $ webppl binomial.wppl
"""
Marginal:
     1 : 0.3750000000000001
     2 : 0.3750000000000001
     0 : 0.12500000000000003
     3 : 0.12500000000000003
"""

However, now it displays just the dist object:
 $ webppl binomial.wppl
"""
dist {
    params: {
      dist: { '0': [Object], '1': [Object], '2': [Object], '3': [Object] } },
     supp: [ 0, 1, 2, 3 ],
     getDist: [Function (anonymous)]
}
"""

Note that some functions works, such as expectation for the model above:
"""
    display(expectation(binomialDist))
"""
It prints 1.5000000000000004

I'm running everything in a LInux Ubuntu 18.04 LTS machine.

* webppl version:
HEAD v0.9.15-258938e /home/hakank/.nvm/versions/node/v14.5.0/lib/node_modules
  U
/webppl
* node version: v14.5.0
  /home/hakank/.nvm/versions/node/v14.5.0/bin/node

As indicated, I've installed webppl with
    $ npm install -g webppl

and using nvm for setting the node.js version.

When playing JavaScript I did a lot of things such as installing different versions of node.js, installed a lot of different npm modules etc, so the environment is not at all the same as when I first tested webppl.  So I must have done some weird stuff...

Does anyone know how to restore a working version/environment? Have I forgot to install some packages or just done some newbie mistake in my model?

Best regards,

Hakan

null-a

unread,
Aug 20, 2020, 3:48:56 PM8/20/20
to webppl-dev
I wonder if you're running into this:


If so, reverting to an earlier version of Node might be the easiest solution.

Hakan Kjellerstrand

unread,
Aug 20, 2020, 4:56:58 PM8/20/20
to webppl-dev
Ah, yes reverting to node.js version v10.22.0 works. Thanks for the tip.  (I thought I tested this but must have missed something.)

Do you if there are any later version than v10.22.0 of node.js that works with webppl regarding this problem?

Best,

Hakan

null-a

unread,
Aug 20, 2020, 5:29:40 PM8/20/20
to webppl-dev
Great. I don't recall anything beyond what's mentioned in the issue I linked to. So, it sounds like the v11 series might work, but I'm not sure.

Hakan Kjellerstrand

unread,
Aug 21, 2020, 2:47:42 AM8/21/20
to webppl-dev
I tested node.js v11.0.0 and v11.15.0. Both have the same problems displaying distributions as reported above.
So I'll settle with v10.22.0.

Thanks for your help!

/Hakan

null-a

unread,
Aug 21, 2020, 4:43:15 AM8/21/20
to webppl-dev
No problem! Thanks for letting us know which versions worked.
Reply all
Reply to author
Forward
0 new messages