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

truncated Normal with zero mean and std hangs #1942

Closed
markmbaum opened this issue Jan 25, 2025 · 3 comments
Closed

truncated Normal with zero mean and std hangs #1942

markmbaum opened this issue Jan 25, 2025 · 3 comments

Comments

@markmbaum
Copy link

markmbaum commented Jan 25, 2025

I know this is an unusual case, but I noticed that:

using Distributions
using Random

rng = Xoshiro(1)

rand(rng, truncated(Normal(0.0, 0.0), 0, Inf))

hangs and doesn't return a number.

I'm using Distributions v0.25.115 if that's relevant. Possibly related to #1910 but I don't know.

@vandenman
Copy link

I've been bitten by this before as well.

Looking at randnt we have tp equals 0.0 so it looks like this will go into an infinite while loop.

Perhaps the truncated normal should have some fallback like tp < eps(tp) && return mean(d)? Alternatively, Normal should require sd > 0.0 (most other distributions don't support degenerate distributions anyway), but that's breaking I guess.

@markmbaum
Copy link
Author

If other distributions don't support this kind of degenerate case I would encourage the same for the Normal. I don't think the eps solution is good because it introduces unexpected behavior. Maybe can slate it for the next larger release?

@quildtide
Copy link
Contributor

Duplicate with #1264, #1712, #1867

Would be fixed by #1721

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

4 participants