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

TuringDirichlet returns non-zero pdf or error outside support #158

Closed
fernando-duarte opened this issue Mar 30, 2021 · 5 comments
Closed

Comments

@fernando-duarte
Copy link

(moving over from #157 since it seems different enough)

The pdf of TuringDirichlet is not zero for points outside the support, and gives an error for points with negative coordinates.

using Pkg
Pkg.add(Pkg.PackageSpec(name="Distributions", version="0.24.15"))
Pkg.add(Pkg.PackageSpec(url="https://github.com/TuringLang/DistributionsAD.jl", rev="master"))
using Distributions, DistributionsAD

# test pdf of Dirichlet distribution
α = [0.43,0.21]
d = Distributions.Dirichlet(α)
Turing_d = DistributionsAD.TuringDirichlet(α)

x_not_sup = [0.5,0.8] # a point not in the support
x_neg = [-0.5,1.5] # a point not in the support with a negative entry

# Distributions.jl has the desired behavior
Distributions.pdf(d,x_not_sup) # returns 0.0
Distributions.pdf(d,x_neg)  # returns 0.0

# DistributionsAD.jl gives a different answer
DistributionsAD.pdf(Turing_d,x_not_sup) # a non-zero number
DistributionsAD.pdf(Turing_d,x_neg) # throws an error

Thanks!
Fernando

@fernando-duarte
Copy link
Author

Hi! Wondering if this issue made sense or if I should provide more info.

Does it look somewhat easy to solve so that it makes sense that I wait for a fix? Or should I try to figure out a way around it assuming it is not fixable in a reasonable amount of time?

Thanks!

@fernando-duarte
Copy link
Author

Hi, wondering if there are any updates regarding a fix or if I should try to find another package or way to do it without DistributionsAD.jl.
Thank you.

@yebai
Copy link
Member

yebai commented Jun 2, 2021

Thanks, @fernando-duarte for raising this issue. @torfjelde Could you take a look at this issue, please?

@yebai
Copy link
Member

yebai commented Jun 3, 2021

Fixed by #173. The fix will become available after JuliaRegistries/General#38066 is merged.

@yebai yebai closed this as completed Jun 3, 2021
@fernando-duarte
Copy link
Author

Thank you very much!

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