[SciPy-User] Problems with fitting Weibell distribution

Warren Weckesser warren.weckesser at gmail.com
Mon Jan 5 07:40:08 EST 2015


On Mon, Jan 5, 2015 at 7:27 AM, Alun (Griffin PC) <alun at griffinpc.co.uk>
wrote:

>  Hi
>
> I am trying to fit a Weibull distribution to some data, with the following
> code:
>
> # Python script to fit metocean data
>
> import scipy.stats as s
> import numpy as np
> import matplotlib.pyplot as plt
>
> # Load data
>
> data = np.loadtxt("meteo.prn",skiprows=1,usecols=(4,))
>
> # Fit data
>
> p0, p1, p2, p3 = s.exponweib.fit(data, floc=0)
>
> # Plot data
>
> x = np.linspace(data.min(), data.max(), 1000)
> y = s.exponweib(p0, p1, p2, p3).pdf(x)
>
> plt.plot(x, y)
> plt.hist(data, data.max(), normed=True)
> plt.show()
>
> Unfortunately, I don't get a distribution that looks anything like the
> inputs.  I have searched the web and the above code is based on a couple of
> other posts but I am getting confused about the arguments that the fit
> function returns and which the EXPONWEIB function needs.  All help greatly
> appreciated!
>
> Thanks!!
>
> Alun Griffiths
>
>

When I run your script with scipy 0.14.0, I get the attached figure.  Is
that what you get?

Warren



> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150105/c159fe02/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: figure_1.png
Type: image/png
Size: 26358 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150105/c159fe02/attachment.png>


More information about the SciPy-User mailing list