Skip to content

Commit

Permalink
pdfs.GammaPdf: fix support, 0.0 is not included
Browse files Browse the repository at this point in the history
  • Loading branch information
strohel committed Aug 20, 2012
1 parent 9360a1c commit fc95362
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions pybayes/pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,8 @@ def variance(self, cond = None):

def eval_log(self, x, cond = None):
self._check_x(x)
if x[0] < 0.:
if x[0] <= 0.:
return float('-inf')
if x == 0.:
if self.k == 1:
return -math.lgamma(self.k) - self.k*math.log(self.theta)
else:
return -math.lgamma(self.k) - self.k*math.log(self.theta) + (self.k - 1)*float('-inf')
return -math.lgamma(self.k) - self.k*math.log(self.theta) + (self.k - 1)*math.log(x[0]) - x[0]/self.theta

def sample(self, cond = None):
Expand Down
2 changes: 1 addition & 1 deletion pybayes/tests/test_pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def test_variance(self):
def test_eval_log(self):
exp_results = np.array([
[0. , 0. ], # eval in -1
[0.3125 , 0. ], # in 0
[0. , 0. ], # in 0
[0.2286298840458256, 0.0231977161187639], # in 1
[0.1672691964121845, 0.0921648960588247], # in 2
[0.1223767583364997, 0.1500982961404964], # ...
Expand Down

0 comments on commit fc95362

Please sign in to comment.