CMP EMBEDDED.COM

Login | Register     Welcome Guest  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Why all the math?



Embedded.com

Mathematically, we hint at the functional dependence by writing:

(1)

where f(x) is some function to be either given later or discovered.

While we can use x-y graphs for a number of purposes, it's in the processing of experimental data that the least squares fit has its greatest value. For exanple, someone once told me that the period between the chirps of a cricket depends on the ambient temperature. If I'm sufficiently motivated, I might perform an experiment to find out. Or, if I were Galileo, I might measure the motion of a ball rolling down an inclined plane and seek to determine the nature of gravity.

If I plot the measured data, I might get a graph something like Figure 1.

From the figure, I can see two things immediately. First, there does indeed seem to be some correlation between the x- and y-components of the data. The y-value seems to decrease as x increases. But I can also see that the data doesn't at all follow the nice, smooth curve that I might have expected.

There are two ways I might react to the data I've just plotted. If I haven't yet had my morning coffee, and my brain is not yet in gear, I might be forgiven for thinking, "Wow, I guess the functional relationship between x and y is a lot more complicated than I thought." In that case, I might try to fit a curve that passes directly through every single data point, as in the red curve of Figure 2.

Hopefully, though, I'll be a little more astute and recognize the data for what it really is: a simple functional relationship, corrupted by lots of noise. Given that level of noise, the best guess of the relationship is the yellow line in Figure 2.

But how did I get the yellow line? For me, it was pretty easy: in Excel, I clicked a button that said, "Add Trendline." Because the data is so noisy, a straight line is about as good a fit as we can expect to get. Business types call this process "linear regression."

And what, you ask, did Excel do to get the trend line? Why, it performed a least squares fit. Now I'm going to show you how you can do it yourself, in your own software.

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

Rate this article: Low High
Current rating
  • .
Embedded.com Career Center
Looking for a new job?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS



WEBINAR
TECH PAPER
TECH PAPER
WEBINAR
WEBINAR
WEBINAR




 :