Vous êtes sur la page 1sur 17

Functia de gradul 1, de 1 variabila, notata f(x,a,b).

Deducerea regresiei, Matriceal

( 1)

f ( x a b) a b x

Regresia care trebuie determinata

( 2)

x ( 1 2 3 4 5 6 7 8 9 10 )

Valorile masurate ale variabilei independente, x

( 3)

y ( 2.1 3.6 4.5 4.9 5.4 5.9 6.6 7.9 8.1 9.5 )

Valorile masurate ale variabilei dependente, y

( 4)

Expunere teorie generala : Intre (4) - (9).

1
1

1
1

1
X
1

1
1
1

3
4

5
6

8
9

10

Se formeaza matricea X, astfel :

X 4

10

( 5)

A ( a b) ( a b )

A = vectorul necunoscutelor

( 6)

X A = y

Ecuatia Matriceala echivalenta cu ecuatia (1)

( 7)

X T X A = X T yT

( 8)

X T X X T X A = X T X

( 9)

A = X X

Calculez

X T X

y
T

( 10) f ( x ) 1.827 0.732 x

( 1)

( 11) E f x

Apoi calculez

T T

T T

f x

T T

X y

X y

X y

1.827

0.732

E = Erori

T T

f x i y i
10

m 3 10

i 0

f x

Grafic Erori

2.559

2.1

0.459

3.291

3.6

-0.309

4.023

4.5

-0.477

4.755

4.9

-0.145

5.487

5.4

0.087

6.219

5.9

0.319

6.951

6.6

0.351

7.683

7.9

-0.217

8.415

8.1

0.315

9.147

9.5

-0.353

T i

10

10

f x

5
i i

10

y T i

( 2)

Functie (regresie) Multilineara determinata prin Calcul Matriceal

f ( x y z u a b c d e) a b x c y d z e u
|
|
|
|
|
|
|
|
|
|
|

x ( 1.11 1.25 1.49 1.61 1.82 2.05 2.27 2.44 2.61 2.89 )
y ( 1.25 1.39 1.85 1.93 2.35 2.72 3.08 3.74 3.93 4.26 )
z ( 2.36 2.64 2.87 2.99 3.65 4.44 4.86 5.69 5.88 6.33 )
u ( 1.51 1.96 2.31 2.45 2.84 3.14 3.59 4.75 5.02 5.66 )
V ( 14.2 15.5 18.4 20.4 22.3 22.9 26.7 35.2 44.4 53.9 )

Valori M asurate. x,y,z,u,V, unde V = vectorul variabilei dependente


A ( a b c d e) ( a b c d e )

a
b

T
A ( a b c d e) c
d

e

Vectorul

necunoscutelor

Se formeaza Matricea Xq [10, 5], astfel :

1
1

1
1

1
Xq
1

1
1
1

1.11 1.25 2.36 1.51

2.31
2.45

2.84
3.14

3.59

4.75
5.02

5.66

1.25 1.39 2.64 1.96


1.49 1.85 2.87
1.61 1.93 2.99
1.82 2.35 3.65
2.05 2.72 4.44
2.27 3.08 4.86
2.44 3.74 5.69
2.61 3.93 5.88
2.89 4.26 6.33

Xq A = V

XqT Xq AT = XqT VT
1

XqT Xq XqT Xq AT = XqT Xq


T

A = Xq Xq

Xq V

6.594
13.995
1

XqT Xq XqT VT 19.901


2.283

20.733

Fq ( x y z u) 6.594 13.995 x 19.901 y 2.283 z 20.773 u

Xq V

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

Prelucrarea ecuatiei Matriceale

T T

E Fq x y z u

VT

E = Erori

14.2

10.044

-4.156

15.5

17.925

2.425

18.4

18.875

0.475

20.4

21.597

1.197

V 4

22.3

22.772

E 4

0.472

22.9

23.056

0.156

26.7

27.359

0.659

35.2

38.806

3.606

44.4

42.578

-1.822

53.9

52.197

-1.703

60
55
50
45
40
35
T T T T
Fq x y z u i 30
25
20
15
10
5
0
1

T T

Fq x y z u

1
Se

10

( 3)

Ei

Se 0.131

i 0

10

Fq xT yT zT uT i V T
i

i 0

60
55
50
45
40
35
T
30 V i
25
20
15
10
5
0
10

i i

Regresie Sinusoidala rezolvata Matriceal ca Regresie Lineara


f ( x a b) a b sin ( x)
y ( 1.1 1.2 1.3 1.5 1.3 1.0 0.7 0.6 0.4 0.1 )
x ( 1 1.1 1.3 1.6 1.9 2.1 2.3 2.5 2.8 3.1 )

XS 0 UT

XS

sin x

A ( a b)

U ( 1 1 1 1 1 1 1 1 1 1 )

a

b

0.131

( 4)

XS

sin x

0.841

0.891

0.964

0.946

0.863

0.746

0.598

0.335

0.042
T

XS A = y

XS T XS

T T

XS y

0.078

1.381

0.841

0.891

0.964

0.946

0.863

0.746

0.598

0.335

0.042

XS T XS XS T XS A = XS T XS

T T

XS XS A = XS y

fs ( z) 0.07825 1.38146 z

T T

z sin x

0.841

1.084

1.1

0.016

0.891

1.153

1.2

0.047

0.964

1.253

1.3

0.047

1.303

1.5

z 4

0.946

fs ( z) 4

0.197

1.3

y fs ( z) 4

0.071

0.863

-0.114

0.952

0.7

-0.252

0.749

0.6

-0.149

0.335

0.385

0.4

0.015

0.042

-0.021

0.1

0.121

1.229

y 4

1.114

0.746

0.598

8
9

A = XS XS

XS y

T T

XS y

i 0 9

1
Se

10

Grafic Erori

yT fs ( z) i
i

1.6

1.6

i 0

1.4

1.4

stdev y fs ( z) 0.127

1.2

1.2

fs ( z)

0.8

0.6

0.6

0.4

0.4

0.2

0.2

0.2
1

10

Formula stdev

Formula Stdev

1
Stdev V i =

( n 1)

V i mean V i 2
2

1 9
2

yT ( fs ( z) ) 0.00119 0.127
i
i

10
i 0

1
2

Regresie Logaritmica rezolvata Matriceal ca Regresie Lineara


f ( x a b) a b log ( x)
y ( 0.01 0.02 0.13 0.25 0.31 0.36 0.37 0.41 0.49 0.51 )

1
T
XL log x

n 1

1 9
2

yT fs ( z) i 0.00119 0.134
i

9
i0

x ( 1 1.1 1.3 1.6 1.9 2.1 2.3 2.5 2.8 3.1 )

A ( a b)

U ( 1 1 1 1 1 1 1 1 1 1 )

a

b

0.2
11

i i

XL0 UT

i 0

Stdev y fs ( z) 0.134

1 n 1

2
stdev V i =
V i mean V i

i0

yT i

Se 2.08 10

0.8

( 5)
6

log x

XL A = y

( 6)

0.041

0.041

0.114

0.114

0.204

0.204

0.279

XL 4

0.279

0.322

0.322

0.362

0.362

0.398

0.398

0.447

0.447

0.491

0.491

T T

XL XL A = XL y

XLT XL XLT XL A = XLT XL

T T

fo ( z) 0.00616 1.05259 z

1
Se

10

i 0

yT fo ( z) i
i

z log x

T T

XL y

XLT XL

T T

XL y

6.158 10 3

1.053

6.1610-3

0.01

3.8410-3

0.041

0.05

0.02

-0.03

0.114

0.126

0.13

3.90410-3

0.221

0.25

0.204

z 4

0.279

fo ( z) 4

0.322

Se 3.313 10

A = XL XL

XL y

0.029

0.31

y fo ( z) 4

0.01

0.36

0.015

0.387

0.37

-0.017

0.425

0.41

-0.015

0.447

0.477

0.49

0.013

0.491

0.523

0.51

-0.013

0.3

y 4

0.345

0.362

0.398

8
9

stdev y fo ( z) 0.017

Stdev y fo ( z) 0.018

i 0 9

0.6

0.6

0.5

0.5

0.4

0.4

0.3

0.3

fo ( z) 0.2
i

0.2

0.1

0.1

1 n 1

2
stdev V i =
V i mean V i

i0

0.1

yT i

1
Stdev V i =

( n 1)

n 1

V i mean V i 2

i 0
1
2

1 9
2

yT fo ( z) i 0.00119 0.017
i

10
i 0

0.1
0

10

0.2
1

( 7)

Grafic Erori

0.2
11

i i

1
2

1 9
2

yT fo ( z) i 0.00119 0.018
i

9
i0

Regresie Exponentiala cu baza [e], rezolvata ca Regresie Lineara


0

f ( x a b) a b e

0
1

3.1
3.2

y ( 3.1 3.2 3.9 4.5 7.8 12.1 19.1 35.5 46.7 58.8 )

3.9

4.5

x ( 1 1.1 1.3 1.6 1.9 2.4 2.9 3.5 3.8 4.1 )

XE0 UT
A ( a b)

a

b

XE

xT
e

U ( 1 1 1 1 1 1 1 1 1 1 )

7.8

12.1

19.1

35.5

46.7

58.8

( 8)
0

xT
e

XE A = y

2.718

2.718

3.004

3.004

3.669

3.669

4.953

4.953

6.686

XE 4

6.686

11.023

11.023

18.174

18.174

33.115

33.115

44.701

44.701

60.34

60.34

T T

XE XE A = XE y

XET XE XET XE A = XET XE

xT
z e

fe ( z) 0.668 0.998 z

T T

A = XE XE

XE y

T T

XE y

XET XE

T T

XE y

2.718

3.381

3.1

-0.281

3.004

3.666

3.2

-0.466

3.669

4.33

3.9

-0.43

4.953

5.611

4.5

-1.111

z 4

6.686

fe ( z) 4

7.341

y 4

7.8

y fe ( z) 4

0.459

11.023

11.669

12.1

0.431

18.174

18.806

19.1

0.294

33.115

33.717

35.5

1.783

44.701

45.28

46.7

1.42

60.34

60.888

58.8

-2.088

0.668

0.998

Se

1
10

yT fe ( z) i
i

i 0

Se 1.185 10

stdev y fe ( z) 1.084

( 9)

Stdev y fe ( z) 1.143

i 0 9
1

fe ( z)

70

70

60

60

50

50

40

40

30

30

20

20

10

10

1 n 1

2
stdev V i =
V i mean V i

i0

Stdev V i =

1
( n 1)

n 1

V i mean V i 2

i 0

yT i

1
2

1 9
2

yT fe ( z) i 0.00119 1.084
i

10
i 0

1
2

0
1

10

i i

0
11

1 9
2

yT fe ( z) i 0.00119 1.143
i

9
i0

Regresie Exponentiala [cu baza n>0, n rezolvata Matriceal ca Regresie Lineara


f ( x m n) m n

ln ( f ) = ln ( m) x ln ( n)

F = a b x

y ( 2.4 2.8 4.5 7.9 13.5 20.8 30.7 43.1 53.1 77.2 )
x ( 1 1.1 1.3 1.6 1.9 2.1 2.3 2.5 2.6 2.8 )

a
A ( a b)
b

w ln y

ln y

0.875

1.03

1.504

2.067

2.603

3.035

3.424

3.764

3.972

4.346

( 10)

U ( 1 1 1 1 1 1 1 1 1 1 )

xT

XN A = w

1.1

1.1

1.3

1.3

1.6

XN 0 UT

XN

1.6

XN 4

1.9

1.9

2.1

2.1

2.3

2.3

2.5

2.5

2.6

2.6

2.8

2.8

XN XN A = XN w

XN T XN 1 XN T XN A = XN T XN 1 XN T w
( 1.04947 )

1.04947 = ln ( m)

m e

1.93306 = ln ( n)

n e

1.93306

z x

1 XN T w XN T XN 1 XN T w 1.049
1.933

m 0.35
n 6.911
0

fm ( x) ( 0.35012) ( 6.91062)

A = XN XN

2.42

2.4

-0.02

1.1

2.936

2.8

-0.136

1.3

4.321

4.5

0.179

7.717

7.9

1.6

z 4

1.9

fm ( z) 4

0.183

13.5

y fm ( z) 4

-0.282

2.1

20.8

0.514

29.861

30.7

0.839

43.955

43.1

-0.855

2.6

53.329

53.1

-0.229

2.8

78.499

77.2

-1.299

13.782

y 4

20.286

2.3

2.5

8
9

( 11)

Se

1
10

i 0

yT fm ( z) i
i

Se 0.11

stdev y fm ( z) 0.59

Stdev y fm ( z) 0.622

i 0 9

Grafic Erori
80

80
1

70

1 n 1

2
stdev V i =
V i mean V i

i0

70

60

60

50

50

Stdev V i =

( n 1)

n 1

V i mean V i 2

i 0

T i

fm ( z) 40
i

40 y

30

30

20

20

10

10

1 9
2

yT fm ( z) i 0.00119
i

10
i 0

5
i i

10

0
11

0.6

1
2

0
1

1 9
2

yT fm ( z) i 0.00119 0.633
i

9
i0

Regresie multilineara REZOLVATA CLASIC : Metoda Sumei celor mai mici patrate
y(x1,x2,x3,x4) = a + bx1 + cx2 + dx3 + hx4

( 12)

Spatiul cu 5 dimensiuni :

Fm a b c d h x1 x2 x3 x4 a b x1 c x2 d x3 h x4

x3t ( 2.36 2.64 2.87 2.99 3.65 4.44 4.86 5.69 5.88 6.33 )

x1t ( 1.11 1.25 1.49 1.61 1.82 2.05 2.27 2.44 2.61 2.89 )

x4t ( 1.51 1.96 2.31 2.45 2.84 3.14 3.59 4.75 5.02 5.66 )

x2t ( 1.25 1.39 1.85 1.93 2.35 2.72 3.08 3.74 3.93 4.26 )

Yt ( 14.2 15.5 18.4 20.4 22.3 22.9 26.7 35.2 44.4 53.9 )

1.11

1.25

2.36

1.51

1.25

1.39

2.64

1.96

1.49

1.85

2.87

2.31

1.93

2.99

2.45

2.35

3.65

2.84

1.61

x1t 4

1.82

2.05

2.72

4.44

3.14

2.27

3.08

4.86

3.59

2.44

3.74

5.69

4.75

2.61

3.93

5.88

5.02

2.89

4.26

6.33

5.66

Se defineste :

x T
2t

U ( 1 1 1 1 1 1 1 1 1 1 )
n

S ( a b c d h) =

i 0

F i y i 2

n5

x T
3t

Necunoscute

x T
4t

a, b, c, d, h

F i y i = diferenta pentru fiecare punct

Fm xt 1 Yt 1

Fm xt 2 Yt 2

...

( 13)
9

S ( a b c d h) =

F x T .j YtT
j
m it

with :

S = 0

da

S = 0

db

S = 0

dc

S =0

dd

S = 0

dh

j 0

a, b, c, d, h
|
|
|
|
|
|
|
|
|
|
|
|
|
|

S = 0

da
d

S = 0

db
d

S = 0

Sistem de 5 ecuatii cu 5 necunoscute

( 2)

dc
d

S =0

dd
d

S = 0

dh
9

S ( a b c d h)

i 0
0

U
0

S = 2

da

d
db

i 0

S = 2

i 0

1
1

a b x T c x T d x T h x T YtT
i
1t i

2t i
3t i
4t i

2
1

3
1

4
1

5
1

6
1

7
1

8
1

9
1

a b x T c x T d x T h x T YtT = 0
i
1t i

2t i
3t i
4t i

a b x T c x T d x T h x T YtT x T = 0
i 1t i
1t i

2t i
3t i
4t i

T
T
Yt i = U Yt

v0 U Yt

i 0

i 0

YtT x T = Yt x T
1t
i 1t i

v1 Yt x1t

S = 2

dc

dh

dd

T T
a b x
T
T
T
1t i c x2t i d x3t i h x4t i Yt i x2t i = 0

i 0

S = 2

i 0

S = 2

i 0

a b x T c x T d x T h x T YtT x T = 0
i 3t i
1t i

2t i
3t i
4t i

a b x T c x T d x T h x T YtT x T = 0
i 4t i
1t i

2t i
3t i
4t i

1 10

i 0

x T = U xtT
1t i

( 14)

Yt x T = Yt x T
i 2t i
2t

v2 Yt x2t

YtT x T = Yt x T
i 3t i
3t

v3 Yt x3t

T
T
T
Yt i x4t i = Yt x4t

v4 Yt x4t

i 0

i 0

i 0

x T = U x T
2t i
2t

i 0

i 0

Definesc : Elementele matricei M[5 x 5]


T

M1 10
T

N1 x1t x1t

N4 x1t x4t

Q2 x3t x4t

P3 x4t x2t

Q1 x3t x3t

T
T

P3 x2t x4t

N4 x1t x4t

M5 U x4t

P2 x3t x2t

P2 x2t x3t

N3 x1t x3t

N3 x1t x3t

M5 U x4t

P1 x2t x2t

N2 x1t x2t

M4 U x3t

N2 x1t x2t

M3 U x2t

M4 U x3t

M2 U x1t

M3 U x2t

M2 U x1t

Q2 x4t x3t

R1 x4t x4t

M1
M2

M M3
M4

M5

M2 M3 M4 M5

10
19.54

M 26.5
41.71

33.23

N2 P1 P2 P3
N3 P2 Q1 Q2

N4 P3 Q2 R1
N1

N2

N3

N4

M 0.192

19.54

26.5

41.71

41.392

57.528

89.311

57.528

80.629

124.678

89.311 124.678 193.391


72.317 101.491 156.821

10.205 15.201 15.671


15.201 30.073 22.887

15.671 22.887 36.151


3.796
1.39
9.657

1.834 3.399 7.966

6.594
13.995

1
M V1 19.901
2.283

20.733

v0
v1

V1 v2
v3

v4

72.317

101.491
156.821

128.072

273.9

601.08
V1 845.39

3
1.304

10

3
1.071 10

3.796 1.834

9.657 7.966
5.647 0.939

0.939 3.727
1.39

3.399

Fm a b c d h x1 x2 x3 x4 a b x1 c x2 d x3 h x4

a 6.594

b 13.995

c 19.901

d 2.283

h 20.733

Se por compara
rezultatele obtinute
prin cele doua
metode.

Fs x1t x2t x3t x4t 6.594 13.995x1t 19.901 x2t 2.283 x3t 20.733 x4t

Fs x1t x2t x3t x4t

33.23

9.983

14.2

-4.217

17.847

15.5

2.347

18.783

18.4

0.383

21.499

20.4

1.099

Yt 4

0.358

22.9

0.03

26.7

0.516

38.616

35.2

3.416

42.378

44.4

-2.022

51.971

53.9

-1.929

22.658

Yt 4

22.3

22.93

27.216

Fs x1t x2t x3t x4t

( 15)

Calculul erorilor

T
i Yt i

Fs x1t x2t x3t x4t

m 2.054 10

10

( 16)

i 0

Fs x1t x2t x3t x4t

60

60

48

48

36

36

24

24

12

12
0

YtT i

10

i i

Invers : Fiind data o relatie liniara de forma ax+by+cz+... , relatie care descrie un fenomen oarecare,
si fiind apoi posibil a se efectua masuratori asupra acestui fenomen,
la momente diferite de timp : t1, t2, t3,..., rezulta in final, urmatoarele date notate (1), (2),...(6) si
marcate cu culoare verde, astfel :
Valorile notate 1,2...6 cu culoare verde,
sunt valori masurate
Sa se rezolve sistemul
de ecuatii simultane:

x 0.51 1.51 , Relatie necesara pentru afisarea graficului


Prelucrez sistemul de ecuatii dupa acelasi procedeu, si rezulta (xo, yo)
( 1)

( 1)

xy= 3

( 2)

3x y = 1

( 3)

2x y = 4.1

( 4)

3x y = 5.3

( 5)

x y = 1.2

( 6)

x 3y = 6.9

1
3
2
A
3
1
1

1
1
25 5
T
A A
B
1
5 14

3
1
4.1

5.3

1.2
6.9

xo yo 3.041

Valorile expresiilor algebrice


pentru [xo ; yo] determinati :

xo 1.03

yo 2.011

e1 3 3.041

e1 0.041

( 2)

3xo yo 1.079

e2 1 1.079

e2 0.079

( 3)

2xo yo 4.071

e3 4.1 4.071

e3 0.029

( 4)

3xo yo 5.101

e4 5.3 5.101

e4 0.199

( 5)

xo yo 0.981

e5 1.2 0.981 e5 0.219

( 6)

xo 3yo 7.063

e6 6.9 7.063

e6 0.163

( 17)

AT A 1 AT B 1.03
2.011

Solutia ar trebui sa fie [1 ; 2]


Fiecare ecuatie este aprox.egala
cu valorile obtinute
din inlocuirea : xp=1 ; yp=2.
Rezultat real : xo=1.03 ; yo=2.011

yo = 2.011

Media erorilor = Me :

4.00
3 x

3.50

1 3x

3.00

4.1 2 x

2.50

xo = xp 3.0% xp

5.3 3x

2.00

yo = yp 1.1% yp

1.2 x

1.50

Me = Mo 1.9%

xo = 1.03

e1 e2 e3 e4 e5 e6
6

0.019

1.03

2.011

2.3 0.33x 1.00


0.50
0.00
0.50

0.70

0.90

1.10

1.30

1.50

eof
=============================================================================================================================

Vous aimerez peut-être aussi