試圖將一個峯這樣一些數據:峯擬合lmfit楠結果
import scipy
from lmfit.models import GaussianModel
x = shm.PTR_P
y = shm.PORE_V_P
mod = LorentzianModel()
pars = mod.guess(y, x=x)
out = mod.fit(y, pars, x=x)
print(out.fit_report(min_correl=0.25))
而我能做的配合,如果我生成的數據,如果我嘗試從沒有關係的另一來源閱讀沒有工作。我不太擅長這個,也不知道這個問題是什麼。下面是輸出:
[X,Y] [(34.145490000000002,3.4599999999999999e-08), (29.286449999999999,4.8399999999999997e-08), (25.118860000000002,0.026773140000000001) (21.544350000000001,0.068791409999999997) , (18.4785,0.083200979999999994) (15.848929999999999,0.02123179), (11.659139999999999,0.01551077), (10.0,0.084493879999999993) (6.3095739999999996,2.0899999999999998e-07), (5.4116949999999999,0.045209140000000002) (4.6415889999999997, 0.054789360000000002 ), (3.4145489999999996,8.9399999999999993e-08), (2.9286449999999999,0.01100814), (2.5118860000000001,0.088990659999999999) (1.84785,3.5799999999999995e-07), (1.5848930000000001,0.099999009999999999) (1.359356,0.075139280000000003), (1.1659139999999999,0.167379), (1.0,0.57693050000000001) (0.85769590000000007,1.8658159999999999) (0.73564230000000008,8.4961369999999992) (0.6309574,25.299099999999999) (0.54116949999999997,21.413350000000001) (0.46415889999999999,13.408829999999998) (0.39810719999999999,8.3584750000000003), (0.34145490000000006,5.3982010000000002) (0.29286440000000002,3.7518540000000002) (0.25118859999999998,2.5325389999999999) (0.21544349999999998,1.7722470000000001) (0.18478499999999998,1.445808), (0.15848929999999997,1.182083), (0.13593559999999999,0.94957730000000007) (0.1165914,0.67620849999999999) (0.10000000000000001,0.46631620000000001) (0.085769590000000007,0.41001890000000002) (0.07356422,0.30625920000000001) (0.063095730000000003,0.24040219999999998) (0.054116949999999997,0.1942596), (0.046415890000000001,0.11306760000 000002), (0.039810720000000001,0.099998470000000006), (0.034145490000000001,0.099998470000000006), (0.029286449999999999,0.02246857), (0.025118870000000001,0.077529909999999994)
通常情況下,當您嘗試適合的數據距離您的分發太遠時,您會得到NAN或INF的。也許嘗試與另一個(或修改你的高斯與你的比例成正比)。檢查'nan_to_num()'函數;它幫助我一次,當我無法擺脫NAN和INF的 – DarkCygnus
你確定這是輸出嗎?適合的報告不應該是這樣的,我沒有看到任何NaN。 –
嗨,試過這個以及沒有任何成功...但我相信問題是數據格式... – Iulian