I have created a simple function in python:
def func(a,x):
return a+x*2
and then I call it
x = [log(1),log(2),log(4),log(5),log(8)]
#Import y data from a file
free= curve_fit(func,np.array(x),np.array(y))[0][0]
yline = func(free,x)
The resulting yline is twice as long as x and is has each element in there twice.
Why is that so?
Note:
I’m importing numpy but not scipy or curve_fit
xis a list and infuncit will be “multiplied by two” (i.e. the number of its elements doubled).If you want to multiply it by two (i.e. multiply each element), convert it to
np.arrayfirst: