sstucki / odds

Probabilistic programming in Scala
Other
34 stars 8 forks source link

Add distributions #5

Closed nightscape closed 8 years ago

nightscape commented 10 years ago

I added continuous uniform and normal distributions to RandOps. Is this the correct way to do it? If so I would add some more continuous distributions.

Best Martin

sstucki commented 10 years ago

Hi Martin,

sorry for the delay, I'm currently traveling so I haven't had time to properly review this PR earlier.

Unfortunately, the way you implemented the two continuous distributions won't work as expected for most inference methods. The reason is that the methods you added sample the distribution as they create random variables, rather than during the inference. E.g. a call to normal will generate a constant random variable taking the value returned by randomGenerator.nextGaussian with probability one, rather than a random variable with a normal distribution. This happens to work if you use simple rejection sampling to infer the distribution, but it will not give the expected result if you use e.g. exact inference.

Implementing proper support for continuously distributed variables in Odds will take some work (the current implementation contains support only for discrete distributions) and I haven't had the time to do it so far. Feel free to add an GitHub issue about that.

nightscape commented 8 years ago

Too old ;)