Lec 7BUE

Embed Size (px)

Citation preview

  • 7/27/2019 Lec 7BUE

    1/20

    ScheduleWeek Date Topic Classification of Topic

    1 9 Feb. 2010 Introduction toNumerical Methodsand Type of Errors

    Measuring errors, Binaryrepresentation, Propagation of errorsand Taylor series

    2 14 Feb. 2010 Nonlinear Bisection Method

    3 21 Feb. 2010 Newton-Raphson Method

    4 28 Feb. 2010 Interpolation Lagrange Interpolation

    5 7 March 2010 Newton's Divided Difference Method

    6 14 March 2010 Differentiation Newton's Forward and BackwardDifference

    7 21 March 2010 Regression Least squares

    8 28 March 2010 Systems of Linear

    Equations

    Gaussian Jordan

    9 11 April 2010 Gaussian Seidel

    10 18 April 2010 Integration Composite Trapezoidal and SimpsonRules

    11 25 April 2010 Ordinary DifferentialEquations

    Euler's Method

    12 2 May 2010 Runge-Kutta 2nd and4th order Method

  • 7/27/2019 Lec 7BUE

    2/20

    Linear Regression

  • 7/27/2019 Lec 7BUE

    3/20

    3

    What is Regression?What is regression? Given ndata points ),(,...),,(),,( 2211 nnyxyxyx

    best fit )(xfy to the data. The best fit is generally based onminimizing the sum of the square of the residuals, rS

    Residual at a point is

    )( iii xfy

    n

    i

    iir xfyS1

    2))(( ),( 11yx

    ),( nn yx

    )(xfy

    Figure. Basic model for regression

    Sum of the square of the residuals

    .

  • 7/27/2019 Lec 7BUE

    4/20

    4

    Least Squares CriterionThe least squares criterion minimizes the sum of the square of theresiduals in the model, and also produces a unique line.

    2

    1

    10

    1

    2

    n

    i

    ii

    n

    i

    ir xaayS

    x

    iiixaay10

    11

    , yx

    22, yx

    33, yx

    nnyx ,

    iiyx ,

    iiixaay10

    y

    Figure. Linear regression of y vs. x data showing residuals at a typical point, xi .

  • 7/27/2019 Lec 7BUE

    5/20

    5

    Finding Constants of Linear Model

    2

    1

    10

    1

    2

    n

    i

    ii

    n

    i

    ir xaayS Minimize the sum of the square of the residuals:

    To find

    0121

    10

    0

    n

    i

    iir xaay

    aS

    021

    10

    1

    n

    i

    iiir xxaay

    a

    S

    giving

    0a and 1a we minimize with respect to 1a 0aandrS .

    yxanayxaa 10n

    1iii

    n

    1i1

    n

    1i0

    xyxaxaxyxaxan

    1i

    210i

    n

    1ii

    2i

    n

    1i1i

    n

    1i0

  • 7/27/2019 Lec 7BUE

    6/20

    6

    Finding Constants of Linear Model0aSolving for

    2

    2

    1

    xxn

    yxxyn

    a

    and

    or

    xxn

    xyxyx

    a2

    2

    2

    0

    1aand directly yields,

    )xaya( 10

  • 7/27/2019 Lec 7BUE

    7/207

    Example 1The torque, T needed to turn the torsion spring of a mousetrap throughan angle, is given below.

    Angle, Torque, T

    Radians N-m

    0.698132 0.188224

    0.959931 0.209138

    1.134464 0.230052

    1.570796 0.250965

    1.919862 0.313707

    Table: Torque vs Angle for atorsional spring

    Find the constants for the model given by

    10 aaT

    Figure. Data points for Angle vs. Torque data

    0.1

    0.2

    0.3

    0.4

    0.5 1 1.5 2

    (radians)

    Torque(N-m

  • 7/27/2019 Lec 7BUE

    8/208

    Example 1 cont.

    1a

    The following table shows the summations needed for the calculations ofthe constants in the regression model.

    2 T

    Radians N-m Radians 2 N-m-Radians

    0.698132 0.188224 0.487388 0.131405

    0.959931 0.209138 0.921468 0.200758

    1.134464 0.230052 1.2870 0.260986

    1.570796 0.250965 2.4674 0.394215

    1.919862 0.313707

    3.6859 0.602274

    6.2831 1.19218.8491 1.5896

    Table. Tabulation of data for calculation of important

    5

    1i

    5n

    Using equations described for

    2

    2

    1

    5

    TT5

    a

    228316849185

    1921128316589615

    ..

    ...

    2

    1060919

    .N-m/rad

    summations

    0aT

    and with

  • 7/27/2019 Lec 7BUE

    9/209

    Example 1 cont.

    n

    T

    T i

    i

    5

    1_

    Use the average torque and average angle to calculate

    _

    1

    _

    0 aTa

    n

    i

    i

    5

    1_

    5

    1921.1

    1103842.2

    5

    2831.6

    2566.1

    Using,

    )2566.1)(106091.9(103842.2 21 1

    101767.1 N-m

    0a

  • 7/27/2019 Lec 7BUE

    10/2010

    Example 1 Results

    Figure. Linear regression of Torque versus Angle data

    Using linear regression, a trend line is found from the data

  • 7/27/2019 Lec 7BUE

    11/20

    Nonlinear Regression

    Some popular nonlinear regression models:

    1. Exponential model: )( bxaey

    2. Power model: )( baxy

    3. Saturation growth model:

    xb

    axy

    4. Polynomial model: )( 10m

    mxa...xaay

  • 7/27/2019 Lec 7BUE

    12/2012

    Exponential ModelGiven best fit

    bxaey to the data.

    bxaey

    ),(nn

    yx

    ),( 11 yx

    ),(22

    yx

    ),(ii

    yx

    )(ii

    xfy

    ),(,...),,(),,( 2211 nn yxyxyx

  • 7/27/2019 Lec 7BUE

    13/2013

    Finding constants of Exponential ModelConsider the equation Taking the logarithm on both sides, we get

    bxaey

    bxalnelnalnaelnyln bxbx

    bxAY Then by using the linear module let then,alnA,Yyln

  • 7/27/2019 Lec 7BUE

    14/2014

    Example 2-Exponential ModelMany patients get concerned when a test involves injection of a

    radioactive material. For example for scanning a gallbladder, a few dropsof Technetium-99m isotope is used. Half of the techritium-99m would begone in about 6 hours. It, however, takes about 24 hours for theradiation levels to reach what we are exposed to in day-to-day activities.Below is given the relative intensity of radiation as a function of time.

    Table. Relative intensity of radiation as a function of time.

    t(hrs) 0 1 3 5 7 9

    1.000 0.891 0.708 0.562 0.447 0.355

  • 7/27/2019 Lec 7BUE

    15/2015

    Example 2-Exponential Model cont.The relative intensity is related to time by the equation

    Find:

    a) The value of the regression constants and

    b) Radiation intensity after 24 hours

    tAe

    A

  • 7/27/2019 Lec 7BUE

    16/2016

    t Y t

    0 1.000 0 0 0

    1 0.891 -0.115 1 -0.115

    3 0.708 -0.345 9 -1.035

    5 0.562 -0.576 25 -2.88

    7 0.447 -0.805 49 -5.635

    9 0.355 -1.035 81 -9.315

    3.963

    lnY 2t

    876.2Y 25t 165t2

    98.18Yt

  • 7/27/2019 Lec 7BUE

    17/2017

    1151.0

    365

    98.41

    625990

    9.7188.113

    25)165(6

    )876.2(25)98.18(6

    tt6

    tYYt6

    222

    Calculating the Other Constant

    The value of can now be calculated

    and the value of A can now be calculated

    9998.0A

    00025.047958.047933.0)6

    25(1151.0

    6

    876.2tYAln

  • 7/27/2019 Lec 7BUE

    18/2018

    Plot of data

  • 7/27/2019 Lec 7BUE

    19/2019

    Plot of data and regression curve

  • 7/27/2019 Lec 7BUE

    20/2020

    Relative Intensity After 24 hrs

    The relative intensity of radiation after 24 hours

    241151.09998.0 e2103160.6

    This result implies that only %317.61009998.0

    10316.6 2

    radioactive intensity is left after 24 hours.