Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.

Similar presentations


Presentation on theme: "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting."— Presentation transcript:

1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting

2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Describes techniques to fit curves (curve fitting) to discrete data to obtain intermediate estimates. There are two general approaches two curve fitting: –Data exhibit a significant degree of scatter. The strategy is to derive a single curve that represents the general trend of the data. –Data is very precise. The strategy is to pass a curve or a series of curves through each of the points. 2 Part 4 CURVE FITTING

3 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Easiest Approach is “Eyeballing” If the data has scatter –Try to fit a straight line or curve to the data If the data is precise –Connect all the data with straight lines –Try to capture the shape of the data with curves 3 We’d like to develop an approach that is less qualitative

4 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. No matter how you model the data In engineering two types of applications are encountered: –Trend analysis. Predicting values of dependent variable, may include extrapolation beyond data points or interpolation between data points. –Hypothesis testing. Comparing existing mathematical model with measured data. 4 Before we do either we’ll need to develop some mathematical background

5 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Part Organization Chapter 14 –Brief Review of Statistics –Linear Regression Chapter 15 –Polynomial Regression –Multiple Linear Regression Chapter 16 – Skip Chapter 17 –Polynomial Interpolation Chapter 18 –Spline and Piecewise Interpolation 5 Creating a best fit mathematical model of the data that doesn’t necessarily pass through every point Passing a line or curve through each of the points

6 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6 Part 4 Chapter 14 Linear Regression

7 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.Review of Statistics 2.Introduction to linear regression 7

8 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8 Mathematical Background Simple Statistics Statistics are widely used to describe engineering data We’ll start out by describing the most useful of these parameters Note: In these first examples we are talking about one parameter – not how a dependent variable changes with an independent variable – that comes later

9 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. These descriptive statistics are most often selected to represent –The location of the center of the distribution of the data, –The degree of spread of the data. 9

10 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Arithmetic mean (the average) 10 The sum of the individual data points (y i ) divided by the number of points (n).

11 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Table 14.2 Measurements of the coefficient of thermal expansion of structural steel.

12 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Example 14.1 12

13 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 13

14 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Standard deviation. The most common measure of the spread in a sample. or 14 Sum of the squares of the residuals Standard Deviation Variance More convenient because you don’t have to precalculate the mean

15 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 15 Variance. Representation of spread - it’s the square of the standard deviation. Coefficient of variation – a representation of the spread as a percentage, based on the average. Degrees of freedom

16 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 16

17 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 17

18 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Histograms 18 Figure 14.3

19 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Part Table PT5_02.jpg

20 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 20 Defaults to 10 bins

21 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Random Numbers MATLAB includes functions to generate random numbers rand –Random uniformly distributed numbers between 0 and 1 randn –Random numbers normally distributed with a mean of 0 and a standard deviation of 1 21

22 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Uniform Random Numbers rand R = rand(m,n) –Generates an m by n matrix of uniformly distributed numbers between 0 and 1 Runiform = low + (up – low)*rand(m,n) 22

23 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Example 14.2 If the initial velocity is 0, the downward velocity of the free-falling bungee jumper can be predicted with the following analytical solution 23

24 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Suppose that  g=9.81 m/s^2  m=68.1 kg  t = 4 sec  Cd is unknown,  but it varies uniformly between 0.225 and 0.275…  ie +/- 10% around 0.250 kg/m.  Use the rand function to generate 1000 values of Cd  Study how v varies 24

25 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 25

26 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 26 Analytical solution

27 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 27 Monte Carlo Simulation

28 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 28

29 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 29

30 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 30

31 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 31

32 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 32 Part 4 Chapter 14 Linear Regression

33 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.Review of Statistics 2.Introduction to linear regression 33

34 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 34 Linear Least Squares Regression Linear Regression Fitting a straight line to a set of paired observations: (x 1, y 1 ), (x 2, y 2 ),…,(x n, y n ). a 0 - intercept a 1 - slope

35 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 35 Linear Least Squares Regression We can get an idea of how good the fit is by comparing the predicted values of y to the measured y values e- error, or residual, between the model and the observations

36 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 36 What is the criteria for a “Best” Fit? Minimize the sum of the residual errors for all available data: n = total number of points However, this is an inadequate criterion, so is the sum of the absolute values of the residual

37 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 37 Minimizes the error of any one point Any straight line within the dashed lines will minimize the sum of the absolute value of the residuals

38 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 38 Best strategy is to minimize the sum of the squares of the residuals between the measured y and the y calculated with the linear model: Yields a unique line for a given set of data.

39 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 39 Least-Squares Fit of a Straight Line To minimize Sr, we need to find the partial derivatives with respect to a0 and a1 and set them equal to 0

40 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 40 Least-Squares Fit of a Straight Line Mean Values 2 equations and 2 unknowns

41 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 41

42 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Example 14.4 Force vs. Wind Velocity in a Wind Tunnel Fit a straight line to the x and y values of the data in Table 14.1 42 V, m/s 1020304050607080 F, N257038055061012208301450

43 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. First let’s plot the data

44 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 44 Finds the best fit line and plots it

45 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 45

46 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Quantification of the Error of Linear Regression 46

47 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Standard Error 47 Quantifies the spread around the regression line as opposed to the standard deviation, which quantifies the spread around a mean value Similar to the standard deviation

48 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Standard Error of the Estimate Regression data showing (a) the spread of data around the mean of the dependent data and (b) the spread of the data around the best fit line: The reduction in spread represents the improvement due to linear regression.

49 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Correlation Coefficient 49 r is a measure of the goodness of the fit When r = 1 the fit is perfect Sum of the squares of the error – the difference between the true value and the predicted value Sum of the squares of the difference between the measured value and the mean

50 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. What is the correlation coefficient, R? 50 It’s a measure of how good a fit you’ve got. If R = 1 the fit is perfect. If R=0 it’s just the average of the y values.

51 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 51

52 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 52 Determines how ‘good’ the fit is

53 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. It might be useful to make this into a function 53 Notice this is a modified version of the algorithm shown in figure 14.15

54 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Or… we could use the built-in MATLAB functions 54

55 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 55 MATLAB Syntax Our book’s Syntax

56 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Or we could use left division 56

57 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Using Left Division to find the coefficients 57

58 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Or we could use left division 58

59 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. What if we want to force the fit through 0? The physics of the situation might dictate that if:  x is equal to 0  y must equal 0  For example  If the wind velocity is 0  The force on the object in the wind tunnel must be 0 59

60 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 60 Least-Squares Fit of a Straight Line To minimize Sr, we need to find the derivatives and set them equal to 0

61 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Once we know 61

62 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 62

63 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 63 Part 4 Chapter 14 Linear Regression

64 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Linearization of Non-linear Relationships It is often useful to transform non-linear relations so that they plot as a straight line. 64

65 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 65 Exponential Equation

66 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 66 Power Equation

67 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 67 Saturation Growth Equation

68 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider the data plotted on the right Notice that it appears to be a straight line when plotted on a log-log scale This leads us to believe it might best be modeled using a power equation 68

69 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Data to be fit to a power equation – from Chapra’s other text Table 17_03.jpg

70 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 70

71 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 71

72 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 72

73 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 73

74 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Number of similar problems in the homework Strategy to determine the appropriate model –Plot the data on an xy scatter plot –Plot the data on a semilog scatter plot –Plot the data on a loglog scatter plot –Plot 1/x vs 1/y on an xy scatter plot Once you’ve determined the model type, find the constants using linear regression. 74


Download ppt "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting."

Similar presentations


Ads by Google