plot SN curve (non-linear regression model) using python

461 views Asked by At

The input data and the form of the function are known. You must find out the coefficients of the function. The values of these coefficients that need to be determined are also known (60.351, 4.388, 4.806). In writing the code I was inspired by the: nonlinear-regression with python The only difference is for input data and for definition of function.

xData = numpy.array([1, 23385, 35800, 63699, 106798, 222064, 4272000, 20296, 461351, 175300, 11815])
yData = numpy.array([198.9, 112.2, 100.3, 89.8, 80.3, 69.8, 60.8, 120.1, 65.3, 74.9, 127.7])


def func(x, a, b, Offset): # Sigmoid A With Offset from zunzun.com
    return  Offset + 139.0/ ((numpy.exp((log10(x))/a))**b)

I believe there are some prooblem with the initial parameteres when I'm using log10() function. Bellow the error: error capture

1

There are 1 answers

0
mvpetre On BEST ANSWER

After several searches ( [StackOverFlow[1]), I redefined the function: Offset + 139.0/ ((numpy.exp(np.log10(np.abs(x))/a))**b) Non-numpy functions like math.log10() don't play nicely with numpy arrays