Skip to content

Commit 2af5b03

Browse files
committed
Remove redundant reimplementation in Weibull
1 parent 7ca4f31 commit 2af5b03

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pymc3/distributions/continuous.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,12 +2800,6 @@ def logcdf(self, value):
28002800
Compute the log of the cumulative distribution function for Weibull distribution
28012801
at the specified value.
28022802
2803-
References
2804-
----------
2805-
.. [Machler2012] Martin Mächler (2012).
2806-
"Accurately computing `\log(1-\exp(- \mid a \mid))` Assessed by the Rmpfr
2807-
package"
2808-
28092803
Parameters
28102804
----------
28112805
value: numeric
@@ -2822,7 +2816,7 @@ def logcdf(self, value):
28222816
return tt.switch(
28232817
tt.le(value, 0.0),
28242818
-np.inf,
2825-
tt.switch(tt.le(a, tt.log(2.0)), tt.log(-tt.expm1(-a)), tt.log1p(-tt.exp(-a))),
2819+
log1mexp(a),
28262820
)
28272821

28282822

@@ -3902,7 +3896,7 @@ def logcdf(self, value):
39023896
39033897
References
39043898
----------
3905-
.. [Machler2012] Martin Mächler (2012).
3899+
.. [Machler2012] c.
39063900
"Accurately computing :math: `\log(1-\exp(- \mid a \mid<))` Assessed by the Rmpfr
39073901
package"
39083902
@@ -3916,6 +3910,7 @@ def logcdf(self, value):
39163910
-------
39173911
TensorVariable
39183912
"""
3913+
# TODO: Check possible redundant (or improved) reimplementation of log1pexp
39193914
mu = self.mu
39203915
s = self.s
39213916
a = -(value - mu) / s

pymc3/math.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,19 @@ def log1pexp(x):
219219

220220

221221
def log1mexp(x):
222-
"""Return log(1 - exp(-x)).
222+
r"""Return log(1 - exp(-x)).
223223
224224
This function is numerically more stable than the naive approach.
225225
226226
For details, see
227227
https://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf
228+
229+
References
230+
----------
231+
.. [Machler2012] Martin Mächler (2012).
232+
"Accurately computing `\log(1-\exp(- \mid a \mid))` Assessed by the Rmpfr
233+
package"
234+
228235
"""
229236
return tt.switch(tt.lt(x, 0.6931471805599453), tt.log(-tt.expm1(-x)), tt.log1p(-tt.exp(-x)))
230237

0 commit comments

Comments
 (0)