0
$\begingroup$

I have some problems with the NonlinearModelFit, i want to fit the analytical data to one function consisting of two Lorentzians

wr=3.1416;

model = (a /((t - wr )^2 + b^2)) - (c/((t - wr)^2 + d^2))
result = NonlinearModelFit[data, model, {a, b, c, d}, t, MaxIterations -> 800, Method -> {NMinimize}]

result["BestFitParameters"]
result["AdjustedRSquared"]

result["AIC"];
fitplot1 = Show[ListPlot[data], Plot[result[t], {t, 2.5, 3.8}, PlotRange -> Full]]

The model should fit my

{{2.5906, 0.0561}, {2.6006, 0.0611}, {2.6106, 0.0663}, {2.6206, 0.0719}, 
 {2.6306, 0.0779}, {2.6406, 0.0843}, {2.6506, 0.0912}, {2.6606, 0.0985}, 
 {2.6706, 0.1064}, {2.6806, 0.1148}, {2.6906, 0.1237}, {2.7006, 0.1333}, 
 {2.7106,  0.1437}, {2.7206, 0.1547}, {2.7306, 0.1666}, {2.7406,  0.1793}, 
 {2.7506, 0.1931}, {2.7606, 0.2078}, {2.7706,  0.2237}, {2.7806, 0.2409}, 
 {2.7906, 0.2594}, {2.8006, 0.2793}, {2.8106, 0.3009}, {2.8206, 0.3242}, 
 {2.8306,  0.3494}, {2.8406, 0.3767}, {2.8506, 0.4061}, {2.8606, 0.438}, 
 {2.8706, 0.4723}, {2.8806, 0.5093}, {2.8906, 0.5491}, {2.9006, 0.5916}, 
 {2.9106, 0.6367}, {2.9206,0.6843}, {2.9306, 0.7338}, {2.9406, 0.7843}, 
 {2.9506, 0.8348}, {2.9606, 0.8834}, {2.9706, 0.9276}, {2.9806, 0.9644}, 
 {2.9906, 0.9899}, {3.0006, 1.}, {3.0106, 0.9906}, {3.0206,  0.9586}, 
 {3.0306, 0.9025}, {3.0406, 0.8234}, {3.0506,  0.7248}, {3.0606, 0.6131}, 
 {3.0706, 0.4955}, {3.0806,0.3798}, {3.0906, 0.2727}, {3.1006, 0.1794}, 
 {3.1106, 0.1037}, {3.1206, 0.0479}, {3.1306, 0.0132}, {3.1406, 0.00010186}, 
 {3.1506, 0.0089348}, {3.1606, 0.0395}, {3.1706, 0.0914}, {3.1806, 0.1634}, 
 {3.1906, 0.2535}, {3.2006, 0.3583}, {3.2106, 0.4728}, {3.2206, 0.5906}, 
 {3.2306, 0.7041}, {3.2406, 0.8057}, {3.2506, 0.889}, {3.2606, 0.9497}, 
 {3.2706, 0.9863}, {3.2806, 0.9998}, {3.2906, 0.9931}, {3.3006, 0.9703}, 
 {3.3106, 0.9354}, {3.3206, 0.8923}, {3.3306, 0.8444}, {3.3406, 0.7941}, 
 {3.3506, 0.7435}, {3.3606, 0.6937}, {3.3706, 0.6457}, {3.3806, 0.6001}, 
 {3.3906, 0.5571}, {3.4006, 0.5168}, {3.4106, 0.4793}, {3.4206, 0.4444}, 
 {3.4306, 0.4121}, {3.4406,  0.3822}, {3.4506, 0.3545}, {3.4606, 0.3289}, 
 {3.4706,  0.3052}, {3.4806, 0.2834}, {3.4906, 0.2631}, {3.5006,  0.2443}, 
 {3.5106, 0.2269}, {3.5206, 0.2108}, {3.5306,  0.1958}, {3.5406, 0.1819}, 
 {3.5506, 0.169}, {3.5606, 0.1569}, {3.5706, 0.1457}, {3.5806, 0.1353}, 
 {3.5906, 0.1255}, {3.6006, 0.1164}, {3.6106, 0.1079}, {3.6206, 0.1}, 
 {3.6306, 0.0926}, {3.6406, 0.0856}, {3.6506, 0.0791}, {3.6606, 0.0731}, 
 {3.6706, 0.0674}, {3.6806, 0.062}, {3.6906, 0.057}, {3.7006, 0.0524}, 
 {3.7106, 0.048}, {3.7206, 0.0439}, {3.7306, 0.0401}, {3.7406, 0.0365}, 
 {3.7506, 0.0331}, {3.7606, 0.03}, {3.7706, 0.0271}, {3.7806,0.0244}, 
 {3.7906, 0.0218}}    

The result is

enter image description here

$\endgroup$
7
  • $\begingroup$ You use the tag warning-messages but you don't mention any in your question. Please edit your question so it describes the messages you got. $\endgroup$
    – m_goldberg
    Jun 22, 2020 at 15:07
  • $\begingroup$ Your experimental peaks look asymmetric, but the Lorentzian function is symmetric. I don't know how good a fit you might get. Also, your model contains the difference of two Lorentzians. Is that correct? $\endgroup$
    – MarcoB
    Jun 22, 2020 at 15:29
  • $\begingroup$ @MarcoB I finally get to disagree with you about something. Check out ListPlot[Transpose[{Abs[data[[All, 1]] - Pi], data[[All, 2]]}]]. I think there's almost perfect symmetry. $\endgroup$
    – JimB
    Jun 22, 2020 at 16:45
  • $\begingroup$ The analytical results are symmetric , i didn't give here all my data and the model used is correct. $\endgroup$
    – user73456
    Jun 22, 2020 at 17:07
  • 1
    $\begingroup$ What is this data actually from? If you give some clues as to the physical processes that can help with analysis! $\endgroup$
    – N.B.
    Jun 22, 2020 at 18:34

2 Answers 2

1
$\begingroup$

Try this slightly modified model

model = (a b/(b^2 +  (t - wr )^2 )) - (c d/(d^2 + (t - wr )^2 ))
result = NonlinearModelFit[data, model, {a, b, c, d }, t,MaxIterations -> 800, Method -> {NMinimize}]

which gives

enter image description here

$\endgroup$
7
  • $\begingroup$ Thanks for the great answer $\endgroup$
    – user73456
    Jun 22, 2020 at 17:03
  • $\begingroup$ You're welcome! $\endgroup$ Jun 22, 2020 at 18:04
  • $\begingroup$ I have a question, there are cases where I have an asymmetrical resonance but I can't find the best fit $\endgroup$
    – user73456
    Jun 22, 2020 at 18:27
  • $\begingroup$ @Malak Perhaps you have to constraint the sign of a,c in this case? $\endgroup$ Jun 22, 2020 at 20:54
  • $\begingroup$ I tried but i didn't find the best fit $\endgroup$
    – user73456
    Jun 23, 2020 at 15:12
0
$\begingroup$

Example of the asymmetrical case, i used the same code above with wr=1.6146

data={{0.9906, 0.0389}, {1.0006, 0.0353}, {1.0106, 0.0318}, {1.0206, 0.0285}, {1.0306, 0.0254}, {1.0406, 0.0224}, {1.0506, 0.0196}, {1.0606, 0.017}, {1.0706, 0.0145}, {1.0806,  0.0122}, {1.0906, 0.0101}, {1.1006, 0.0081942}, {1.1106, 0.0064455}, {1.1206, 0.0048891}, {1.1306, 0.0035317}, {1.1406,0.0023805}, {1.1506, 0.0014439}, {1.1606, 0.00073128}, {1.1706, 0.00025303}, {1.1806, 0.000020972}, {1.1906, 0.000048372}, {1.2006, 0.00035018}, {1.2106, 0.00094326}, {1.2206, 0.0018467}, {1.2306,  0.0030822}, {1.2406, 0.0046743}, {1.2506, 0.006651}, {1.2606, 0.0090447}, {1.2706, 0.0119}, {1.2806, 0.0152}, {1.2906, 0.0191}, {1.3006, 0.0236}, {1.3106, 0.0288}, {1.3206,  0.0347}, {1.3306, 0.0415}, {1.3406, 0.0492}, {1.3506,  0.058}, {1.3606, 0.0681}, {1.3706, 0.0797}, {1.3806,  0.058}, {1.3906, 0.1084}, {1.4006, 0.1262}, {1.4106, 0.1471}, {1.4206, 0.1717}, {1.4306, 0.2009}, {1.4406, 0.236}, {1.4506, 0.2787}, {1.4606, 0.3313}, {1.4706,  0.3968}, {1.4806, 0.4791}, {1.4906, 0.5823}, {1.5006,  0.7082}, {1.5106, 0.8486}, {1.5206, 0.968}, {1.5306,  0.992}, {1.5406, 0.8574}, {1.5506, 0.6124}, {1.5606,  0.3735}, {1.5706, 0.2023}, {1.5806, 0.0975}, {1.5906, 0.0394}, {1.6006, 0.0109}, {1.6106, 0.0006228}, {1.6206, 0.0018712}, {1.6306, 0.0106}, {1.6406, 0.0246}, {1.6506, 0.0423}, {1.6606, 0.0629}, {1.6706, 0.0859}, {1.6806, 0.1111}, {1.6906, 0.1383}, {1.7006, 0.1673}, {1.7106, 0.198}, {1.7206, 0.2306}, {1.7306, 0.2648}, {1.7406,  0.3008}, {1.7506, 0.3383}, {1.7606, 0.3774}, {1.7706, 0.4178}, {1.7806, 0.4595}, {1.7906, 0.5022}, {1.8006,  0.5456}, {1.8106, 0.5895}, {1.8206, 0.6334}, {1.8306,  0.6769}, {1.8406, 0.7195}, {1.8506, 0.7608}, {1.8606, 0.8003}, {1.8706, 0.8373}, {1.8806, 0.8715}, {1.8906, 0.9023}, {1.9006, 0.9293}, {1.9106, 0.9522}, {1.9206,  0.9707}, {1.9306, 0.9847}, {1.9406, 0.9942}, {1.9506,  0.9991}, {1.9606, 0.9997}, {1.9706, 0.9962}, {1.9806,  0.9887}, {1.9906, 0.9778}, {2.0006, 0.9637}, {2.0106,  0.9469}, {2.0206, 0.9278}, {2.0306, 0.9067}, {2.0406,  0.884}, {2.0506, 0.8601}, {2.0606, 0.8353}, {2.0706, 0.8099}, {2.0806, 0.7841}, {2.0906, 0.7581}, {2.1006,  0.7322}, {2.1106, 0.7065}, {2.1206, 0.6811}, {2.1306,   0.6562}, {2.1406, 0.6318}, {2.1506, 0.6079}, {2.1606, 0.5847}, {2.1706, 0.5622}, {2.1806, 0.5404}, {2.1906, 0.5193}, {2.2006, 0.4989}, {2.2106, 0.4793}, {2.2206, 0.4603}, {2.2306, 0.4421}, {2.2406, 0.4246}, {2.2506, 0.4077}, {2.2606, 0.3914}, {2.2706, 0.3759}, {2.2806,  0.3609}, {2.2906, 0.3465}, {2.3006, 0.3327}, {2.3106, 0.3194}, {2.3206, 0.3066}, {2.3306, 0.2944}, {2.3406,  0.2826}, {2.3506, 0.2713}, {2.3606, 0.2605}, {2.3706,  0.25}, {2.3806, 0.24}, {2.3906, 0.2304}, {2.4006, 0.2211}, {2.4106, 0.2122}, {2.4206, 0.2036}, {2.4306, 0.1954}, {2.4406, 0.1875}, {2.4506, 0.1798}, {2.4606, 0.1725}, {2.4706,  0.1654}, {2.4806, 0.1586}, {2.4906, 0.152}, {2.5006,  0.1457}, {2.5106, 0.1396}, {2.5206, 0.1338}, {2.5306,  0.1281}, {2.5406, 0.1227}, {2.5506, 0.1174}, {2.5606,  0.1123}, {2.5706, 0.1074}, {2.5806, 0.1027}, {2.5906,   0.0982}, {2.6006, 0.0938}, {2.6106, 0.0896}, {2.6206,  0.0855}, {2.6306, 0.0815}, {2.6406, 0.0777}, {2.6506, 0.0741}, {2.6606, 0.0705}, {2.6706, 0.0671}, {2.6806,   0.0638}, {2.6906, 0.0606}, {2.7006, 0.0576}, {2.7106,  0.0546}, {2.7206, 0.0518}, {2.7306, 0.049}, {2.7406, 0.0464}, {2.7506, 0.0438}, {2.7606, 0.0414}, {2.7706, 0.039}, {2.7806, 0.0367}, {2.7906, 0.0345}, {2.8006,  0.0324}, {2.8106, 0.0304}, {2.8206, 0.0284}, {2.8306,  0.0266}, {2.8406, 0.0248}, {2.8506, 0.0231}, {2.8606, 0.0214}, {2.8706, 0.0198}, {2.8806, 0.0183}, {2.8906, 0.0169}, {2.9006, 0.0155}, {2.9106, 0.0142}, {2.9206,  0.013}, {2.9306, 0.0118}, {2.9406, 0.0107}, {2.9506, 0.0095917}, {2.9606, 0.0085906}, {2.9706, 0.0076481}, {2.9806, 0.0067636}, {2.9906, 0.0059361}}

The result is

enter image description here

$\endgroup$
1
  • $\begingroup$ Now I see, but I can't reproduce your result!? You need a modell with minimum at t=wr and asymmetrical maxima. Unitl now I have no idea how to solve it, sorry. $\endgroup$ Jun 23, 2020 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy