Numerical Tech for Interpolation & Curve Fitting

Embed Size (px)

Citation preview

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    1/46

    Advanced Mathematical Methods

    for Civil Engineering Applications

    Wonsiri Punurai, PhDWonsiri Punurai, PhDDepartment of Civil EngineeringRoom 6391, EG Building 3Faculty of Engineering, Mahidol UniversityClass Web: www.egmu.net/~civil/wonsiri

    Numerical techniques for interpolation & curve fitting

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    2/46

    Basic Problems in relation to CE work

    Dial Gauge

    0

    75

    25

    50

    Experimental Data

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    3/46

    Curve Fitting

    {

    Linear Regression{ Polynomial Regression

    { Multiple Linear Regression

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    4/46

    Linear Regression

    Errors do exist between model and observation.

    Find the best line which minimizes the sum of error for all data

    ( )

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    5/46

    Least-square Fit of a Straight Line

    { Minimize sum of the square of the errors

    { Differentiate with respect to each coefficient:

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    6/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    7/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    8/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    9/46

    How good is our fit?

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    10/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    11/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    12/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    13/46

    Confidence Interval (CI)

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    14/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    15/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    16/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    17/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    18/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    19/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    20/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    21/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    22/46

    Linear Regression with MATLAB

    { Matlab function regress addresses the

    multiple linear regression problem based onthe least squares approach.

    { Matlab function regress estimates the

    model parameters and performing theregression model automatically.

    { Theregress function requires that thematrix of independent variables include a

    column of ones so that the model containsa constant term.

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    23/46

    Example use of functionregress

    { Given the following independent

    observations for variable Q and t:

    19.919151412.5127.95.502Q

    10987654321t

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    24/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    25/46

    1 2 3 4 5 6 7 8 9 100

    2

    4

    6

    8

    10

    12

    14

    16

    18

    20

    t

    Q

    19.919151412.5127.95.502Q

    10987654321t

    Figure 1: Plot of variable Q vs. t

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    26/46

    Now one wants to check if there exists a linear

    relationship between Q and t (e.g. one wants to

    predict Q when t is 11 and 12

    >> Use the regress function to estimate the model

    parameter and perform regression analysis.

    >>The r e g r e s s function requires that the matrix of

    independent variables include a column of ones so that

    the model contains a constant term.

    Create x in matlab

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    27/46

    Now lets apply theregress function to our data (note that Q and t have

    to be transposed according to the function requirements):

    Vector of regressionQ=b1+tb2+

    Confidence intervalsDefault is 95% CIIf contains zero, theconstant shall be excluded.

    95% CI for b195% CI for b2

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    28/46

    Discussion

    As a result, our model that can be used for prediction Q for given t look as follow

    Q=2.0081t

    Q

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    29/46

    1 2 3 4 5 6 7 8 9 100

    5

    10

    15

    20

    25

    t

    Q

    Data

    Model

    Figure 2 Original data and estimated regression model

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    30/46

    Q

    Qt

    Qt-1

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    31/46

    Q

    Q

    Qt-1Qt

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    32/46

    Curve Fitting

    { Linear Regression

    { Polynomial Regression

    { Multiple Linear Regression

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    33/46

    Polynomial Regression

    0 =

    Model equation

    Sum sq. error

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    34/46

    Normal Equations

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    35/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    36/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    37/46

    Polynomial Regression with MATLAB

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    38/46

    Solving previous example using Matlab

    Fit a 2nd orderpolynomial

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    39/46

    Matlab Polyval function

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    40/46

    Polyval Example

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    41/46

    Error Bounds

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    42/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    43/46

    Multiple Linear Regression

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    44/46

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    45/46

    Multivariate Fit in Matlab

  • 7/27/2019 Numerical Tech for Interpolation & Curve Fitting

    46/46

    Example