Why using 1/x in pdf and cdf of Gamma class
Closed this issue · 1 comments
In the GammaExponential class, why do you take 1/x for pdf and cdf methods?
def pdf(self, x):
return stats.gamma.pdf(1.0/x, self.alpha, scale=1.0/self.beta)
def cdf(self, x):
return 1-stats.gamma.cdf(1.0/x, self.alpha, scale=1.0/self.beta)
It looks like you are using the standard Gamma PDF definition with alpha and beta. This is exactly equal to the Gamma pdf in scipy if you set scale=1/Beta, as you do above. So it seems wrong to take the reciprocal of x for pdf and cdf calculation (and also to define cdf as 1-gamma.cdf).
It's been a long time since I wrote this class, however - if I recall, the motivation - is using the expectency and not the decay rate.
The conjugate prior formula on the wikipedia page refers to updating the parameters based on the lambda
(decay rate) parameter, but I implemented the cdf and pdf functions on the expectency (1/lambda
in the Exponential distribution) which is easier to reason about.