Problem with evaluation of parameters of gumbel distribution

In the following code, i am trying to evaluate the parameters of a gumbel distribution using PyMC3.
The data is annual_maxima_1 and the method works for MLE but i could not make any conclusions regarding the results of PyMC3.

Any suggestions. ?? with the code below.

import numpy as np
from scipy.stats import gumbel_r
import pymc3 as pm
import arviz as az

#%%
#1. Data
annual_maxima_1 = np.array([5.41,6.89,6.10,5.72,7.91,10.45])
#%%frequentistic statistics

#%using MLE methods for parameter estimation

#fitting the gumbel distribution
loc1, scale1 = gumbel_r.fit(annual_maxima_1)
mean, var, skew, kurt = gumbel_r.stats(loc=loc1, scale=scale1,moments=‘mvsk’)

#%%now doing bayesian using Pymc3

#%%
with pm.Model() as model:
# Define the prior of the parameter lambda.
mu = pm.Uniform(‘mu’)
beta=pm.Uniform(‘beta’)

# Define the likelihood function.
y_obs = pm.Gumbel('y_obs', mu=mu, beta=beta, observed=annual_maxima_1)

# Tracing
trace = pm.sample(draws=1000, chains=5, cores=1)
mu_trace=trace.get_values(varname="mu", burn=100)
sd_trace=trace.get_values(varname="beta", burn=100)

trace_dataframe=pm.backends.tracetab.trace_to_dataframe(trace)

You probably did not mean mu and beta to be pm.Uniform('mu', lower=0, upper=1) which are the default parameters if you just use pm.Uniform('mu'). If you want a non informative prior you should use pm.Flat, or increase the lower and upper bounds of pm.Uniform to include any plausible values.

1 Like

thanks for the reply .
Thanks for pointing that out, i am considerably new to the PyMC3 environment/code/syntax but not to bayesian.

I can make two different analysis,
1-Non informative
2-with uniform distribution

Please check if the following code is correct for the two cases.

1-Non informative
mu = pm.Flat(‘mu’)
beta=pm.Flat(‘beta’)

2-with uniform distribution
mu = pm.Uniform(‘mu’, lower=0, upper=10)
beta=pm.Uniform(‘beta’, lower=0, upper=5)

I guess you got my original idea, i am i trying to fit distribution parameters(mu, beta) for Gumbel given data.
Feel free to make further suggestion, thanks for the reply .

ATS

Is there any specific problem you are finding with the new priors?

I have a groundwater level, which apply force on the structure.
A lot of research indicates that maximum yearly water levels can be modelled as gumbel distribution.
I have some maximum values from last 6 years.
I want to fit these 6 or some more values/data to find the parameters of the underlining gumbel distribution.

Regards
Ats

Your initial example with the right priors should get you started.

I don’t have specific advice to give you as I don’t have experience on the specific topic.

You might want to browse our gallery examples to see if you find something helpful in there: examples_notebooks — PyMC3 3.10.0 documentation