Skip to content

Commit

Permalink
Merge pull request #681 from TuringLang/mohamed82008-patch-1
Browse files Browse the repository at this point in the history
Fix #680
  • Loading branch information
mohamed82008 authored Feb 11, 2019
2 parents 0d5cf23 + 79a8c40 commit 1396ae2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ import StatsFuns: nbinomlogpdf
# Note the definition of NegativeBinomial in Julia is not the same as Wikipedia's.
# Check the docstring of NegativeBinomial, r is the number of successes and
# k is the number of failures
_nbinomlogpdf_grad_1(r, p, k) = sum(1 / (k + r - i) for i in 1:k) + log(p)
_nbinomlogpdf_grad_1(r, p, k) = k == 0 ? log(p) : sum(1 / (k + r - i) for i in 1:k) + log(p)
_nbinomlogpdf_grad_2(r, p, k) = -k / (1 - p) + r / p

nbinomlogpdf(n::Tracker.TrackedReal, p::Tracker.TrackedReal, x::Int) = Tracker.track(nbinomlogpdf, n, p, x)
Expand Down

0 comments on commit 1396ae2

Please sign in to comment.