Skip to content
Snippets Groups Projects
Commit 768831bf authored by Gregory Ashton's avatar Gregory Ashton
Browse files

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

Adds bounds to power law prior

See merge request Monash/peyote!19
parents 45c79998 d63562bb
No related branches found
No related tags found
1 merge request!19Adds bounds to power law prior
Pipeline #
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment