probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link

incorrect labels when using viz.marginals(dist, options) ? #66

Closed CMoebus closed 7 years ago

CMoebus commented 7 years ago

Hi Viz-developers, I want to plot the marginals of a bivariate density. The code is below. Each marginal density plot has a title "mu" and "sigma", but the x-axis is still called "(state)". This is not what I wanted. The x-axis labels should be "mu" and "sigma". Claus

var start_time = Date.now()
var nsamples = 200
var my_precision = 0.001
var sigmaOfMu = Math.sqrt(1.0/my_precision)
print("sigmaOfMu = "); print(sigmaOfMu)
var model = function(){
  var my_mu = sample(Gaussian({mu: 0, sigma: sigmaOfMu}))
  var my_sigma = sample(Uniform({a:0.0, b:10.0}))
  observe(Gaussian({mu: my_mu, sigma: my_sigma}), 1.1)
  observe(Gaussian({mu: my_mu, sigma: my_sigma}), 1.9)
  observe(Gaussian({mu: my_mu, sigma: my_sigma}), 2.3)
  observe(Gaussian({mu: my_mu, sigma: my_sigma}), 1.8)
  return {mu: my_mu, sigma: my_sigma}
}
var posterior = Infer({method: 'rejection', samples: nsamples, maxScore: -2.32}, model)
viz.marginals(posterior, {xLabel: "mu", yLabel: 'sigma'})