JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected behavior of `truncated` for zero variance distributions at the lower bound

HakanBrian opened this issue · comments

When truncating a Normal distribution with zero variance and mean equal to the lower bound of the truncated, evaluating rand will result in infinite compilation time. An equivalent operation with the upper bound of the truncated will return the value for the upper bound as expected.

Example:

using Distributions

rand(truncated(Normal(1, 0), 0, 1))  # Expected output: 1
rand(truncated(Normal(0, 0), 0, 1))  # Expected output: 0

# Note that when the expected output is 0 we get infinite compilation time.

At a surface level, this sounds closely related to #1264 and #1712 to me.

#1721 should help resolve this, I think.

Yes, you are right. #1721 will resolve this issue.