我正在通过mathematica尝试NonLinearModelFit .. 数据应包括
Exp [-ax] Sin [bx] ......但我无法获得正确的拟合曲线(参数)..
原始节目列在下面..
data = {{0, 0.8156862745098039`}, {5/21, 0.5163398692810458`}, {10/21,
0.20784313725490197`}, {5/7, 0.052941176470588235`}, {20/21,
0.0363921568627451`}, {25/21, 0.11776589423648247`}, {10/7,
0.18943355119825708`}, {5/3, 0.1329847494553377`}, {40/21,
0.04635294117647058`}, {15/7, 0.022294843863471313`}, {50/21,
0.05026737967914438`}, {55/21, 0.08732806555458003`}, {20/7,
0.08406234288587229`}, {65/21, 0.04240196078431373`}, {10/3,
0.010288350634371396`}, {25/7, 0.005962384953981593`}, {80/21,
0.0145602795573675`}, {85/21, 0.023162910023822612`}, {30/7,
0.019077901430842606`}, {95/21, 0.007103825136612022`}, {100/21,
0.002007843137254902`}, {5, 0.0046875`}, {110/21,
0.009488550665021253`}, {115/21, 0.011350455675227838`}, {40/7,
0.007381776239907728`}, {125/21, 0.0025227925565130507`}, {130/21,
0.001340282948622487`}, {45/7, 0.002856171370282217`}, {20/3,
0.004392156862745098`}, {145/21, 0.003963510537905002`}, {50/7,
0.0024745727167872498`}, {155/21, 0.0011558307533539732`}, {160/
21, 0.0014921090387374463`}, {55/7, 0.0025759323337178008`}, {170/
21, 0.0030401151286202554`}, {25/3, 0.0023312550826782323`}, {60/
7, 0.0012677484787018255`}, {185/21,
0.0015068990559186637`}, {190/21, 0.002007693029364856`}, {65/7,
0.0024161323297091346`}, {200/21, 0.0024937154348919056`}, {205/
21, 0.0016575702445926822`}, {10, 0.0015728216420257944`}, {215/
21, 0.0020161737011188657`}, {220/21, 0.002557544757033248`}, {75/
7, 0.0030375155842683895`}, {230/21,
0.0031632542519770337`}, {235/21, 0.002895576835385317`}, {80/7,
0.0033217993079584776`}, {35/3, 0.0034982174688057044`}, {250/21,
0.004`}, {85/7, 0.003390830016217013`}, {260/21,
0.003701667582921019`}, {265/21, 0.004117647058823529`}, {90/7,
0.004841442749939482`}, {275/21, 0.0046199301638463605`}, {40/3,
0.004551820728291316`}, {95/7, 0.004470588235294118`}, {290/21,
0.005930176948828312`}, {295/21, 0.005186590765338393`}, {100/7,
0.004108309990662932`}, {305/21, 0.0024132730015082957`}, {310/21,
0.0028011204481792717`}, {15, 0.`}};
ListLinePlot[data, PlotRange -> All]
然后我按照
进行了装配fit = NonlinearModelFit[data,0.8 Exp[-t*r] Sin[4.5 (r + b)] + d, {t, b, d}, r];
无论如何,结果总是不合适.. 如下:
我确信模型应该以
结束Exp[-ax]Sin[kx]
我应该修改模型吗?如何才能获得更好的拟合曲线?
欢迎任何建议或帮助。
答案 0 :(得分:1)
这可以通过Anton Antonov的Quantile regression with B-splines包(direct link到M
- 文件)轻松完成:
Needs["QuantileRegression`"]
qfunc = QuantileRegression[data, data[[;; , 1]], {0.5},
InterpolationOrder -> 2][[1]]; // Quiet
Plot[qfunc[x], {x, Min[data[[All, 1]]], Max[data[[All, 1]]]},
Frame -> True, PlotStyle -> Red, Prolog -> Point[data],
PlotLabel -> "Comparison of the model with original data",
Exclusions -> None, PlotRange -> All]
ListPlot[data[[;; , 2]] - qfunc /@ data[[;; , 1]], PlotRange -> All,
Filling -> Axis,
PlotLabel -> "Differences between the original data and the model"]