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

Fallbacks for betapdf should respect support of input #44

Closed
wants to merge 1 commit into from

Conversation

bdeonovic
Copy link

Ran into this issue where behavior of fallback betapdf doesn't match that from Rmath

Main> T = ForwardDiff.Dual{nothing,Float64,9}
ForwardDiff.Dual{nothing,Float64,9}

Main> a = ForwardDiff.Dual{nothing}(6.4939207766474265,0.8357436393299081,1.3579354055156831,-1.3555982865121416,1.160498244824507,-2.079327009825812,0.004863844970181275,-0.25727952518133534,-2.2389294116926743,-10.5166484082746)
Dual{nothing}(6.4939207766474265,0.8357436393299081,1.3579354055156831,-1.3555982865121416,1.160498244824507,-2.079327009825812,0.004863844970181275,-0.25727952518133534,-2.2389294116926743,-10.5166484082746)

Main> b = ForwardDiff.Dual{nothing}(232.02099155052173,323.55948699129425,490.7620357655114,-690.2228324218437,441.6711726841804,-1149.8624174807328,-1831.3399060164832,-9.586679718153569,-608.3911976640888,-2973.826015588245)
Dual{nothing}(232.02099155052173,323.55948699129425,490.7620357655114,-690.2228324218437,441.6711726841804,-1149.8624174807328,-1831.3399060164832,-9.586679718153569,-608.3911976640888,-2973.826015588245)

Main>

Main> logpdf(Beta(a.value,b.value), -1.2)
-Inf

Main> logpdf(Beta{T}(a,b), T(-1.2))
ERROR: DomainError:
log will only return a complex result if called with a complex argument. Try log(complex(x)).
Stacktrace:
 [1] nan_dom_err at .\math.jl:300 [inlined]
 [2] log at .\math.jl:419 [inlined]
 [3] log at C:\Users\deonovib\.julia\v0.6\ForwardDiff\src\dual.jl:167 [inlined]
 [4] betalogpdf(::ForwardDiff.Dual{nothing,Float64,9}, ::ForwardDiff.Dual{nothing,Float64,9}, ::ForwardDiff.Dual{nothing,Float64,9}) at C:\Users\deonovib\.julia\v0.6\StatsFuns\src\distrs\beta.jl:19
 [5] logpdf(::Distributions.Beta{ForwardDiff.Dual{nothing,Float64,9}}, ::ForwardDiff.Dual{nothing,Float64,9}) at C:\Users\deonovib\.julia\v0.6\Distributions\src\univariates.jl:540
 [6] eval(::Module, ::Any) at .\boot.jl:235

@ararslan
Copy link
Member

It would be great if you could add a test for the new functionality.

@bdeonovic
Copy link
Author

I just noticed that these changes are included on branch promotions. Along with a host of other updates as well. So I assume I should go ahead and close this assuming that branch will be merged at some point?

@devmotion
Copy link
Member

This was fixed by #125 which was released in StatsFuns 0.9.11.

@devmotion devmotion closed this Sep 29, 2021
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

Successfully merging this pull request may close these issues.

3 participants