※ 引述《abcd28s (乖小孩)》之铭言:
: 鲁蛇小弟我又遇到瓶颈了
: 想要将我做的interpolation函数用解析的方法去fit
: 但是因为肯定不是linear的函数
: 所以不能直接用Fit的指令做(对吧@@)
: 因此试了一些其他的指令
: 像是FindFit,NonlinearModelFit
: 可是基本上好像都是我要先有一个默认的model去fit(?)
: 想请教有没有办法直接让mathematica给我一个analytic的形式?
: 当然是近似的analytic并不是exact的
: 附上图形
:
![]()
: 谢谢大大们QQ
(* test data*)
plot1=Plot[PDF[LogNormalDistribution[0,1],x],{x,0,5}]
mypts=plot1[[1,1,-1,2,1]];
ListLinePlot[mypts]
(* models and parameters *)
myrule=b[coef_]:>ToExpression["b"<>ToString[coef]];
mymodel=Accumulate[b[#]*x^#&/@Range[0,10,1]/.myrule][[2;;-1]]
myvar=b[#]&/@Range[0,10]/.myrule
(* fitting models *)
myfit=FindFit[mypts,mymodel[[#]],myvar[[1;;#+1]],x]&/@
Range[Length@mymodel]
(* plot data and model *)
Plot[mymodel[[#]]/.myfit[[#]],{x,0,5},Epilog->Point[mypts],
PlotRange->{{0,5},{0,0.8}}]&/@Range[Length@mymodel]