diff --git a/peyote/prior.py b/peyote/prior.py index ff69acd292c6a361ed410a196d525223d903b8fb..1ef3a098306fa8485cac2ec43aa3380b5cd915a7 100644 --- a/peyote/prior.py +++ b/peyote/prior.py @@ -145,15 +145,21 @@ class PowerLaw(Prior): This maps to the inverse CDF. This has been analytically solved for this case. """ if self.alpha == -1: - return self.low * np.exp(val * np.log(self.low / self.high)) + return self.low * np.exp(val * np.log(self.high / self.low)) else: return (self.low ** (1 + self.alpha) + val * (self.high ** (1 + self.alpha) - self.low ** (1 + self.alpha))) ** (1. / (1 + self.alpha)) def prob(self, val): """Return the prior probability of val""" - return val ** self.alpha * (1 + self.alpha) / (self.high ** (1 + self.alpha) - - self.low ** (1 + self.alpha)) + if (val > self.low) and (val < self.high): + if self.alpha == -1: + return 1 / val / np.log(self.high / self.low) + else: + return val ** self.alpha * (1 + self.alpha) / (self.high ** (1 + self.alpha) + - self.low ** (1 + self.alpha)) + else: + return 0 class Cosine(Prior):