Skip to content

Commit 7f2e3e7

Browse files
ricardoV94brandonwillard
authored andcommitted
Fix HalfCauchy/HalfCauchyRV parameterization
1 parent 2f42d72 commit 7f2e3e7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pymc3/distributions/continuous.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,14 +2259,10 @@ class HalfCauchy(PositiveContinuous):
22592259
@classmethod
22602260
def dist(cls, beta, *args, **kwargs):
22612261
beta = aet.as_tensor_variable(floatX(beta))
2262-
2263-
# mode = aet.as_tensor_variable(0)
2264-
# median = beta
2265-
22662262
assert_negative_support(beta, "beta", "HalfCauchy")
2267-
return super().dist([beta], **kwargs)
2263+
return super().dist([0.0, beta], **kwargs)
22682264

2269-
def logp(value, beta, alpha):
2265+
def logp(value, loc, beta):
22702266
"""
22712267
Calculate log-probability of HalfCauchy distribution at specified value.
22722268
@@ -2281,12 +2277,12 @@ def logp(value, beta, alpha):
22812277
TensorVariable
22822278
"""
22832279
return bound(
2284-
aet.log(2) - aet.log(np.pi) - aet.log(beta) - aet.log1p((value / beta) ** 2),
2285-
value >= 0,
2280+
aet.log(2) - aet.log(np.pi) - aet.log(beta) - aet.log1p(((value - loc) / beta) ** 2),
2281+
value >= loc,
22862282
beta > 0,
22872283
)
22882284

2289-
def logcdf(value, beta, alpha):
2285+
def logcdf(value, loc, beta):
22902286
"""
22912287
Compute the log of the cumulative distribution function for HalfCauchy distribution
22922288
at the specified value.
@@ -2302,8 +2298,8 @@ def logcdf(value, beta, alpha):
23022298
TensorVariable
23032299
"""
23042300
return bound(
2305-
aet.log(2 * aet.arctan(value / beta) / np.pi),
2306-
0 <= value,
2301+
aet.log(2 * aet.arctan((value - loc) / beta) / np.pi),
2302+
loc <= value,
23072303
0 < beta,
23082304
)
23092305

0 commit comments

Comments
 (0)