In python I have a function which has many parameters. I want to fit this function to a data set, but using only one parameter, the rest of the parameters I want to supply o
Scipy's curve_fit takes three positional arguments, func, xdata and ydata. So an alternative approach (to using a function wrapper) is to treat 'b' as xdata (i.e. independent variable) by building a matrix that contains both your original xdata (x1) and a second column for your fixed parameter b.
Assuming x1 and x2 are arrays:
def func(xdata,a):
x, b = xdata[:,0], xdata[:,1] # Extract your x and b
return a*x*x + b
for b in xrange(10):
xdata = np.zeros((len(x1),2)) # initialize a matrix
xdata[:,0] = x1 # your original x-data
xdata[:,1] = b # your fixed parameter
popt,pcov = curve_fit(func,xdata,x2) # x2 is your y-data