Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate function of Gaussian seems not work #38

Open
universewill opened this issue Jul 8, 2016 · 1 comment
Open

truncate function of Gaussian seems not work #38

universewill opened this issue Jul 8, 2016 · 1 comment

Comments

@universewill
Copy link

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants