I have a dataset and uncertainty both single arrays of length 100. I have a "model" array also of length 100. Goal: Optimize only one parameter (scaling the amplitude) of this model array to better fit the data given its uncertainty.
so far I've tried:
def residual(params, x, data, eps_data):
amp = params['amp'].value
model = amp * x
return (data - model)/eps_data
params = Parameters()
params.add('amp',value=100)
out = minimize(residual,params,args=(mod_array,data_array,unc_array))
Then, I multiply the best fit value amplitude with the original model array:
fit = params['amp'].value*mod_array
Then, I plot the fit over the original dataset and it looks absolutely terrible, I don't even see the model anywhere close to the data. What's wrong in the code/algorithm?