Skip to content

Commit fd11cf0

Browse files
velochyricardoV94
authored andcommitted
Use more numerically stable function in truncatenormal area computation
1 parent 05b557f commit fd11cf0

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

pymc/distributions/continuous.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,7 @@ def logp(value, mu, sigma, lower, upper):
706706
is_upper_bounded = not (isinstance(upper, TensorConstant) and np.all(np.isinf(upper.value)))
707707

708708
if is_lower_bounded and is_upper_bounded:
709-
lcdf_a = normal_lcdf(mu, sigma, lower)
710-
lcdf_b = normal_lcdf(mu, sigma, upper)
711-
lsf_a = normal_lccdf(mu, sigma, lower)
712-
lsf_b = normal_lccdf(mu, sigma, upper)
713-
norm = pt.switch(lower > 0, logdiffexp(lsf_a, lsf_b), logdiffexp(lcdf_b, lcdf_a))
709+
norm = log_diff_normal_cdf(mu, sigma, upper, lower)
714710
elif is_lower_bounded:
715711
norm = normal_lccdf(mu, sigma, lower)
716712
elif is_upper_bounded:

0 commit comments

Comments
 (0)