No error for custom continuous distribution

15 views
Skip to first unread message

erdal.k...@gmail.com

unread,
Jan 24, 2020, 12:51:23 PM1/24/20
to webppl-dev
Hi all,
For the following inference:

var posterior = Infer({
  method
: "enumerate", model: function(){
 
var x = gaussian({mu: 0, sigma: 1})
 
return x
}})


I get this error message:

Gaussian({ mu: 0, sigma: 1 })
Enumerate can only be used with distributions that have finite support.


Which is telling me I cannot use a continuous distribution with enumerate.
However, when I simulate a continuous distribution using Math.rand(), there is no error message:

var posterior = Infer({
  method
: "enumerate", model: function(){
 
var x = Math.random()
 
return x
}})

Should there be an error or warning message?

null-a

unread,
Jan 24, 2020, 3:41:39 PM1/24/20
to webppl-dev
> Should there be an error or warning message?

Good question. Calling `Math.random` breaks one of the restrictions on calling out to JS functions:


It would be nice if we had an error/warning for this, but doing this for the general case is probably quite hard. Alternatively, perhaps we could maintain a list of the names of often called functions that don't work, and use that to generate warnings. (Though I guess it's unlikely this will be something that gets added anytime soon.)

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages