Hello,everyone! I am a rookie about pymc,and I’m trying to define a three-parameter log-logistic distribution in pymc.I have referred to the official documents in pymc3.But I have encountered a problem.This is my code:
from pymc3.distributions.dist_math import bound, logpow
import numpy as np
from scipy.stats import fisk
def loglogistic_logp(alpha,beta,r,value):
alpha_r_value=(value-r)/alpha
log_prob=np.log(beta/alpha)+logpow(alpha_r_value,beta-1)+logpow(1+alpha_r_value**beta,-2)
return log_prob
def loglogistic_rvs(alpha,beta,r,size):
return fisk.rvs(c=beta,loc=r,scale=alpha,size=size)
class CustomLogLogistic(pm.Continuous):
def init(self,alpha,beta,r,*args,**kwargs):
super(CustomLogLogistic,self).init(*args, **kwargs)
self.alpha=alpha
self.beta=beta
self.r=r
def logp(self,value):
alpha=self.alpha
beta=self.beta
r=self.r
return loglogistic_logp(alpha,beta,r,value)
def random(self,alpha,beta,r):
return fisk.rvs(c=beta,loc=r,scale=alpha,size=size)
then i tried this:
b=CustomLogLogistic.dist(beta=3.05,r=0,alpha=1).random()
print(b)
i got a error:
init() got an unexpected keyword argument ‘beta’
and i don’t know how to fix it.
English is not my native language, forgive me for my poor expression.
Thank you all!