2017-12-12 11 views
0

lmfit의 지수 모델은 (음의) 지수 함수를 근사 할 때 어떻게 작동합니까?LMFIT에서 음수 지수 모델을 맞 춥니 다

다음은 https://lmfit.github.io/lmfit-py/model.html을 따르려고했는데, 올바른 결과를 제공하기 위해 실패

mod = lmfit.models.ExponentialModel() 
pars = mod.guess([1, 0.5], x=[0, 1]) 
out = mod.fit([1, 0.5], pars, x=[0, 1]) 
out.eval(x=0) # result is 0.74999998273811308, should be 1 
out.eval(x=1) # result is 0.75000001066995159, should be 0.5 

답변

1

당신은 데이터에 대한 두 매개 변수 지수 모델에 맞게 두 개 이상의 데이터 포인트가 필요합니다. Lmfit 모델은 데이터 피팅을 수행하도록 설계되었습니다. 이런 식으로 뭔가가 작동합니다 :

import numpy as np 
import lmfit 

xdat = np.linspace(0, 2.0, 11) 
ydat = 2.1 * np.exp(-xdat /0.88) + np.random.normal(size=len(xdat), scale=0.06) 

mod = lmfit.models.ExponentialModel() 
pars = mod.guess(ydat, x=xdat) 
out = mod.fit(ydat, pars, x=xdat) 

print(out.fit_report()) 

를 대신 amplitude = 0.75decay > 1e6을 받고 있습니다.

+0

감사합니다. 데이터는 MVCE로 작성되었지만 너무 단순합니다. lmfit이 내 실제 데이터에 잘 맞지 않는 것 같습니다. –