Fit
Usage
• Fit[data, funs, vars] 找一个数据列的最小二乘拟合,这个拟合是作为一个以 vars为自变量的函数funs的线性组合。
• 数据有形式   , , ... ,  ,  , , ... ,  , ...  , 其中坐标数 x, y, ... 等于在列表 vars中的变量数。
• 数据可以有形式  , , ...  , 有一个坐标假设是取值 1, 2, ... .
• 参数 funs可以是任何仅依赖于对象vars的函数列表。
Notes
• Fit 总是求在列表中的函数的线性组合,使得最小化由值  得出的平方和。 • 作为Fit的输入给出的精确数被转化为有机器精度的近似数。
Further Examples
You will have to evaluate all the cells in this example to regenerate the data used for the plots. Here is a table of the first 20 primes.
In[1]:=
|
Here is a plot of this data. Evaluate the cell to see the graphic.
In[2]:=
|
This gives a quadratic fit to the data.
In[3]:=
|
Here is a plot of the quadratic fit. Evaluate the cell to see the graphic.
In[4]:=
|
This shows the quadratic fit superimposed on the original data. The quadratic fit is better than the linear one. Evaluate the cell to see the graphic.
In[5]:=
|
This gives a table of the values of an exponential function for x from 1 to 10 in steps of 1.
In[6]:=
|
Out[6]=
|
This fit recovers the original functional form.
In[7]:=
|
Out[7]=
|
If you include other functions in the list, Fit determines that they occur with small coefficients.
In[8]:=
|
Out[8]=
|
You can use Chop to get rid of the terms with small coefficients.
In[9]:=
|
Out[9]=
|
In[10]:=
|
|