Chapter 6. Interpolation and Approximation

   

 
Java Number Cruncher: The Java Programmer's Guide to Numerical Computing
By Ronald  Mak

Table of Contents
Part  II.   Iterative Computations


If you're given a set of data values, the following are questions you might ask. Is there a good way to represent these data in a meaningful way, so that I can see what's the overall shape or trend of the values? How can I estimate new data values that lie between the given values, so that the new ones "fit in" with this shape or trend? Can I generate new values that approximate the original values?

If you can cast the data as a set of points in the xy plane, a very useful way to answer these questions is to draw a graph of the data. There are two types of graphs you can draw. If the set of data values is small, say 10 values or fewer, you can try to plot a curve that goes through all of the points. Or if there are many data values, you can plot a curve that goes as "near" as possible among the points, but not necessarily going through any of them.

Both types of graphs will allow you to generate new data values. Our job, then, is to define the function for the graph. By plugging new x values into the function, it will generate new values that fit in with the existing values.

In this chapter, given a set of data points, we will create a polynomial function that goes through each point. Because the function passes through the points, it is an interpolation function. With this function, we can estimate a new data point between two original adjacent data points by plugging in a new x coordinate that lies between the x coordinates of the two original points.

We'll also create a line function that passes closely among a given set of data points (and, of course, we'll have to define what "close" means). This regression function defines a regression line. By plugging in new x coordinates into the function, we can generate new data points that approximate the original data. We'll defer polynomial regression functions of a higher degree until Chapter 10, since they require solving sets of simultaneous equations.

Figure 6-1 graphs examples of a polynomial interpolation function and a regression line.

Figure 6-1. Graphs of a polynomial interpolation function of degree 7 (left) and a regression line (right) for the same set of data points.

graphics/06fig01.jpg


   
Top
 


Java Number Cruncher. The Java Programmer's Guide to Numerical Computing
Java Number Cruncher: The Java Programmers Guide to Numerical Computing
ISBN: 0130460419
EAN: 2147483647
Year: 2001
Pages: 141
Authors: Ronald Mak

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net