matematica 7 numerica - sitios de las cátedras facultad de ci

Post on 20-Jul-2022

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Universidad Nacional de Tucumán

FACULTAD DE CIENCIAS EXACTAS

Y TECNOLOGIA

7

MAGISTER EN

METODOS

NUMERICOS Y

COMPUTACIONALES

EN INGENIERIA

MATEMATICA

NUMERICA

OBJETIVOS

Aprender a usar Matlab para resolverproblemas que involucren interpolación y ajustepor mínimos cuadrados

Familiarizarse con los métodos numéricos deajuste de curvas por regresión de mínimoscuadrados

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

Tema 7Regresión de Datos

Teoría de la aproximación. Regresión por mínimoscuadrados discretos: aproximación a una recta,aproximación polinomial, funciones generales,criterios de ajuste. Regresión lineal múltiple.Regresión no lineal de datos. Mínimos CuadradosContinuos. Polinomios ortogonales. Funciones deMatlab

TEMAS

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

Tema 7Regresión de Datos

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA Por definición, la Función

de interpolación ajustaexactamente los datos.

INTERPOLACIÓN vs. REGRESIÓN

La Regresión, es apropiada cuando se manejan datos obtenidos con errores experimentales importantes.

x0

f(x0)

En regresión, se busca la curva que “más se aproxime”a los datos (menor error)

x0

f(x0)error

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

Teorema de Weierstrass

TEORÍA DE LA APROXIMACIÓN

Esto garantiza que cualquier función continuaen un intervalo cerrado pueda ser aproximadaen ese intervalo por un polinomio

Si f(x) es una función real definida en elintervalo [a,b]

Entonces para todo real > 0, existe unpolinomio Pn(x) definido en [a,b] tal que:

b][a,x ε(x)Pf(x) n

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN DE DATOSEl pr

oblema

es

CÓM

O M

INIM

IZAR

EL E

RROR.

)

n

1i

i10i

n

1i

i xaa(ye

Con la suma de errores

n

1i

i10i

n

1i

i xaaye

Con la suma de valores absolutos de errores

Con el máximo error en valor absoluto

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN DE DATOS

La solución es minimizar la suma de los cuadrados de

los errores.

Esto conduce a la solución de Mínimos Cuadrados.

i

2

ir eS

El problema es cómo minimizar el error

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN DE DATOS

REGRESION LINEAL SIMPLE

Dados los puntos:

P1

P2P3

P4

P5

P6

P7

y=a0+a1x )y,(x),y,(x),y,(x),y,(x nnii2211

i10i xa a y )(calc

i10ii xa a y = e

n

1=i

2

i10i

n

1=i

2

ir xa a y = e = S Encontrar los valores de a0 y a1 que hacen mínimo Sr

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN DE DATOS

REGRESIÓN LINEAL SIMPLE

0

1)( xaay2

a 2

a

xaaya

= a

S

n

1=i

i10i

n

1=i 0

n

1=i

2

0

n

1=i

2

i10i

00

r

n

1=i

i1

n

1=i

i0 y a x a n

0

)x( xaay2

a2

a

xaaya

= a

S

n

1=i

ii10i

n

1=i 1

n

1=i

2

1

n

1=i

2

i10i

11

r

n

1=i

ii1

n

1=i

2

i0

n

1=i

i yx a x a x

Condición necesaria, el gradiente de Sr igual a cero

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL SIMPLE

n

1=i

ii1

n

1=i

2

i0

n

1=i

i yx a x a x

n

1=i

i1

n

1=i

i0 y a x a n

Sistema

2n

1=i

i

n

1=i

2

i

n

1=i

i

n

1=i

i

n

1=i

ii

1

2n

1=i

i

n

1=i

2

i

n

1=i

ii

n

1=i

i

n

1=i

2

i

n

1=i

i

0

xn

1x

yxn

1yx

a

xn

1x

yxxn

1xy

n

1

a

Solución Explícita

ERROR

Desviación estándar de la estimación:

2n

Ss r

y/x

2

i

2

ci

2

i

t

rt2

)y(y

)y(y)y(y

S

SSR

Coeficiente de determinación:

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

ANÁLISIS DEL ERROR

La Regresión permite asignar parte de la variabilidad total de los datos a la función ajustada.

2

2

c

2

t

rt2

)y(y

)y(y)y(y

S

SSR

variabilidad total

variabilidad respecto de la

función

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

Sy/x

Sy

Sy: Variabilidad respecto de la media

Sy/x: Variabilidad respecto de la función lineal de

regresión

2n

SS

1n

SS

ry/x

ty

ANÁLISIS DEL ERROR

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL SIMPLE

La precondición para emplear Regresión

Lineal es que exista RELACIÓN LINEALentre variables (!!!)

¿Y si no es así?

LINEALIZAR

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL SIMPLE

Ejemplo: Adsorción en carbón

0

50

100

150

200

250

300

350

0 100 200 300 400 500 600

C

q

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL SIMPLE

ncKq

0

0.5

1

1.5

2

2.5

3

0 0.5 1 1.5 2 2.5 3

X=Log(c)

Y=

Lo

g(q

)

cnlog Klog qlog 101010

logK = 1.8733, K = 101.6733 = 74.696, n = 0.2289

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

Ejemplo: Adsorción en carbón

REGRESIÓN LINEAL SIMPLE

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Lineal)

)y,(x),y,(x),y,(x),y,(x nnii2211 Datos

i10i xa a y Lineal

2

i2i10i xa xa a y Cuadrática

3

i3

2

i2i10i xa xa xa a y Cúbica

General m

im

3

i3

2

i2i10i xa xa xa xa a y

Se deben encontrar los valores de a0 , a1, a2, … am

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Lineal)

Residuos (errores):

Condiciones Necesarias:Las derivadas de Sr respecto de cada ai igualadas a cero

)xa xa xa xa (a y = em

im

3

i3

2

i2i10ii

Suma de Residuos (errores):

n

1=i

2m

m

3

3

2

210

n

1=i

2

ir )]xa xa xa x a (a [y = e = S

n

1i

2m

im

2

i2i10ir )]xaxaxa(a[yS min

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Lineal)

Considerando la condición necesaria para la existencia de un mínimo, gradiente igual a cero, resulta:

n

1=i

i

m

i

n

1=i

i

2

i

n

1=i

ii

n

1=i

i

m

2

1

0

n

1=i

2m

i

n

1=i

2m

i

n

1=i

1m

i

n

1=i

m

i

n

1=i

2m

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

1m

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

n

1=i

m

i

n

1=i

2

i

n

1=i

i

yx

yx

yx

y

a

a

a

a

xxxx

xxxx

xxxx

xxxn

Matriz del Sistema, Simétrica Ecuaciones Normales

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Lineal)

n

1=i

i

m

i

n

1=i

i

2

i

n

1=i

ii

n

1=i

i

m

2

1

0

n

1=i

2m

i

n

1=i

2m

i

n

1=i

1m

i

n

1=i

m

i

n

1=i

2m

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

1m

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

n

1=i

m

i

n

1=i

2

i

n

1=i

i

yx

yx

yx

y

a

a

a

a

xxxx

xxxx

xxxx

xxxn

Regresión Lineal Simple

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Lineal)

n

1=i

i

m

i

n

1=i

i

2

i

n

1=i

ii

n

1=i

i

m

2

1

0

n

1=i

2m

i

n

1=i

2m

i

n

1=i

1m

i

n

1=i

m

i

n

1=i

2m

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

1m

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

n

1=i

m

i

n

1=i

2

i

n

1=i

i

yx

yx

yx

y

a

a

a

a

xxxx

xxxx

xxxx

xxxn

Regresión Cuadrática

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Ejemplo)

x 0 1.0 1.5 2.3 2.5 4.0 5.1 6.0 6.5 7.0 8.1 9.0

y 0.2 0.8 2.5 2.5 3.5 4.3 3.0 5.0 3.5 2.4 1.3 2.0

x 9.3 11.0 11.3 12.1 13.1 14.0 15.5 16.0 17.5 17.8 19.0 20.0

y -0.3 -1.3 -3.0 -4.0 -4.9 -4.0 -5.2 -3.0 -3.5 -1.6 -1.4 -0.1

-6

-4

-2

0

2

4

6

0 5 10 15 20 25

x

f(x)

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Ejemplo)

n

1=i

i

3

i

n

1=i

i

2

i

n

1=i

ii

n

1=i

i

3

2

1

0

n

1=i

6

i

n

1=i

5

i

n

1=i

4

i

n

1=i

3

i

n

1=i

5

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

yx

yx

yx

y

a

a

a

a

xxxx

xxxx

xxxx

xxxn

9943.36

6037.2

316.9

1.30

a

a

a

a

8223518116.12780147.7752835.246342.8

12780147.7752835.246342.83060.2

752835.246342.83060.2229.6

46342.83060.2229.624

3

2

1

0

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Ejemplo)

-6

-4

-2

0

2

4

6

0 5 10 15 20 25

x

f(x)

0.0121

0.3532

2.3051

0.3593

a

a

a

a

3

2

1

0

y = - 0.359 + 2.305x - 0.353x2 + 0.012x3

Ecuación de Regresión

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Análisis del Error)

CRITERIOS PARA SELECCIONAR EL ORDEN DEL POLINOMIO DE REGRESIÓN

1)(mn

Ss r

y/x

Desviación Estándar del Error mínima

Coeficiente de Determinación de regresión más

próximo a la unidad

n

1i

2m

im

2

i2i10ir )]xaxaxa(a[yS

2

i

2

ci

2

i

t

rt2

)y(y

)y(y)y(y

S

SSR

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Análisis del Error)

n

1i

2m

im

2

i2i10ir )]xaxaxa(a[yS

El grado óptimo delpolinomio de ajuste deMínimos Cuadradosresultará de la mínimaDesviación Estándar

1 2 3 4 m. . .

Sy/x

m

m óptimo

1)(mn

Ss r

y/x

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN POLINOMIAL (Análisis del Error)

n

1=i

i

m

i

n

1=i

i

2

i

n

1=i

ii

n

1=i

i

m

2

1

0

n

1=i

2m

i

n

1=i

2m

i

n

1=i

1m

i

n

1=i

m

i

n

1=i

2m

i

n

1=i

4

i

n

1=i

3

i

n

1=i

2

i

n

1=i

1m

i

n

1=i

3

i

n

1=i

2

i

n

1=i

i

n

1=i

m

i

n

1=i

2

i

n

1=i

i

yx

yx

yx

y

a

a

a

a

xxxx

xxxx

xxxx

xxxn

El aumento del orden del polinomio, incrementa tambiénel mal condicionamiento del sistema lineal para elcálculo de los coeficientes a. Surge una relación decompromiso entre precisión (orden m) y erroresnuméricos en el cómputo de los coeficientes.

Aumenta el Númerode Condición con elincremento del orden

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL (Generalización)

(x)fa(x)fa(x)fay mm2211

Para generalizar, (incluye RLS y polinomial), se toma:

Donde las fi(x) son las Funciones Base

Ejemplos:

1i

i x(x)f

1i

ix

1(x)f

1i

i (logx)(x)f

T

x πi 2sen(x)fi

Regresión polinomial

Polinomio de Fourier

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL (Generalización)

(x)fa(x)fa(x)fay mm2211

Si el número de datos es n.

)(xf )(xf )(xf

)(xf )(xf )(xf

)(xf )(xf )(xf

Z

nmn2n1

2m2221

1m1211

]y y [y{y} n21

T

]a a [a{a} m21

T

n

1i

2m

1j

ijjir ])(xfa[yS min

]e e [e{e} n21

T

ea[Z]{y}

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL (Generalización)

(x)fa(x)fa(x)fay mm2211

0a

S

0a

S

0a

S

m

r

2

r

1

r

Condición necesaria, el gradiente de Sr igual a

cero

{y}[Z] {a} [Z][Z] TT

Ecuaciones Normales

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL (Generalización)

(x)fa(x)fa(x)fay mm2211

Paso 1: Construir [Z] e {y}.

Paso 2: Conformar el

sistema de ecuaciones

Paso 3: Resolver el sistema lineal para encontrar

los coeficientes, es decir el vector {a}.

Algoritmo:

{y}[Z] {a} [Z][Z] TT

Paso 4: Evaluar

- Desviación Estándar

- Coeficiente de

determinación

mn

Ss r

xy

/

2

2

2

)(

)(

1

11

yy

yy

mn

nR

i

Cii

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL MÚLTIPLE

22110 xaxaay

Dadas variables independientes x1,x2 y la correspondiente variable dependiente y el problema de Regresión Lineal Múltiple consiste en encontrar la mejor relación lineal que ajuste los datos.

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL MÚLTIPLE

Dado un conjunto de N: variable independientes y con variables indepen-dientes ; u, v, & w

Encontrar la mejor función lineal que aproxime los datos

La minimización de la suma de los errores cuadráticos resulta en 4 Ecs. Para 4 incógnitas a, b, c & d.

1 1 1 1 2 2 2 2

2

1

, , , ; , , , ;........,

, , , ;

( )

N N N N

N

r i i i i

i

y u v w y u v w

y u v w

y a bu cv dw

S y a bu cv dw

0d

S ,0

c

S,0

b

S,0

a

S rrrr

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL MÚLTIPLE

donde

R

Ecu

acion

es

Nor

males

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL

, n1,2,i)y,(xP ii Datos:

Curva (no lineal): )a,,a,a;f(xy m21i

calc

i

De modo que hay que encontrar los ai para que el funcional

n

1i

2calc

ii

n

1i

i yyeSr

im21ii e)a,,a,a;f(xy

La limitación ahora es que la aplicación de lacondición necesarias no conduce a un sistema lineal yla búsqueda de {a} debe hacerse por un procedimientonumérico (método de Gauss-Newton)

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL

Se parte de valores iniciales:

(k)

i

1)(k

ii aaΔa

m

m

(k)

i2

2

(k)

i1

1

(k)

i(k)

i

1)(k

i Δaa

)f(xΔa

a

)f(xΔa

a

)f(x)f(x)f(x

(k)

im

m

(k)

i2

2

(k)

i1

1

(k)

i(k)

ii eΔaa

)f(xΔa

a

)f(xΔa

a

)f(x)f(xy

][(0)

m

(0)

2

(0)

1

(0)a,...,a,a{a}

)a,...,a,a;f(x)f(x(k)

m

(k)

2

(k)

1i

(k)

i

La función evaluada con los valores del vector {a} en la etapa k de iteración es:

Usando una aproximación de Taylor de primer orden:

Donde

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL

m

(k)

nn

2

(k)

nn

1

(k)

nn

m

(k)

22

2

(k)

22

1

(k)

22

m

(k)

11

2

(k)

11

1

(k)

11

a

)(xf

a

)(xf

a

)(xf

a

)(xf

a

)(xf

a

)(xf

a

)(xf

a

)(xf

a

)(xf

[Jz]

eΔa[Jz]{d}

(k)

nn

(k)

22

(k)

11

)f(xy

)f(xy

)f(xy

{d}

T(k)

m

(k)

2

(k)

1

(k)e, ,e ,e{e}

Las ecuaciones anteriores se pueden poner en forma matricial:

Con

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL

n

1i

2

ir )(eS min

{d}[Jz] Δa [Jz][Jz] TT ¨

A efectos de ir disminuyendo progresivamente Sr, en cada iteración k, se calculan los a resolviendo el sistema lineal:

Y se calculan los nuevos a, más próximos al óptimo con:

(k)

i

(k)

i

1)(k

i Δaaa

Estos valores sirven para una nueva iteración.

Con este procedimiento, en cada etapa se va disminuyendo Sr, aproximándose al óptimo:

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL(Algoritmo)

{d}[Jz] a}{ [Jz][Jz] TT

Paso 3: Para todos los datos evaluar f(xi)

Paso 4: Para todos los datos evaluarf(xi;a1,a2,…,am)/ak

Paso 1: k=1

Paso 5: definir [Jz] and {d}

Paso 6: Calcular {a} resolviendo

Paso 7: Actualizar {a} con

Paso 8: Evaluar la norma Δa

Paso 9: Si cumple con las condiciones de precisión, entonces parar de lo contrario hacer k=k+1 y volver a 3

Paso 2: asumir valores iniciales para a a(0)

(k)

i

(k)

i

1)(k

i Δaaa

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL -Ejemplo

)cos( 21 xaeyxa

Los datos de la gráfica

deberán ser ajustados a la función:

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL -Ejemplo

)sin(

)cos(

)cos(

xaxea

f

xaxea

f

xaexf

xa

xa

xa

2

2

2

1

2

1

1

1

)sin()cos(

)sin()cos(

)sin()cos(

n

xa

n

xa

xaxa

xaxa

nnxaxexaxe

xaxexaxe

xaxexaxe

a

f

a

f

a

f

a

f

a

f

a

f

nn

n

n

22

2222

1212

21

2

2

1

2

2

1

1

1

11

121

111

Jz

)cos(

)cos(

)cos(

n

xa

n

xa

xa

xaey

xaey

xaey

d

n

2

222

121

1

21

11

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL -Ejemplo

{d}[Jz] Δa [Jz][Jz]TT

El proceso de iteración que involucra resolver en cada etapa el sistema

It a1 a2 Delta a1 Delta a2

1 2.1977 5.0646 0.1977 2.06462 1.0264 3.9349 -1.1713 -1.12963 1.1757 4.3656 0.1494 0.43074 1.1009 4.4054 -0.0748 0.03985 1.1035 4.3969 0.0026 -0.00856 1.1030 4.3973 -0.0005 0.00037 1.1030 4.3972 0.0000 0.0000

).cos(.

x39724exfx10301

a1(0) = 2 a2

(0) = 3

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN NO LINEAL -Ejemplo

).cos(.

x39724exfx10301

a1 = 1.1030 a2 = 4.3972

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Comparación)

Regresión Lineal

Solución exacta – Sistema de ecuaciones lineales

{y}[Z] {a} [Z][Z] TT

Regresión No Lineal

Proceso de iteración – Sistema de ecuaciones no lineales.Realmente es una optimización de un funcional no lineal.

{d}[Jz] a}{ [Jz][Jz] TT

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

La cinética enzimática se puede describir en muchos casos empleando la ecuación de Michaelis-Menten.

1

2

,x

f xx

θ

La velocidadde reacciónestá dada eneste caso porla ecuación(modelo):

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

1

2

,x

f xx

θModelo no linealde cinética.

2 2

1 1 1

1 1 1

,

x

f x x x

θModelo linealizadode cinética.

1 2,f y y βNueva estructura lineal de la ecuación.

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

Parámetros1 = 0.0051072

2 = 0.00024722

Regresión lineal del modelo linealizado

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

Retornando a los datos originales

Con los parámetros de la ecuacion de Michaelis-Menten1 = 195.8

2 = 0.048407

El algoritmo de optimización (Método de Gauss-Newton) lleva al proceso iterativo que implicaresolver el sistema lineal

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

La Regresión no lineal, realmente significa que losparámetros se obtienen minimizando el funcional(no-lineal):

2

1

( ) ,n

i i

i

S y f

θ x θ

{d}[Jz] a}{ [Jz][Jz] TT

en forma reiterada hasta encontrar {a}

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

Curvas de Nivel para el funcional S(θ)

Mínimo

Solución para el sistema linealizado

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

REGRESIÓN LINEAL Y NO LINEAL(Un ejemplo)

Regresión no lineal

Regresión lineal(desde el sistema

linealizado)

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOS

La aproximación usada hasta ahora fue CuadradosMínimos Discretos.

Considerar el caso de ajustar la función f(x) a un polinomio Pn(x) en el intervalo [a,b].

Podría pensarse en un funcional distinto y plantear la minimización de una función continua de discrepancia:

dxxfxPE n

b

a

2

Y suponiendo que:

2

210 xaxaaxPn

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOS

Tomando derivadas respecto de los coeficientes a:

Si por ejemplo

0 2i

b

ai

dx

da

xdPxfxP

da

dE nn

xxexf 2)(

La integral del Error será:

12

2 2

0 1 2

0

1

2 2

0 1 2

0 0

1 1 1 1

2 2

0 1 2

0 0 0 0

2 1 0

x

x

x

E x a a x a x xe dx

dE xa a x a x xe dx

da

a dx a x dx a x dx xe dx

Y la condición de mínimo para a0

resulta:

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOS

Separando en términos, integrando los correspondientes

a los coeficientes del polinomio se tiene,

para la primera condición:

1

0 0

0

1

11

0

1

2 22

0

2

3

a dx a

aa x dx

aa x dx

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOSSiguiendo con las otras derivadas, el sistema lineal para el cálculo de los coeficientes será:

Y el vector de términos independientes:

1

0

23

1

0

22

1

0

2

2

1

0

5

1

4

1

3

14

1

3

1

2

13

1

2

11

dxex

dxex

dxxe

a

a

a

x

x

x

38

1

14

1

14

1

2

2

2

1

0

23

1

0

22

1

0

2

e

e

e

dxex

dxex

dxxe

x

x

x

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOS

El polinomio de mínimos cuadrados continuos resulta ser:

21642.95806.23328.0)( xxxPn

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

MÍNIMOS CUADRADOS CONTINUOS

Hay otras funciones para representar funciones continuas,entre las que se pueden destacar:

Polinomios de Legrendre

Polinomios de Chebychev

Funciones con senos y cosenos (funciones de Fourier)

En general se trata de funciones ortogonales,escaladas en distintos intervalos que tienen lapropiedad:

j i if 0

j i if # )( ji

b

a

dxxPxPxw

La función de peso w(x)define el tipo de polinomio

MA

GIS

TE

R E

N M

ET

OD

OS

N

UM

ER

IC

OS

Y

CO

MP

UTA

CIO

NA

LE

S E

N IN

GE

NIE

RIA

FUNCIONES DE MATLAB

polyfit Realiza la regresión polinómica de datos

Sintaxisp = polyfit(x,y,n)[p,S] = polyfit(x,y,n)

polyvalEvalúa una función polinómica

Sintaxisy = polyval(p,x)

top related