3

I've been trying to use scipy.stats.genextreme to fit my data to the generalized extreme value distribution. I've tried all of the methods that I could find, but I don't know why it won't fit the data.

I've tried both these methods:

import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import genextreme as gev

dataN = [0.0, 0.0, 0.122194513716, 0.224438902743, 0.239401496259, 0.152119700748, 
         0.127182044888, 0.069825436409, 0.0299251870324, 0.0199501246883, 0.00997506234414, 
         0.00498753117207, 0.0]

t = np.linspace(1,13,13)
fit = gev.fit(dataN,loc=3)
pdf = gev.pdf(t, *fit)
plt.plot(t, pdf)
plt.plot(t, dataN, "o")
print(fit)

as well as

popt, pcov = curve_fit(gev.pdf,t, dataN)
plt.plot(t,gev.pdf(*popt),'r-')

This is the result I got for the first one

The second method resulted in this

" ValueError: Unable to determine number of fit parameters."

Thanks for any help that you can give me!

2

According to the scipy.stats documentation at:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.genextreme.html

the fit() method uses the raw data, and it looks like you are passing the binned histogram data in your call to:

fit = gev.fit(dataN,loc=3)

Try passing in the raw data to see if it works as you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.