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

Relax _gammalogccdf argument types not to be restricted to Float64 #161

Open
mashu opened this issue Sep 20, 2023 · 3 comments
Open

Relax _gammalogccdf argument types not to be restricted to Float64 #161

mashu opened this issue Sep 20, 2023 · 3 comments

Comments

@mashu
Copy link

mashu commented Sep 20, 2023

I am getting the following error when I am trying to use ForwardDiff with Turing to sample Truncated Poisson distribution.

ERROR: MethodError: no method matching _gammalogccdf(::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 8}, ::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 8}, ::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 8})
Stacktrace:
  [1] gammalogccdf(k::Int64, θ::Int64, x::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 8})

Which suggests that there is a problem with dispatch and perhaps types shouldn't be restricted to Float64.

@andreasnoack
Copy link
Member

The function branches on some values and is therefore written specifically for Float64. It would probably be better to introduce a derivative rule for gammalogccdf. In particular when you computing the derivative with respect to x since it's then just -gammapdf(..., x)/gammaccdf(..., x)

@mashu
Copy link
Author

mashu commented Sep 20, 2023

That would be great.

@mashu mashu closed this as completed Sep 20, 2023
@mashu mashu reopened this Sep 20, 2023
@mashu
Copy link
Author

mashu commented Sep 21, 2023

@andreasnoack so I tried to add the appropriate rule, but tests for frule and rrule fail.
For the code see master...mashu:StatsFuns.jl:master

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