Uverstas Gadjah Mada Departmet o Cvl ad Evrometal Egeerg Master o Egeerg Natural Dsaster Maagemet Data Processg Techques Curve Fttg: Regresso ad Iterpolato 3Oct7
Curve Fttg Reerece Chapra, S.C., Caale R.P., 99, Numercal Methods or Egeers, d Ed., McGrawHll Book Co., New York. Chapter ad, pp. 39398. 3Oct7
Curve Fttg A le or curve that represets a umber o data pots There are two methods to d such le or curve Regresso Iterpolato Egeerg applcatos Tred aalyss Hypothess testg 3Oct7 3
Regresso vs Iterpolato Regresso The data show sgcat errors or ose To d a sgle curve that represet geeral tred o the data Regresso le (curve) does ot eed to pass every data pot Iterpolato The data are accurate To d a curve or curves that ecompass(es) every data pot To estmate values betwee data pots 3Oct7 4
Regresso ad Iterpolato Etrapolato Smlar to terpolato but appled to outsde rage o data pots Not recommeded 3Oct7 5
Curve Fttg to Measured Data Tred aalyss Use o data tred (measuremets, epermets) to estmate values I the data are accurate, use terpolato techque I the data show ose, use regresso techque Hypothess testg Comparso betwee theoretcal values wth computed oes 3Oct7 6
represet data dstrbuto Recall: Statstcal Parameters Arthmetc mea Stadard devato Varace Coecet o varato! y y s y!! s S t y S t! S y t ( y ) c.v. s y! y % 3Oct7 7
Probablty Dstrbuto 3Oct7 req X Normal Dstrbuto oe o data dstrbutos that s requetly ecoutered egeerg 8
3Oct7 REGRESSION Smple Lear Regresso 9
Regresso: Leastsquare Method To d a sgle curve or ucto (appromate) that represets the geeral tred o the data The data show sgcat error The curve does ot eed to pass every data pot Methods Lear regresso (smple lear regresso) Learzed epressos Polyomal regresso Multple lear regresso Nolear regresso 3Oct7
Regresso: Leastsquare Method How Spreadsheet (MS Ecel) Computer program MatLab Freeware Octave Sclab Freemat 3Oct7
Smple Lear Regresso To d a straght le that represets the geeral tred o data pots: (,y ), (,y ),, (,y ) y reg a + a a : tercept : slope a MS Ecel INTERCEPT(y,) SLOPE(y,) 3Oct7
Smple Lear Regresso Error or resdual Dscrepaces betwee actual value o y (y data) ad appromate value o y (y reg ) accordg to lear epresso a + a! e y ( a +a ) Mmze the sum o squared resdues m! S # "! r $ m! " e! ( ) # $ m y a a "' # $( 3Oct7 3
Smple Lear Regresso How to d a ad a? Deretate the equato o S r twce; rstly w.r.t a ad lastly w.r.t a Set each o the two equatos to zero Solve the equatos or a ad a S r ( y a a a ) S r ( y a a a )! a y a! y a ( ) y 3Oct7 4
Eample # y ( ).5.5 3 3 4 4 4 5 3.5 5 6 6 6 7 5.5 y () 7 6 5 4 3 3 4 5 6 7 3Oct7 X 5
Eample # y y y reg (y y reg ) (y y mea ) 3Oct7.5.5.974.68686 8.57653.5 5 4.75.565.8645 3. 6 9.58986.34758.486 3 4 4. 6 6 3.4857.3653.3653 4 5 3.5 7.5 5 4.67857.58965.5 5 6 6. 36 36 5.743.79794 6.645 6 7 5.5 38.5 49 5.94649.9998 4.986 8 4. 9.5 4.997.749 6
Eample # a y y 4 7 3.4 8 7 4 y ( ) a! 3.4.83986 4 ( ) 8( 4).83986 7( 4) ( 8) 7 9.5 ( ).749 3Oct7 7
Eample # Y 7 6 5 4 3 3 4 5 6 7 8 X data regresso 3Oct7 8
Error Error Stadard error magtude s y! S r Notce ts smlarty wth stadard devato s y!! S y r ( a a ) S t! S y t ( y ) 3Oct7 9
Error Drece betwee the two errors sges a mprovemet o the predcto or a reducto o error r S t S r S t r S r S t y ( )( y ) ( ) y y ( ) coecet o determato correlato coecet 3Oct7
Error ( ) ( ) S r y a a.997 S! t y y.749! r S r S t.9997.749.86838 r.93836 3Oct7
Eample # y ( ) 5.5 6 3 3.5 3 4 4 4 5 5 6.5 6 7.5 y () 7 6 5 4 3 3 4 5 6 7 3Oct7 X
3Oct7 REGRESSION Regresso o Learzed Epresso 3
Lear Regresso Learzed olear equatos Logarthmc eq. à lear eq. Epoetal eq. à lear eq. th order polyomal eq. ( > ) à lear eq. etc. 3Oct7 4
Lear Regresso 3Oct7 y! y aeb l y l a! ly la+b b 5
Lear Regresso 3Oct7 y! y ab log y! loga! logy loga+blog b log 6
Lear Regresso 3Oct7 y! y a b+ /y! y b+ a a + b a! b a! a / 7
3Oct7 REGRESSION Polyomal Regresso 8
Polyomal Regresso Some egeerg data, although ehbtg a marked patter, s poorly represeted by a straght le Method : Coordate trasormato (learzed olear eq.) Method : Polyomal regresso The mthdegree polyomal! y a +a +a +...+a m m The sum o the squares o the resduals S r e y a a +a m +...+a m! ( ) 3Oct7 9
The leastsquare method eteded to t the data to a mthdegree polyomal These equatos ca be set equal to zero ad rearraged to develop a set o ormal equatos S r a S r a! m ( y a a +a m +...+a m ) S r a y a a +a m +...+a m S r a... ( ) ( y a a +a m +...+a m ) m ( y a a +a m +...+a m ) 3Oct7 3
m a +a +a +...+a m y! a 3 m+ +a +a +...+a m y 3 4 m+ a +a +a +...+a m y... m m+ a +a m+ m +a +...+a m m y There are m+ lear equatos havg m+ ukows,.e. a, a, a,, a m These lear equatos ca be smultaeously solved by usg methods such as Gauss elmato GaussJorda Jacob terato Matr verso 3Oct7 3
Eample Ft a secodorder polyomal to the data the table o the rght! y a +a +a Aswer y.47857+.3599+.867 r S r S t 3.74657 53.39.9985! r.9995 y. 7.7 3.6 3 7. 4 4.9 5 6. 3Oct7 3
3Oct7 REGRESSION Multple Lear Regresso 33
Multple Lear Regresso Suppose the depedet varabel y s a lear ucto o two depedet varables ad! y a +a +a The best values o the coecets are determed by settg up the sum o the squares o the resduals S r! ( y a a a ) 3Oct7 34
Multple Lear Regresso Deretatg ths equato w.r.t each o the ukow coecets S r a ( y a a a ) S r a y a a a ( ) S r a y a a a! ( ) Equatg the deretals to zero ad epressg the resulted equato as a set o smultaeous lear eqs yeld a +a +a y! a +a +a y a +a +a y 3Oct7 35
Multple Lear Regresso Wrtte matr orm 3Oct7 " $ $ $ $ $ $ $ $! # % ' '( ' ' * ) '* ' + * ' ' & a a a ( *, * * * ) * *.* * * + * y y y, * * * * * *.* 36
Eample Fd the best lear equato that ts to the data the table o the rght Aswer y 5+ 4 3! R y 5.5 9 3 4 6 3 7 7 3Oct7 37
Multple Lear Regresso Multple lear regresso ca be useul the dervato o power equatos o the geeral orm! y a a a... m a m Such equatos are etremely useul whe ttg epermetal data I order to use the multple lear regresso, the equato s trasormed by takg ts logarthm to yeld! logy loga +a log +a log +...+a m log m 3Oct7 38
3Oct7 REGRESSION Geeral Lear Least Squares 39
Geeral Lear Least Squares The three types o regresso that have bee preseted,.e. smple lear, polyomal, ad multple lear ca be epressed a geeral leastsquares model! y a z +a z +a z +...+a m z m where z, z,, z m are m+ deret uctos m+ s the umber o depedet varables + s the umber o data pots The above epresso ca be wrtte a matr orm {! Y }! " Z # $ { A } 3Oct7 4
Geeral Lear Least Squares {! Y }! " Z # $ { A }! % %! " Z # % $ % % % %! "% a a... a m a a... a m......... a a a m!! " Z# T! $ " Z # $ { A }! " Z # T $ # & & & & & & & $ & { Y} {Y} cotas the observed values o the depedet varables [Z] a a matr o the observed values o the depedet varables {A} cotas the ukow coecets # m & S r % y a j z j ( j! $ ' 3Oct7 4
Geeral Lear Least Squares!! " Z# T! $ " Z # $ { A }! " Z # T $ { Y} Soluto strategy LU decomposto Cholesky s method Matr verse approach! { A}! " Z # $! "% T! " Z # # $ $& T! Z " # $ { Y} 3Oct7 4
3Oct7 INTERPOLATION Newto Method Lagrage Method 43
Iterpolato 3Oct7 lear quadratc cubc 44
Iterpolato Stuato Need to estmate termedate values betwee precse data pots. The most commo method used or ths purpose s polyomal terpolato Geeral ormula or a thorder polyomal s! ( ) a +a +a +...+a There s oly oe polyomal o order or less that passes through all + data pots. 3Oct7 45
Iterpolato Soluto or th order polyomal requres + data pots Avalable methods to d th order polyomal that terpolates + data pots are: Newto Method Lagrage Method 3Oct7 46
Lear Iterpolato: Newto Method ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) + () ( ) () ( ) 3Oct7 47
Quadratc Iterpolato: Newto Method ( ) ( ) ( )( ) ( ) ( ) ( )! b b b b b b b b b b b b b b b b b a a a + + + + + + + + " " # " %" $ "" " # "" %" $ ( ) a a a + + ï î ï í ì + b a b b b a b b b a 3Oct7 48
Quadratc Iterpolato: Newto Method ( ) ( ) ( ) ( ) [ ] [ ] [ ],,, b ( ) b ( ) ( ) [ ], b 3Oct7 49
Polyomal Iterpolato: Newto Method ( ) ( ) ( )( ) ( )...... + + + b b b ( ) [ ] [ ] [ ],,...,,...,,, b b b b 3Oct7 5
Polyomal Iterpolato: Newto Method [ ] ( ) ( ) [ ] [ ] [ ] [ ] [ ] [ ],...,,,...,,,,...,,,,,,, k k j j k j j j j ( ) ( ) ( ) [ ] ( )( ) [ ] ( )( ) ( ) [ ],...,,......,,, + + + + 3Oct7 5
Polyomal Iterpolato: Newto Method ( ) Computatoal Steps st d 3rd ( ) [, ] [,, ] [ 3,,, ] ( ) [, ] [ 3,, ] ( ) [ 3, ] 3 3 ( 3 ) 3Oct7 5
Polyomal Iterpolato: Lagrage Method ( ) ( ) ( ) ( ) Õ å ¹ j j j j L L 3Oct7 53
Eample 7 3Oct7 ( ).5 4 3. 5 6 3 6. () 6 5 4 3 3 4 5 6 7 X 54
SPLINE INTERPOLATION Lear Sple Quadratc Sple Cubc Sple 3Oct7 55
Sple Iterpolato For + data pots à thorder terpolatg polyomals There s a case where a ucto s geerally smooth but udergoes a abrupt chage somewhere alog the rego o terest Hgherorder polyomals, >>, ted to swg through wld oscllatos the vcty o a abrupt chage Lowerorder polyomal, <<, mght better represet the data patter Lowerorder polyomals: sple terpolato Lear sples ( ) Quadratc sples ( ) Cubc sples ( 3) 3Oct7 56
Polyomal vs Sple Iterpolatos thorder polyomal»» 3Oct7 57
Lear Sples storder sple: straght le Ordered data pots:,,,, ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) m m m + + +... ( ) ( ) j j m + + slope: 3Oct7 58
Lear Sples Lear sples They are thereore detcal to lear terpolato The drawback o lear sples s that they are ot smooth At data pots where two sples meet (called a kot), the slope chages abruptly The rst dervatve o the ucto s dscotuous at kots The above dececy s overcome by usg hgherorder polyomal sples that esure smoothess at the kots by equatg dervatves at these pots 3Oct7 59
Quadratc Sples Quadratc sples I order to esure that the mth dervatves are cotuous at the kots, a sple o at least m+ order must be used 3rd order polyomals or cubc sples that esure cotuous rst ad secod dervatves are most requetly used practce. The dscotuous thrd ad ourth dervatves caot usually be detected vsually, thus they ca be gored 3Oct7 6
Quadratc Sples Objectve: to derve a dorder polyomal or each terval betwee data pots Those polyomals have to show cotuous rst dervatve at data pots The geeral ormula o a dorder polyomal a + b + c ( ) For + data pots (,,,, ) there are tervals, so that there are 3 ukow costats (a, b, c ;,,, ) to evaluate Requres 3 equatos 3Oct7 6
Quadratc Sples The 3 equatos. The sple curves tersect the kots, thus the sples at ad tervals meet at data pot [, ( )] a a + b + b + c + c ( ) ( ), 3,, ( ) eqs.. The rst sple curve passes through the rst data pot ( ) ad the last sple curve passes through the ed pot ( ) a a + b + b + c + c ( ) ( ) eqs. 3Oct7 6
Quadratc Sples The 3 equatos 3. The gradets (the rst dervatves) o the sple curve at the teror kots are equal! ( ) a+b a! +b a +b, 3,, ( ) eqs. 4. Assume that the secod dervatve s zero at the rst data pot a eq. as a cosequece, the rst two data pots ( ad ) are coected wth a straght le 3Oct7 63
Quadratc Sples The 3 equatos ( ) + + ( ) + 3 3Oct7 64
Cubc Sples Objectve: to derve a 3rdorder polyomal or each terval betwee data pots Those polyomals have to show cotuous rst ad secod dervatves at data pots The geeral ormula o a 3rdorder polyomal ( ) a 3 +b +c +d! For + data pots (,,,, ) there are tervals, so that there are 4 ukow costats (a, b, c, d ;,,, ) to evaluate Requres 4 equatos 3Oct7 65
Cubc Sples The 4 equatos. The sple curves tersect the kots, thus the sples at ad tervals meet at data pot [, ( )] à ( ) eqs.. The rst sple curve passes through the rst data pot ( ) ad the last sple curve passes through the ed pot ( ) à eqs. 3. The gradets (the rst dervatves) o the sple curve at the teror kots are equal à ( ) eqs. 4. The secod dervatves o the sple curve at the teror kots are equal à ( ) eqs. 5. The secod dervatves at the ed kots are zero à eqs. 3Oct7 66
Cubc Sples The 4 equatos The th codto brgs to the ollowg cosequece The sple curves at the rst ad last tervals are straght les the rst two data pots are coected by a straght le the last two data pots are coected by a straght le There s a alteratve codto The secod dervatves at the ed kots are kow 3Oct7 67
Cubc Sples The 4 equatos ( ) + + ( ) + ( ) + 4 It s possble to do mathematcal mapulatos so that the cubc sple that requres ( ) equatos to evaluate à reer to Chapra ad Caale (99), pp. 395396. 3Oct7 68
Cubc Sples ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( )( ) ( ) 3 3 6 6 6 6 ú û ù ê ë é + ú û ù ê ë é + + ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) [ ] ( ) ( ) ( ) [ ] + + + + + + + + 6 6!!tervals!! ( )!! ( ) " # $ $ % $ $ ( )!equato ukows at each terval: ( ) ( ) da 3Oct7 69
3Oct7 7