This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

Numerical OptimizationStatistics Packages

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.

Functions for fitting curves.

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}]


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]


This finds a fit of the form .

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


This gives a table of , pairs.

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


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

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


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

Fourier transforms.

Here is a simple square pulse.

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


This takes the Fourier transform of the pulse.

In[7]:= Fourier[data]


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.3 gives more details.

Numerical OptimizationStatistics Packages