VIEWS: 21 PAGES: 5 POSTED ON: 4/28/2011
CURVE FITTING There are three main components to science and engineering: Theory, computer simulations and experiments. In the case of experiments, it is necessary to be able to interpret the data and to extract useful information. Curve fitting is a very powerful tool in that it allows finding the relationships between variables. For example, properly fitting the data of experiments measuring the drag force on an object as a function of wind velocity can produce the very useful result that the drag is roughly a function of the velocity squared (see figure 1): F .2741 V 1.9842 Figure 1: Curve fitting for drag .vs. wind velocity The goal of curve fitting is therefore to develop some tools that can help approximate data points with useful functions. The first useful function one can think of is a linear curve, i.e. how to fit a straight line to data points. Since the data may not be naturally aligned, one needs to design a “best fit”. For example, figure 2 depicts a linear fit to the data relating the drag force to the wind velocity. This is the “best fit” in the sense that the sum of the square of the error between the fit and the data is minimized. This is called a least square fit. Figure 2: Linear fit to the data drag .vs. wind velocity A similar mathematical construct exists for defining “quadratic best fit” or “cubic best fit”, etc. The tools function in MATLAB is quite useful in this regard. ToolsBasic Fitting was used to produce the results in figure 3. In class: Description of ToolsBasic Fitting Description of polyfit and polyval. Figure 3: Different fitting curves for the same data However, blind curve fitting like those in figure 3 is not always useful. For example, in the case of the drag-versus-velocity example, we need to impose that the drag force be zero when the wind velocity is zero (otherwise, the fit will have little physical meaning). In this case, trying a linear or a quadratic or a cubic fit will not produce acceptable results since the intercepts will not be equal to zero in any of those cases. A better approach is to use a transform that will convert the data into a more useable form. This is called linearization in this case and there are three standard linearization strategies (note that there exits other models, but the following three are very informative): 1. The exponential model: y aebx 2. The power model: y ax b 3. The saturation-growth-rate model: x ya b x Notes: It is useful to keep in mind the following when deciding which model to use: In the case of the exponential model, y is different from zero when x=0. Therefore this model is not well- suited for a case like the drag .vs. wind velocity relation. For the other two models we have y=0 when x=0 but the difference between the two is that the saturation-growth-rate model “levels off” as x increases, modeling a limiting condition of growth (or decay). The linearization is obtained in the following way. Instead of expressing y as a function of x we express: 1. ln(y) as a function of x in the case of the exponential model. 2. ln(y) as a function of ln(x) in the case of the power model. 3. 1/y as a function of 1/x in the case of the saturation-growth-rate model. In class: Show the linearization. Since the data is now linearized, we can use a “linear best fit” to fit the transformed (linearized) data. The slope and intercept of the transformed data are linked with the original models by: 1. Slope=b and Intercept=ln(a) in the case of the exponential model. 2. Slope=b and Intercept=ln(a) in the case of the power model. 3. Slope=b/a and Intercept=1/a in the case of the saturation-growth-rate model. From these relations, one can find the coefficients a and b in the case of all three models. Example: In the case of drag .vs. wind velocity, it is physically intuitive that a good model would be the power model. Indeed, the velocity should be zero when the wind velocity is zero. Moreover, we do not expect any constraints or “leveling off” process (the faster the wind, the greater the drag). Solution: Plot ln(Drag) .vs. ln(Velocity). Use a linear fit. Extract the coefficients a and b of the power model from the slope and intercept of the linear fit. This is described in figure 4. Figure 4: Using the power model. From this we obtain that a=1.9842 and b=ln(-1.2941)=.2741. Therefore, the relationship between the drag force and the wind velocity is: F .2741 V 1.9842