Skip to content

Commit dc4ce4a

Browse files
committed
Small change to logcdf methods of DiscreteWeibull and ZeroInflated making use of tt.log1p and logaddexp.
More informative comment on workaround for `Poisson.logcdf`.
1 parent bcf87a2 commit dc4ce4a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: pymc3/distributions/discrete.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def logcdf(self, value):
614614
beta = self.beta
615615

616616
return bound(
617-
tt.log(1 - tt.power(q, tt.power(value + 1, beta))),
617+
tt.log1p(-tt.power(q, tt.power(value + 1, beta))),
618618
0 <= value,
619619
0 < q,
620620
q < 1,
@@ -727,7 +727,7 @@ def logcdf(self, value):
727727
"""
728728
mu = self.mu
729729
value = tt.floor(value)
730-
# To avoid issue with #4340
730+
# To avoid gammaincc C-assertion when given invalid values (#4340)
731731
safe_mu = tt.switch(tt.lt(mu, 0), 0, mu)
732732
safe_value = tt.switch(tt.lt(value, 0), 0, value)
733733

@@ -1612,7 +1612,7 @@ def logcdf(self, value):
16121612
psi = self.psi
16131613

16141614
return bound(
1615-
tt.log(1 - psi + psi * tt.exp(self.pois.logcdf(value))),
1615+
logaddexp(tt.log1p(-psi), tt.log(psi) + self.pois.logcdf(value)),
16161616
0 <= value,
16171617
0 <= psi,
16181618
psi <= 1,
@@ -1751,7 +1751,7 @@ def logcdf(self, value):
17511751
psi = self.psi
17521752

17531753
return bound(
1754-
tt.log(1 - psi + psi * tt.exp(self.bin.logcdf(value))),
1754+
logaddexp(tt.log1p(-psi), tt.log(psi) + self.bin.logcdf(value)),
17551755
0 <= value,
17561756
0 <= psi,
17571757
psi <= 1,
@@ -1920,7 +1920,7 @@ def logcdf(self, value):
19201920
psi = self.psi
19211921

19221922
return bound(
1923-
tt.log(1 - psi + psi * tt.exp(self.nb.logcdf(value))),
1923+
logaddexp(tt.log1p(-psi), tt.log(psi) + self.nb.logcdf(value)),
19241924
0 <= value,
19251925
0 <= psi,
19261926
psi <= 1,

0 commit comments

Comments
 (0)