User:Brian P. Josey/Notebook/2010/05/03

From OpenWetWare

Jump to: navigation, search
Project name Main project page
Previous entry      Next entry

Smoothing Revisited

I was able to find a pretty good smoothing algorithm for MATLAB using the moving average, or boxcar average. Here you can find the web page for it, and it was written by Carlos Adrian Vargas Aguilera from Universidad de Guadalajara, in Mexico. I like his code because it is simple to use and can be used for both matrices and vectors. To use the function, all you have to do is specify the vector that you want to smooth and how many points to the right and left you want to define the window size.

Today, I used a window size of ten points to the left and right, and applied it to the whole set of data for either the field or derivative. The reason for this is that the end points do not change under this function, which is useful, but the points near the end become less accurate. I then pick out the inner points to are in the region that I am interested in.

Two Methods

I created two different continuous and smooth functions by applying the smoothing operation in two different places. For the first method, I smoothed the entire set of data for the field intensity, took the derivative, and then selected out my points. Here is the resulting graph of the function:

As you can see, the derivative is significantly smoother than the one I developed on Friday, and the anomalous bump in the beginning has been removed.

For the second method, I first calculated the derivative for the whole set of the date first, then I smoothed this function and finally removed the points that I was interested in. Graphing this against the length of the gap, I generated this graph:

Both of these graphs are remarkably similar, and at first, I assumed that I had a programming error. Checking my code, I found this wasn't the case and I cannot see any obvious difference between the two approaches.

Numerical Comparison

Because of how similar the two approaches were, I had to analyze the data for any signs of a numerical difference between them. I took the raw difference between the two derivatives and graphed it against the length of the yoke, getting this graph:

Here it is clear that the difference between the two functions oscillates between about -12*10-6 to 6*10-6 T/inch. This is a minuscule amount and suggests that they two processes are identical. To double check, I calculated and graphed the percent difference between the two derivatives:

From this graph, it is abundantly clear that two processes or equivalent. With a percent difference on the order of 10-5 there is no reason to favor one over the other. However, for the sake of consistency, I will take the derivative and then smooth it for my data analysis.

Personal tools