2012年4月15日星期日

Mathematica 中的 FindFit

 在官网教程中看到FindFit最简单的Sample如下:


In[1]:=

data = {{1., 12.}, {1.9, 1.0}, {2.6, 8.2}, {3.4, 6.9}, {5., 5.9}};
model = a*Exp[-k*t];
fit = Findfit[data, model, {a, k}, t]


          Out[1]=





悲剧的是,我的output:


          Out[1]=



Findfit[{{1, 12}, {1.9, 10}, {2.6, 8.2}, {3.4, 6.9}, {5, 5.9}}, 
 a E^(-k t), {a, k}, t]

     
改成

In[1]:=

FindFit[{{1., 12.}, {1.9, 10.}, {2.6, 8.2}, {3.4, 6.9}, {5., 5.9}}, 
 c*Exp[d*x], {c, d}, x]


什么output都无。。。
但如果是


In[1]:=



FindFit[{{1., 12.}, {1.9`, 10}, {2.6`, 8.2`}, {3.4`, 6.9`}, {5, 5.9`}}, 

 c*x + d, {c, d}, x]


就好了。。。


   Out[1]=

{c -> -1.53531, d -> 12.8682}


或者

In[1]:=



FindFit[{{1., 12.}, {1.9, 10.}, {2.6, 8.2}, {3.4, 6.9}, {5., 5.9}}, 
 c^x + d, {c, d}, x]


FindFit::nrlnum: The function value {-0.66714+0. I,2.15828-0.0942626 I,3.60731+0.187322 I,4.93125-0.113626 I,5.92422+0. I} is not a list of real numbers with dimensions {5} at {c,d} = {-0.535314,11.8682}.

 
  Out[1]=


{c -> -0.535314, d -> 11.8682}



真稀奇。


难道是我这个version太笨了?

没有评论:

发表评论