danielkorzekwa / bayes-scala

Bayesian Networks in Scala
Other
205 stars 39 forks source link

truncate function of Gaussian seems not work #38

Open universewill opened 8 years ago

universewill commented 8 years ago

i use truncate function of Gaussian in bases-scala, but it seems not working the code:

val truncGaussian = dk.bayes.math.gaussian.Gaussian(0.5, 1).truncate(0.0, true) for(i<- 0 until 300000){ val d = truncGaussian.draw println(d) }

i plot the hist of sampled data draw from truncGaussian, and it is a Gaussian distribution with no truncation

danielkorzekwa commented 8 years ago

Gaussian().truncate() gives you the moments (mean and variance) of a truncated Gaussian, so then you just sample from a new Gaussian that approximates truncated Gaussian by moment matching.