I'm trying to create a beta RV that behaves like the one in scipy. Namely, it takes an alpha
, beta
, loc
, and scale
. I followed the discussion on creating a shifted gamma, and came up with something that looks like this:
import pymc3 as pm
class SSBeta(pm.Beta):
def __init__(self, alpha, beta, loc, scale, *args, **kwargs):
# Not sure what this is doing but it won't work without it.
transform = pm.distributions.transforms.lowerbound(loc)
super().__init__(alpha=alpha, beta=beta, *args, **kwargs, transform=transform)
self.scale = scale
self.loc = loc
self.mean += loc
def random(self):
return super().random()*self.scale + self.loc
def logp(self, x):
return super().logp((x - self.loc)/self.scale)
So I have two questions:
- Is this implementation correct (
random
,logp
)? - What's the purpose of the transform at the top of the class? I can't find anything useful in the docs and the code didn't help a ton.