Sampling Error: GEV PyMC3

Hi @ccaprani ,
Again here for some queries. Could start a new thread if you wish.
So it was decided to put on hold the incorporation of GEV to v.4. I checked PYMC experimental, but it’s missing there as well.
I was trying to run the custom distribution in v.4 but get some errors. Here is my code:

def gev_logp(value,μ  ,  σ,  ξ):
        scaled = (value - μ ) /  σ
        logp_xi_not_zero = -(at.log( σ)
                 + (( ξ + 1) /  ξ) * at.log1p( ξ * scaled)
                 + (1 +  ξ * scaled) ** (-1/ ξ))
        logp_xi_zero = -at.log( σ) + ( ξ+1)*(-(value - μ )/ σ) - at.exp(-(value - μ )/ σ)
        logp = at.switch(at.abs_( ξ) > 1e-4  , logp_xi_not_zero, logp_xi_zero) 
        return at.sum(logp)

with pm.Model() as model:
    μ = pm.Normal("μ", mu=1, sigma=100)
    σ= pm.Normal("σ",mu=1, sigma=100)
    ξ= pm.Beta("ξ",alpha=6, beta=9)
    gev = pm.DensityDist( "gev", logp= gev_logp, observed = {'value':data, 'μ':μ, 'σ':σ, 'ξ':ξ})
    idata = pm.sample(1000, tune=1500)
TypeError: float() argument must be a string or a real number, not 'dict'

I guess there might be some issues with the aesara tensor here?

DensityDist no longer accepts a dictionary for observed in v4

@ricardoV94 Thanks, got it.
I simply changed the variable value in gev_logp function to data and modified the code as:

gev = pm.DensityDist( "gev", μ, σ, ξ, logp= gev_logp, observed = data)
1 Like