Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Previous section-----Next section

1.6.6 Manipulating Numerical Data

When you have numerical data, it is often convenient to find a simple formula that approximates it. For example, you can try to "fit" a line or curve through the points in your data.

Fit[{ ,  , ... }, { ,  , ... }, x]
fit the values  to a linear combination of functions
Fit[{{ ,  }, { ,  }, ... }, { ,  , ... }, x]
fit the points  to a linear combination of the

Fitting curves to linear combinations of functions.
This generates a table of the numerical values of the exponential function. Table will be discussed in Section 1.8.2.

In[1]:=  data = Table[ Exp[x/5.] , {x, 7}]

Out[1]=

This finds a least-squares fit to data of the form  . The elements of data are assumed to correspond to values  ,  ,  of  .

In[2]:=  Fit[data, {1, x, x^2}, x]

Out[2]=

This finds a fit of the form  .

In[3]:=  Fit[data, {1, x, x^3, x^5}, x]

Out[3]=

This gives a table of  ,  pairs.

In[4]:=  data = Table[ {x, Exp[Sin[x]]} , {x, 0., 1., 0.2}]

Out[4]=

This finds a fit to the new data, of the form  .

In[5]:=  Fit[%, {1, Sin[x], Sin[2x]}, x]

Out[5]=

FindFit[data, form, { ,  , ... }, x]
find a fit to form with parameters

Fitting data to general forms.
This finds the best parameters for a linear fit.

In[6]:=  FindFit[data, a + b x + c x^2, {a, b, c}, x]

Out[6]=

This does a nonlinear fit.

In[7]:=  FindFit[data, a + b^(c + d x), {a, b, c, d}, x]

Out[7]=

One common way of picking out "signals" in numerical data is to find the Fourier transform, or frequency spectrum, of the data.

Fourier[data] numerical Fourier transform
InverseFourier[data] inverse Fourier transform

Fourier transforms.
Here is a simple square pulse.

In[8]:=  data = {1, 1, 1, 1, -1, -1, -1, -1}

Out[8]=

This takes the Fourier transform of the pulse.

In[9]:=  Fourier[data]

Out[9]=

Note that the Fourier function in Mathematica is defined with the sign convention typically used in the physical sciences--opposite to the one often used in electrical engineering. Section 3.8.4 gives more details.


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: