Skip to content

Commit

Permalink
Added epsilon to numerator and denominator of Interval.forward
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Fonnesbeck committed Oct 7, 2016
1 parent a70187c commit 3cf5450
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pymc3/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,19 @@ class Interval(ElemwiseTransform):

name = "interval"

def __init__(self, a, b):
def __init__(self, a, b, eps=1e-6):
self.a = a
self.b = b
self.eps = eps

def backward(self, x):
a, b = self.a, self.b
r = (b - a) * tt.exp(x) / (1 + tt.exp(x)) + a
r = (b - a) / (1 + tt.exp(-x)) + a
return r

def forward(self, x):
a, b = self.a, self.b
r = tt.log((x - a) / (b - x))
a, b, e = self.a, self.b, self.eps
r = tt.log(tt.maximum((x - a) / tt.maximum(b - x, e), e))
return r

interval = Interval
Expand Down

0 comments on commit 3cf5450

Please sign in to comment.