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

Open
markmbaum opened this issue Jan 25, 2025 · 1 comment
Open

truncated Normal with zero mean and std hangs #1942

markmbaum opened this issue Jan 25, 2025 · 1 comment

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.

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