Commit 768831bf authored by Gregory Ashton's avatar Gregory Ashton

Merge branch 'add-bounds-to-power-law' into 'master'

Adds bounds to power law prior

See merge request Monash/peyote!19
parents 45c79998 d63562bb
Pipeline #17454 passed with stages
in 4 minutes and 50 seconds
...@@ -145,15 +145,21 @@ class PowerLaw(Prior): ...@@ -145,15 +145,21 @@ class PowerLaw(Prior):
This maps to the inverse CDF. This has been analytically solved for this case. This maps to the inverse CDF. This has been analytically solved for this case.
""" """
if self.alpha == -1: 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: else:
return (self.low ** (1 + self.alpha) + val * return (self.low ** (1 + self.alpha) + val *
(self.high ** (1 + self.alpha) - self.low ** (1 + self.alpha))) ** (1. / (1 + self.alpha)) (self.high ** (1 + self.alpha) - self.low ** (1 + self.alpha))) ** (1. / (1 + self.alpha))
def prob(self, val): def prob(self, val):
"""Return the prior probability of val""" """Return the prior probability of val"""
return val ** self.alpha * (1 + self.alpha) / (self.high ** (1 + self.alpha) - if (val > self.low) and (val < self.high):
self.low ** (1 + self.alpha)) 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): class Cosine(Prior):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment