[SciPy-User] covariance mtrix returns inf

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Fri Feb 7 21:58:46 EST 2014


Hi,
I am performing a fit with this code, and it fits well but at the end when
I try to print the covariance matrix it returns to me inf:

def funk(x0, a, b, c, d):

                return a - b * x0 - log10(e)*((10**x0)/c)**b


        #I should take away the 0 values in y and the corrispettive ones in
x

        i=0

        zeroenemy=[]

        for o in y:

                if o==0:

                        zeroenemy.append(i)

                i=i+1

        newx = np.delete(x, zeroenemy)

        newy = np.delete(y, zeroenemy)

        x = newx

        y = newy

        #conversion in log scale

        logy = np.log10(y)

        logx = np.log10(x)

        maxi = y.max()

        Alog = log(maxi)

        gamma = 2/3

        Ecut = 122243792

        b = 1

        guess = [Alog, gamma, Ecut, b]


        print('before fit')

        params, params_covariance = optimize.curve_fit(funk, logx, logy,
guess, logy/1000)#, maxfev=10000

        print('paramcov')

        print(params_covariance)

I attach the data I use for x and y and a plot of the data and the fitted
curve


[image: Immagine in linea 1]
thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140207/03b5074c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: figure_1.png
Type: image/png
Size: 26109 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140207/03b5074c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdata1.dat
Type: application/octet-stream
Size: 1749 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140207/03b5074c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ydata1.dat
Type: application/octet-stream
Size: 1849 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140207/03b5074c/attachment-0001.obj>


More information about the SciPy-User mailing list