3
Regresión Lineal >> x=[0 2 4 6 9 11 12 15 17 19]; >> y=[5 6 7 6 9 8 7 10 12 12]; >> xy=x.*y; >> xx=x.*x; >> a1=(10*sum(xy)-sum(x)*sum(y))/(10*sum(xx)-(sum(x)^2)) a1 = 0.3525 >> a0=mean(y)-a1*mean(x) a0 = 4.8515 % y = 4.8515 + 0.3525x Sumatorias de Error >> Sr = y - a0 - a1*x; >> SrSr = Sr.*Sr; >> SSR= sum(SrSr) SSR = 9.0740 Desviación Estandar >> Syx= sqrt(SSR/(10-2)) Syx = 1.0650

Regresión Lineal

Embed Size (px)

DESCRIPTION

Regresión LinealRegresión Lineal>> x=[0 2 4 6 9 11 12 15 17 19];>> y=[5 6 7 6 9 8 7 10 12 12];>> xy=x.*y;>> xx=x.*x;>> a1=(10*sum(xy)-sum(x)*sum(y))/(10*sum(xx)-(sum(x)^2))

Citation preview

Page 1: Regresión Lineal

Regresión Lineal

>> x=[0 2 4 6 9 11 12 15 17 19];>> y=[5 6 7 6 9 8 7 10 12 12];>> xy=x.*y;>> xx=x.*x;>> a1=(10*sum(xy)-sum(x)*sum(y))/(10*sum(xx)-(sum(x)^2))

a1 =

0.3525

>> a0=mean(y)-a1*mean(x)

a0 =

4.8515

% y = 4.8515 + 0.3525x

Sumatorias de Error

>> Sr = y - a0 - a1*x;>> SrSr = Sr.*Sr;>> SSR= sum(SrSr)

SSR =

9.0740

Desviación Estandar

>> Syx= sqrt(SSR/(10-2))

Syx =

1.0650

Page 2: Regresión Lineal

IntegralesTrapecio simple

a = 0.0b= 0.8

I = (f(a) + f(b))/2*(b-a)

print Iprint (1.640533 - I)/1.640533*100;"%"

function f(x)f = 0.2 + 25*x - 200*x^2 + 675*x^3 - 900*x^4 + 400*x^5end function

trapecio multiple

REM ejemplo 21.1 pag 624 cap 21 chapra

a = 0.0b= 0.8

x0 = ax1 = 0.4x2 = bn= 2

I = (b-a)*(f(x0) + 2*f(x1) + f(x2))/(2*n) 'formula trapecio multipleprint Iprint (1.640533 - I)/1.640533*100;"%"

function f(x)f = 0.2 + 25*x - 200*x^2 + 675*x^3 - 900*x^4 + 400*x^5end function

REM ejemplo 21.1 pag 624 cap 21 chapra

a = 0.0b= 0.8

x0 = ax1 = 0.266x2 = 0.53x3 = bn= 3

Page 3: Regresión Lineal

I = (b-a)*(f(x0) + 2*(f(x1)+f(x2)) + f(x3))/(2*n) 'formula trapecio múltipleprint Iprint (1.640533 - I)/1.640533*100;"%"

function f(x)f = 0.2 + 25*x - 200*x^2 + 675*x^3 - 900*x^4 + 400*x^5end function