Click here to Skip to main content
15,903,203 members

Comments by Zohreh Karimzadeh (Top 3 by date)

Zohreh Karimzadeh 5-Sep-22 12:04pm View    
Deleted
Please take a look here:https://stackoverflow.com/questions/69046347/scipy-minimize-scipy-curve-fit-lmfit---
But in my case I should make the f function in a dynamic way for each iteration that includes different variables and expression.
Zohreh Karimzadeh 5-Sep-22 12:01pm View    
Deleted
Thank you for considering in summer to fit a model using lmfit it should be passed to Model as follows:
def f(x, gamma, alpha, beta, eta):
L = x[0]
K = x[1]

return gamma - (1/eta)*np.log(alpha*L**-eta + beta*K**-eta)

fmodel = Model(f)
params = Parameters()
params.add('gamma', value = 1, vary=True, min = 1)
params.add('alpha', value = 0.01, vary=True, max = 1, min = 0)
params.add('beta', value = 0.98, vary=True, max = 1, min = 0)
params.add('eta', value = 1, vary=True, min = -1)

result = fmodel.fit(np.log(VA), params, x=(L,K))
print(result.fit_report())
Zohreh Karimzadeh 5-Sep-22 9:49am View    
But this way the result of function will be obtained while I need it makes :
def fun(var1, var2): return expr(var1, var2)