• Non ci sono risultati.

Consente di determinare la funzione che meglio si approssima ai dati.

N/A
N/A
Protected

Academic year: 2021

Condividi "Consente di determinare la funzione che meglio si approssima ai dati."

Copied!
24
0
0

Testo completo

(1)

3 2 2 1 2

2 2 1

N N N

N

f

 

2 1

N fN

2

 30 N

1

 9 N

013 .

2f

 0

114 .

 0

f

1 . 0 3 .

0 

fN

1

f

2

 30

N

(2)

2

 20 N

N

1

f

2

 10 N

N

1

f

(3)
(4)
(5)
(6)
(7)
(8)
(9)

-Il metodo dei minimi quadrati (least square fitting)

Dato un insieme di n punti sperimentali.

Consente di determinare la funzione che meglio si approssima ai dati.

) , ( ) , ( ) , ( ) ,

( x

1

y

1

x

2

y

2

x

3

y

3

x

n

y

n

min ))

(

(

2

1



 

n

i

i

i

f x

y

(10)

-Se scegliamo di utilizzare una retta (fit lineare)

b ax

x

f (

i

) 

i

min ))

(

(

2

1



 

n

i

i

i

ax b

y

0 ))

(

(

2

1

 

 

n

i

i

i

ax b

a y

0 ))

(

(

2

1

 

 

n

i

i

i

ax b

b y

[1]

[2]

(11)

0 ))

(

(

2

1

 

 

n

i

i

i

ax b

b y

0 ))

( (

2

1

 

n

i

i

i

ax b

y

0

1 i 1 i 1

   

n

i

n n

i

i

ax b

y 0

1 i 1

  

n

i

n

i

i

ax nb

y

 

n

i

n

i

i

i

ax

y nb

1 1

n

ax y

b

n

i

n

i

i

i

1 1

n

x a

y b

n

i

n

i i

i

1

1

[2]

[3]

(12)

0 ))

(

(

2

1

 

 

n

i

i

i

ax b

a y

0 ))

( (

2

1

 

n

i

i i

i

y ax b

x

0

1 i 1 i 1

2

 

   

n

i

n i n

i i

i

y ax bx

x

n

x a

y b

n

i

n i

i

1

i 1

0

1 i 1

1 i 1

1 i

2

 

    

n

i

n

n

i

n i i

i n

i i

i

n

x a

y x

ax y

x

0

2

1 i 1

1 i 1 i 1

i

2

 

 

 

  

n

x a

n y x

ax y

x

n n i

i

n i n

i n

i i

i

[3]

(13)

1

1 i 1 i 2

1 i 1

i

2

   

 

 

n

i

n i n

i i

i n

n i

i

n

y x

y n x

x a

ax

n x x

n y x

y x

a

n

n i i n

i

n i n

i i

i

2

1 i 1

i

2 1

1 i 1

i

 

 

 

 

  

2

1 i 1

i

2

1 i 1 i 1

 

 

 

 

  

n i n

i n

i

n i n

i i

i

x x

n

y x

y x n

a [4]

(14)

n

x a

y b

n

i

n

i i

i

1

1

[3]

  

 

n

i n

i i n

i

n i n

i i

i

x x

n

y x

y x n

a

1 i

2 1

2

1 i 1 i 1

) (

[4]

n x x

x n

y x

y x n

n y b

n

i i n

i n

i i n

i

n i n

i i

i n

i

i

  

 

1

1 i

2 1

2

1 i 1 i 1

1

)

(

) ) (

(

) (

1

2 1

2

1 i 1

2 1

i 1

i 1

   

 

n

i i n

i i n

i

n i n

i n

i i

i n

i i

x x

n n

y x

x y

x n

n y b

) ) (

(

) (

- )

( -

1

2 1

2

1 1

2 1

1

1 1

2 1

n

1 i

2

   

  

n

i i n

i i

n

i

n

i i n

i i n

i i i

i n

i

n

i i n

i i i

i

x x

n n

y x

x y

x n

y x

y x

n

b

(15)

) ) (

(

-

1

2 1

2

1 1

1 1

2

 

n

i i n

i i

n

i

n

i i i

i n

i i n

i i

x x

n n

x y

x n

y x

n b

 

n

i i n

i i

n

i

n

i i i

i n

i i n

i i

x x

n

x y

x y

x b

1

2 1

2

1 1

1 1

2

) (

-

n x x

n

x y

x y

x

b

n

i n i

i i

n

i

n

i i i

i n

i i n

i

 

 

1

2

1 2

1 1

1 1

2

) (

-

(16)

2 1

2

1 1

2

) (

x n x

y x x

x y

b

n

i i

n

i

i i n

i

 

[5]

  

 

n

i n

i i n

i

n i n

i i

i

x x

n

y x

y x n

a

1 i

2 1

2

1 i 1 i 1

) (

[4]

n x x

n y x

y x

a

n

i n

i i n

i

n i n

i i

i

 

  

 

1 i

2

1 2 1

1 i 1 i

) (

2 1

2 1

) (

x n x

y x n y

x

a

n

i i n

i

i i

 

[6]

(17)

Se la funzione con cui vogliamo rappresentare i dati non è una retta, ma ad esempio un

polinomio allora

Se la funzione con cui vogliamo rappresentare i dati non è una retta, ma ad esempio un

polinomio allora

min )

) (

(

2

1



 

n

i

i

i

f x

y

k i k i

i i

i

a a x a x a x a x

x

f ( ) 

0

1

2 2

3 3

(18)

0 )

...

(

(

2

1

3 3 2

2 1

0 0

 

 

n

i

k i k i

i i

i

a a x a x a x a x

a y

0 )

...

(

(

2

1

3 3 2

2 1

0 1

 

 

n

i

k i k i

i i

i

a a x a x a x a x

a y

0 )

...

(

(

2

1

3 3 2

2 1

0 2

 

 

n

i

k i k i

i i

i

a a x a x a x a x

a y

0 )

...

(

(

2

1

3 3 2

2 1

0

    

 

 

n

i

k i k i

i i

i k

x a x

a x

a x

a a

a y

...

(19)

Per trovare (col metodo dei minimi quadrati) la miglior “gaussiana” che approssima i dati

2 0 2

2 ) (

0

, ) A

, ,

( x A xe

x x

f

0 ))

A ( (

1

2 2 ) (

2 0 2

 

 

n

i

x x

i

e

A y

0 ))

A ( (

1

2 2 ) (

0

2 0 2

 

 

n

i

x x

i

e

x y

0 ))

A ( (

1

2 2 ) (

2 0 2

 

 

n

i

x x

i

e

y

(20)
(21)
(22)
(23)
(24)

Riferimenti