Open universewill opened 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
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.
i use truncate function of Gaussian in bases-scala, but it seems not working the code:
i plot the hist of sampled data draw from truncGaussian, and it is a Gaussian distribution with no truncation